NVIDIA DOCA™ HBN supports access control lists (ACLs) for filtering traffic on NVIDIA® BlueField® interfaces. ACLs can permit or block traffic based on packet fields and, for stateful ACLs, connection state.
-
Stateless ACLs evaluate each packet independently against the configured match criteria.
-
Stateful ACLs evaluate packets in the context of a tracked connection.
Before You Begin
-
Identify the host representor port or subinterface and the direction in which the ACL must apply.
-
Replace interface names, addresses, ports, MAC addresses, rule IDs, and ACL names in the examples with deployment-specific values.
-
Use either NVIDIA® user experience (NVUE) or flat-file configuration for a given rule set, and apply the configuration after making changes.
The addresses shown on this page are example values.
Stateless ACLs
HBN supports stateless ACLs for IPv4 packets, IPv6 packets, and Ethernet frames. You can bind a stateless ACL to a host representor port, such as pf0hpf_if or pf0vf0_if, or to a host representor subinterface, such as pf0hpf_if.500 or pf0vf0_if.999.
NVUE Examples
IPv4 ACLs
The following ingress ACL permits DHCP requests received on pf0vf1_if.999:
nv set acl acl1_ingress type ipv4
nv set acl acl1_ingress rule 100 match ip protocol udp
nv set acl acl1_ingress rule 100 match ip dest-port 67
nv set acl acl1_ingress rule 100 match ip source-port 68
nv set acl acl1_ingress rule 100 action permit
Bind the ACL to the interface in the inbound direction, and apply the configuration:
nv set interface pf0vf1_if.999 acl acl1_ingress inbound
nv config apply
The following egress ACL permits DHCP replies sent through pf0vf1_if.999:
nv set acl acl2_egress type ipv4
nv set acl acl2_egress rule 200 match ip protocol udp
nv set acl acl2_egress rule 200 match ip dest-port 68
nv set acl acl2_egress rule 200 match ip source-port 67
nv set acl acl2_egress rule 200 action permit
Bind the ACL to the interface in the outbound direction, and apply the configuration:
nv set interface pf0vf1_if.999 acl acl2_egress outbound
nv config apply
IPv6 ACLs
The following ingress ACL permits TCP traffic with destination address 48:2034::80:9 on pf0hpf_if:
nv set acl acl5_ingress type ipv6
nv set acl acl5_ingress rule 100 match ip protocol tcp
nv set acl acl5_ingress rule 100 match ip dest-ip 48:2034::80:9
nv set acl acl5_ingress rule 100 action permit
Bind the ACL to the interface in the inbound direction, and apply the configuration:
nv set interface pf0hpf_if acl acl5_ingress inbound
nv config apply
The following egress ACL permits TCP traffic with source address 48:2034::80:9 on pf0hpf_if:
nv set acl acl6_egress type ipv6
nv set acl acl6_egress rule 101 match ip protocol tcp
nv set acl acl6_egress rule 101 match ip source-ip 48:2034::80:9
nv set acl acl6_egress rule 101 action permit
Bind the ACL to the interface in the outbound direction, and apply the configuration:
nv set interface pf0hpf_if acl acl6_egress outbound
nv config apply
MAC ACLs
The following ingress ACL permits frames that match the specified source and destination MAC addresses:
nv set acl acl3_ingress type mac
nv set acl acl3_ingress rule 1 match mac source-mac 00:00:00:00:00:0a
nv set acl acl3_ingress rule 1 match mac dest-mac 00:00:00:00:00:0b
Bind the ACL to pf0hpf_if in the inbound direction, and apply the configuration:
nv set interface pf0hpf_if acl acl3_ingress inbound
nv config apply
The following egress ACL permits frames that match the reverse source and destination MAC addresses:
nv set acl acl4_egress type mac
nv set acl acl4_egress rule 2 match mac source-mac 00:00:00:00:00:0b
nv set acl acl4_egress rule 2 match mac dest-mac 00:00:00:00:00:0a
nv set acl acl4_egress rule 2 action permit
Bind the ACL to pf0hpf_if in the outbound direction, and apply the configuration:
nv set interface pf0hpf_if acl acl4_egress outbound
nv config apply
Flat-File Examples
For flat-file configuration, add the corresponding rules to a file under /etc/cumulus/acl/policy.d/, and then run cl-acltool -i. The rules use Linux iptables, ip6tables, or ebtables syntax.
IPv4 ACLs
Ingress DHCP request rule:
[iptables]
## ACL acl1_ingress in dir inbound on interface pf1vf1_if.999 ##
-t filter -A FORWARD -m physdev --physdev-in pf1vf1_if.999 -p udp --sport 68 --dport 67 -j ACCEPT
Egress DHCP reply rule:
[iptables]
## ACL acl2_egress in dir outbound on interface pf1vf1_if.999 ##
-t filter -A FORWARD -m physdev --physdev-out pf1vf1_if.999 -p udp --sport 67 --dport 68 -j ACCEPT
IPv6 ACLs
Ingress rule that matches the destination address and TCP protocol:
[ip6tables]
## ACL acl5_ingress in dir inbound on interface pf0hpf_if ##
-t filter -A FORWARD -m physdev --physdev-in pf0hpf_if -d 48:2034::80:9 -p tcp -j ACCEPT
Egress rule that matches the source address and TCP protocol:
[ip6tables]
## ACL acl6_egress in dir outbound on interface pf0hpf_if ##
-t filter -A FORWARD -m physdev --physdev-out pf0hpf_if -s 48:2034::80:9 -p tcp -j ACCEPT
MAC ACLs
Ingress rule that matches the source and destination MAC addresses:
[ebtables]
## ACL acl3_ingress in dir inbound on interface pf0hpf_if ##
-t filter -A FORWARD -m physdev --physdev-in pf0hpf_if -s 00:00:00:00:00:0a/ff:ff:ff:ff:ff:ff -d 00:00:00:00:00:0b/ff:ff:ff:ff:ff:ff -j ACCEPT
Egress rule that matches the reverse source and destination MAC addresses:
[ebtables]
## ACL acl4_egress in dir outbound on interface pf0hpf_if ##
-t filter -A FORWARD -m physdev --physdev-out pf0hpf_if -s 00:00:00:00:00:0b/ff:ff:ff:ff:ff:ff -d 00:00:00:00:00:0a/ff:ff:ff:ff:ff:ff -j ACCEPT
Stateful ACLs
HBN implements stateful ACLs through a reflexive ACL mechanism. This mechanism permits a connection initiated from one side of the network and permits return traffic only for the tracked connection.
Stateful ACLs support IPv4 and IPv6 traffic with TCP, UDP, and ICMP. You can bind them to host representor ports or host representor subinterfaces.
You can apply stateful ACLs to:
-
Native routed traffic, referred to as native Layer 3 stateful ACLs.
-
EVPN bridged traffic, referred to as EVPN Layer 2 stateful ACLs.
-
EVPN routed traffic, referred to as EVPN Layer 3 stateful ACLs.
Stateful ACLs are enabled by default. If they were disabled, enable them with NVUE:
nv set system reflexive-acl enable
nv config apply
For flat-file configuration, set rflx.reflexive_acl_enable to TRUE in /etc/cumulus/nl2docad.d/acl.conf, and reload the configuration:
supervisorctl start nl2doca-reload
NVUE Example
The following example permits the host to initiate an HTTP connection to server 11.11.11.11. It uses one inbound rule for new and established traffic and one outbound rule for established return traffic. Bind both rules to the same host representor port or subinterface. This example uses pf1vf7_if.
-
Configure the inbound rule:
nv set acl allow_tcp_conn_from_host rule 11 action permit
nv set acl allow_tcp_conn_from_host rule 11 match conntrack new
nv set acl allow_tcp_conn_from_host rule 11 match conntrack established
nv set acl allow_tcp_conn_from_host rule 11 match ip dest-ip 11.11.11.11/32
nv set acl allow_tcp_conn_from_host rule 11 match ip dest-port 80
nv set acl allow_tcp_conn_from_host rule 11 match ip protocol tcp
nv set acl allow_tcp_conn_from_host type ipv4
-
Bind the inbound rule, and apply the configuration:
nv set interface pf1vf7_if acl allow_tcp_conn_from_host inbound
nv config apply
-
Configure the outbound rule:
nv set acl allow_tcp_resp_from_server rule 21 action permit
nv set acl allow_tcp_resp_from_server rule 21 match conntrack established
nv set acl allow_tcp_resp_from_server rule 21 match ip protocol tcp
nv set acl allow_tcp_resp_from_server type ipv4
nv config apply
-
Bind the outbound rule, and apply the configuration:
nv set interface pf1vf7_if acl allow_tcp_resp_from_server outbound
nv config apply
After both rules are applied, the host can initiate the permitted HTTP connection, and established return traffic can traverse the outbound path.
Flat-File Example
Add the corresponding rules to /etc/cumulus/acl/policy.d/stateful_acl.rules, and then run cl-acltool -i.
Inbound rule:
[iptables]
## ACL allow_tcp_conn_from_host in dir inbound on interface pf1vf7_if ##
-t filter -A FORWARD -m physdev --physdev-in pf1vf7_if -p tcp -d 11.11.11.11/32 --dport 80 -m conntrack --ctstate EST,NEW -j ACCEPT -m mark --mark 0xdead
Outbound rule:
[iptables]
## ACL allow_tcp_resp_from_server in dir outbound on interface pf1vf7_if ##
-t filter -A FORWARD -m physdev --physdev-out pf1vf7_if -p tcp -s 11.11.11.11/32 --sport 80 -m conntrack --ctstate EST -j ACCEPT -m mark --mark 0xdead
Last updated: