acl: add dumper for acls

A reasonable attempt will be made to shorten the output of terms, but
due to the nature of the ACL plugin in VPP, all ACLs will be unrolled
into their individual ACEs (called 'terms').

- src/dst-port will only be emitted with UDP/TCP
- icmp-typc/code will only be emitted with ICMP/ICMPv6
- icmp-code/type and source/destination-ports ranges will be collapsed
  where appropriate.
- if protocol is 0, only L3 information will be emitted

NOTE: a bug in the VPP plugin will allow for ICMP 'sport' and 'dport'
upper value to be 16 bits. If an ACE is retrieved from the dataplane
regarding an ICMP or ICMPv6 (referring the 16 bit values to icmp type
and code), they will be truncated and a warning issued.
This commit is contained in:
Pim van Pelt
2023-01-16 17:12:48 +00:00
parent 7a69f657db
commit 871e5a7d8b

View File

@ -119,8 +119,8 @@ class VPPApi:
"interface_names": {}, "interface_names": {},
"interfaces": {}, "interfaces": {},
"interface_addresses": {}, "interface_addresses": {},
"interface_acls": {},
"interface_mpls": {}, "interface_mpls": {},
"interface_acls": {},
"bondethernets": {}, "bondethernets": {},
"bondethernet_members": {}, "bondethernet_members": {},
"bridgedomains": {}, "bridgedomains": {},
@ -382,6 +382,19 @@ class VPPApi:
f"MPLS state retrieval requires https://gerrit.fd.io/r/c/vpp/+/39022" f"MPLS state retrieval requires https://gerrit.fd.io/r/c/vpp/+/39022"
) )
try:
self.logger.debug("Retrieving ACLs")
api_response = self.vpp.api.acl_dump(acl_index=0xFFFFFFFF)
for acl in api_response:
self.cache["acls"][acl.acl_index] = acl
self.logger.debug("Retrieving interface ACLs")
api_response = self.vpp.api.acl_interface_list_dump()
for iface in api_response:
self.cache["interface_acls"][iface.sw_if_index] = iface
except AttributeError:
self.logger.warning(f"ACL API not found - missing plugin: {err}")
self.logger.debug("Retrieving bondethernets") self.logger.debug("Retrieving bondethernets")
api_response = self.vpp.api.sw_bond_interface_dump() api_response = self.vpp.api.sw_bond_interface_dump()
for iface in api_response: for iface in api_response: