src: Support netdev egress hook
Pablo Neira Ayuso
maintainerPATCH 1/1 src: Support netdev egress hook
From: Lukas Wunner <[email protected]>
Add userspace support for the newly introduced netdev egress hook with documentation and tests. Usage is identical to the ingress hook.
---
Hi Lukas,
This is the rebase I'm using here locally for testing, let me know if you have more pending updates on your side.
doc/nft.txt | 19 +- doc/statements.txt | 4 +- include/linux/netfilter.h | 1 + src/evaluate.c | 2 + src/rule.c | 3 + tests/py/any/dup.t | 3 +- tests/py/any/icmpX.t.netdev | 3 +- tests/py/any/limit.t | 3 +- tests/py/any/meta.t | 3 +- tests/py/any/objects.t | 3 +- tests/py/any/quota.t | 3 +- tests/py/any/rawpayload.t | 3 +- tests/py/arp/arp.t | 3 +- tests/py/bridge/vlan.t | 3 +- tests/py/inet/ah.t | 2 + tests/py/inet/comp.t | 3 +- tests/py/inet/dccp.t | 3 +- tests/py/inet/esp.t | 3 +- tests/py/inet/ether-ip.t | 3 +- tests/py/inet/ether.t | 3 +- tests/py/inet/ip.t | 3 +- tests/py/inet/ip.t.payload.netdev | 14 + tests/py/inet/ip_tcp.t | 3 +- tests/py/inet/map.t | 3 +- tests/py/inet/sctp.t | 3 +- tests/py/inet/sets.t | 3 +- tests/py/inet/tcp.t | 3 +- tests/py/inet/udp.t | 3 +- tests/py/inet/udplite.t | 3 +- tests/py/ip/ip.t | 3 +- tests/py/ip/ip_tcp.t | 2 + tests/py/ip/ip_tcp.t.payload.netdev | 93 + tests/py/ip/sets.t | 3 +- tests/py/ip6/frag.t | 2 + tests/py/ip6/frag.t.payload.netdev | 2186 +++++++++++++++++ tests/py/ip6/sets.t | 3 +- tests/py/ip6/vmap.t | 3 +- tests/shell/testcases/chains/0021prio_0 | 1 + .../shell/testcases/chains/0026prio_netdev_1 | 4 +- .../testcases/chains/dumps/0021prio_0.nft | 20 + 40 files changed, 2395 insertions(+), 36 deletions(-) create mode 100644 tests/py/ip/ip_tcp.t.payload.netdev create mode 100644 tests/py/ip6/frag.t.payload.netdev
doc/nft.txt +12 -7
@@ -193,7 +193,7 @@ packet processing paths, which invoke nftables if rules for these hooks exist. *inet*:: Internet (IPv4/IPv6) address family. *arp*:: ARP address family, handling IPv4 ARP packets. *bridge*:: Bridge address family, handling packets which traverse a bridge device. -*netdev*:: Netdev address family, handling packets from ingress. +*netdev*:: Netdev address family, handling packets on ingress and egress. All nftables objects exist in address family specific namespaces, therefore all identifiers include an address family. If an identifier is specified without an
@@ -251,9 +251,9 @@ The list of supported hooks is identical to IPv4/IPv6/Inet address families abov NETDEV ADDRESS FAMILY ~~~~~~~~~~~~~~~~~~~~ -The Netdev address family handles packets from the device ingress path. This -family allows you to filter packets of any ethertype such as ARP, VLAN 802.1q, -VLAN 802.1ad (Q-in-Q) as well as IPv4 and IPv6 packets. +The Netdev address family handles packets from the device ingress and egress +path. This family allows you to filter packets of any ethertype such as ARP, +VLAN 802.1q, VLAN 802.1ad (Q-in-Q) as well as IPv4 and IPv6 packets. .Netdev address family hooks [options="header"]
@@ -263,6 +263,10 @@ VLAN 802.1ad (Q-in-Q) as well as IPv4 and IPv6 packets. All packets entering the system are processed by this hook. It is invoked after the network taps (ie. *tcpdump*), right after *tc* ingress and before layer 3 protocol handlers, it can be used for early filtering and policing. +|egress | +All packets leaving the system are processed by this hook. It is invoked after +layer 3 protocol handlers and after *tc* egress. It can be used for late +filtering and policing. |================= RULESET
@@ -388,9 +392,10 @@ Apart from the special cases illustrated above (e.g. *nat* type not supporting *forward* hook or *route* type only supporting *output* hook), there are three further quirks worth noticing: -* The netdev family supports merely a single combination, namely *filter* type and - *ingress* hook. Base chains in this family also require the *device* parameter - to be present since they exist per incoming interface only. +* The netdev family supports merely two combinations, namely *filter* type with + *ingress* hook and *filter* type with *egress* hook. Base chains in this + family also require the *device* parameter to be present since they exist per + interface only. * The arp family supports only the *input* and *output* hooks, both in chains of type *filter*. * The inet family also supports the *ingress* hook (since Linux kernel 5.10),
doc/statements.txt +2 -2
@@ -668,8 +668,8 @@ dup to ip daddr map { 192.168.7.1 : "eth0", 192.168.7.2 : "eth1" } FWD STATEMENT ~~~~~~~~~~~~~ The fwd statement is used to redirect a raw packet to another interface. It is -only available in the netdev family ingress hook. It is similar to the dup -statement except that no copy is made. +only available in the netdev family ingress and egress hooks. It is similar to +the dup statement except that no copy is made. *fwd to* 'device'
include/linux/netfilter.h +1 -0
@@ -54,6 +54,7 @@ enum nf_inet_hooks {enum nf_dev_hooks {NF_NETDEV_INGRESS , +NF_NETDEV_EGRESS ,NF_NETDEV_NUMHOOKS };
src/evaluate.c +2 -0
@@ -4310,6 +4310,8 @@ static uint32_t str2hooknum(uint32_t family, const char *hook)case NFPROTO_NETDEV :if (!strcmp (hook,"ingress" ))return NF_NETDEV_INGRESS ; +else if (!strcmp (hook,"egress" )) +return NF_NETDEV_EGRESS ;break ;default :break ;
src/rule.c +3 -0
@@ -675,6 +675,7 @@ static const char * const chain_hookname_str_array[] = {"postrouting" ,"output" ,"ingress" , +"egress" , NULL, };
@@ -832,6 +833,8 @@ const char *hooknum2str(unsigned int family, unsigned int hooknum)switch (hooknum) {case NF_NETDEV_INGRESS :return "ingress" ; +case NF_NETDEV_EGRESS : +return "egress" ; }break ;default :
tests/py/any/dup.t +2 -1
@@ -1,6 +1,7 @@ :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress dup to "lo";ok dup to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"};ok
tests/py/any/icmpX.t.netdev +2 -1
@@ -1,6 +1,7 @@ :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress ip protocol icmp icmp type echo-request;ok;icmp type echo-request icmp type echo-request;ok
tests/py/any/limit.t +2 -1
@@ -1,12 +1,13 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;output *ip6;test-ip6;output *inet;test-inet;output *arp;test-arp;output *bridge;test-bridge;output -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress limit rate 400/minute;ok limit rate 20/second;ok
tests/py/any/meta.t +2 -1
@@ -1,12 +1,13 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input *arp;test-arp;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress meta length 1000;ok meta length 22;ok
tests/py/any/objects.t +2 -1
@@ -1,12 +1,13 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;output *ip6;test-ip6;output *inet;test-inet;output *arp;test-arp;output *bridge;test-bridge;output -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress %cnt1 type counter;ok %qt1 type quota 25 mbytes;ok
tests/py/any/quota.t +2 -1
@@ -1,12 +1,13 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;output *ip6;test-ip6;output *inet;test-inet;output *arp;test-arp;output *bridge;test-bridge;output -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress quota 1025 bytes;ok quota 1 kbytes;ok
tests/py/any/rawpayload.t +2 -1
@@ -1,8 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress meta l4proto { tcp, udp, sctp} @th,16,16 { 22, 23, 80 };ok;meta l4proto { 6, 17, 132} th dport { 22, 23, 80} meta l4proto tcp @th,16,16 { 22, 23, 80};ok;tcp dport { 22, 23, 80}
tests/py/arp/arp.t +2 -1
@@ -1,9 +1,10 @@ # filter chains available are: input, output, forward :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *arp;test-arp;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress arp htype 1;ok arp htype != 1;ok
tests/py/bridge/vlan.t +2 -1
@@ -1,8 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress vlan id 4094;ok vlan id 0;ok
tests/py/inet/ah.t +2 -0
@@ -1,10 +1,12 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook ingress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input *netdev;test-netdev;ingress +*netdev;test-netdev;egress - ah nexthdr esp;ok - ah nexthdr ah;ok
tests/py/inet/comp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress # BUG: nft: payload.c:88: payload_expr_pctx_update: Assertion `left->payload.base + 1 <= (__PROTO_BASE_MAX - 1)' failed. - comp nexthdr esp;ok;comp nexthdr 50
tests/py/inet/dccp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress dccp sport 21-35;ok dccp sport != 21-35;ok
tests/py/inet/esp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress esp spi 100;ok esp spi != 100;ok
tests/py/inet/ether-ip.t +2 -1
@@ -1,8 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress tcp dport 22 iiftype ether ip daddr 1.2.3.4 ether saddr 00:0f:54:0c:11:4 accept;ok;tcp dport 22 ether saddr 00:0f:54:0c:11:04 ip daddr 1.2.3.4 accept tcp dport 22 ip daddr 1.2.3.4 ether saddr 00:0f:54:0c:11:04;ok
tests/py/inet/ether.t +2 -1
@@ -1,11 +1,12 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress tcp dport 22 iiftype ether ether saddr 00:0f:54:0c:11:4 accept;ok;tcp dport 22 ether saddr 00:0f:54:0c:11:04 accept tcp dport 22 ether saddr 00:0f:54:0c:11:04 accept;ok
tests/py/inet/ip.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress ip saddr . ip daddr . ether saddr { 1.1.1.1 . 2.2.2.2 . ca:fe:ca:fe:ca:fe };ok ip saddr vmap { 10.0.1.0-10.0.1.255 : accept, 10.0.1.1-10.0.2.255 : drop };fail
tests/py/inet/ip.t.payload.netdev +14 -0
@@ -12,3 +12,17 @@ netdev test-netdev ingress [ payload load 6b @ link header + 6 => reg 10 ] [ lookup reg 1 set __set%d ] +# meta protocol ip ip saddr . ip daddr . ether saddr { 1.1.1.1 . 2.2.2.2 . ca:fe:ca:fe:ca:fe } +__set%d test-netdev 3 +__set%d test-netdev 0 + element 01010101 02020202 fecafeca 0000feca : 0 [end] +netdev test-netdev egress + [ meta load protocol => reg 1 ] + [ cmp eq reg 1 0x00000008 ] + [ meta load iiftype => reg 1 ] + [ cmp eq reg 1 0x00000001 ] + [ payload load 4b @ network header + 12 => reg 1 ] + [ payload load 4b @ network header + 16 => reg 9 ] + [ payload load 6b @ link header + 6 => reg 10 ] + [ lookup reg 1 set __set%d ] +
tests/py/inet/ip_tcp.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress # must not remove ip dependency -- ONLY ipv4 packets should be matched ip protocol tcp tcp dport 22;ok;ip protocol 6 tcp dport 22
tests/py/inet/map.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress mark set ip saddr map { 10.2.3.2 : 0x0000002a, 10.2.3.1 : 0x00000017};ok;meta mark set ip saddr map { 10.2.3.1 : 0x00000017, 10.2.3.2 : 0x0000002a} mark set ip hdrlength map { 5 : 0x00000017, 4 : 0x00000001};ok;meta mark set ip hdrlength map { 4 : 0x00000001, 5 : 0x00000017}
tests/py/inet/sctp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress sctp sport 23;ok sctp sport != 23;ok
tests/py/inet/sets.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input *bridge;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress !set1 type ipv4_addr timeout 60s;ok ?set1 192.168.3.4 timeout 30s, 10.2.1.1;ok
tests/py/inet/tcp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress tcp dport set {1, 2, 3};fail
tests/py/inet/udp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress udp sport 80 accept;ok udp sport != 60 accept;ok
tests/py/inet/udplite.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress udplite sport 80 accept;ok udplite sport != 60 accept;ok
tests/py/ip/ip.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress - ip version 2;ok
tests/py/ip/ip_tcp.t +2 -0
@@ -1,7 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip;input +*netdev;test-netdev;ingress,egress # can remove ip dependency -- its redundant in ip family ip protocol tcp tcp dport 22;ok;tcp dport 22
tests/py/ip/ip_tcp.t.payload.netdev new file +93 -0
93 lines not on this page · raw message
tests/py/ip/sets.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress !w type ipv4_addr;ok !x type inet_proto;ok
tests/py/ip6/frag.t +2 -0
@@ -1,8 +1,10 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip6;test-ip6;output *inet;test-inet;output +*netdev;test-netdev;ingress,egress frag nexthdr tcp;ok;frag nexthdr 6 frag nexthdr != icmp;ok;frag nexthdr != 1
tests/py/ip6/frag.t.payload.netdev new file +2186 -0
2,186 lines not on this page · raw message
tests/py/ip6/sets.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress !w type ipv6_addr;ok !x type inet_proto;ok
tests/py/ip6/vmap.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress ip6 saddr vmap { abcd::3 : accept };ok ip6 saddr 1234:1234:1234:1234:1234:1234:1234:1234:1234;fail
tests/shell/testcases/chains/0021prio_0 +1 -0
@@ -69,6 +69,7 @@ done family=netdev echo "add table $family x" gen_chains $family ingress filter lo +gen_chains $family egress filter lo family=bridge echo "add table $family x"
tests/shell/testcases/chains/0026prio_netdev_1 +3 -1
@@ -1,7 +1,8 @@ #!/bin/bash family=netdev - hook=ingress + for hook in ingress egress + do for prioname in raw mangle dstnat security srcnat do $NFT add table $family x || exit 1
@@ -12,4 +13,5 @@ family=netdev exit 1 fi done + done exit 0
tests/shell/testcases/chains/dumps/0021prio_0.nft +20 -0
@@ -1382,6 +1382,26 @@ table netdev x { chain ingressfilterp11 { type filter hook ingress device "lo" priority 11; policy accept; } + + chain egressfilterm11 { + type filter hook egress device "lo" priority -11; policy accept; + } + + chain egressfilterm10 { + type filter hook egress device "lo" priority filter - 10; policy accept; + } + + chain egressfilter { + type filter hook egress device "lo" priority filter; policy accept; + } + + chain egressfilterp10 { + type filter hook egress device "lo" priority filter + 10; policy accept; + } + + chain egressfilterp11 { + type filter hook egress device "lo" priority 11; policy accept; + } } table bridge x { chain preroutingfilterm11 {
Signature · 1 line
2.30.2
Quoted 4 lines · Pablo Neira Ayuso
Hi Lukas,
This is the rebase I'm using here locally for testing, let me know if you have more pending updates on your side.
I'm using the attached two patches. The first one moves Python tests dup.t and fwd.t to the netdev directory, the second one adds nft egress support.
Phil and Florian noted back in January that the payload dumps should contain "oiftype" instead of "iiftype". That's the only remaining issue not yet addressed in the attached patches:
https://lore.kernel.org/all/[email protected]/
The difference between the patch you've posted here and the attached ones are primarily more extensive docs. Also, the following two issues are not present in my version:
Review
Quoted 2 lines
(quoted diff) +2
-0+All packets leaving the system are processed by this hook. It is invoked after +layer 3 protocol handlers and after *tc* egress. It can be used for late
^^^^^ before
tests/py/inet/ah.t line 3
Quoted 6 lines
tests/py/inet/ah.t +1
-0@@ -1,10 +1,12 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook ingress device lo priority 0
^^^^^^^ egress
Thanks,
Lukas
From 22d11d9956b54e151b716ad76b39ae9bb3fa3ebc Mon Sep 17 00:00:00 2001
From: Lukas Wunner <[email protected]>
Date: Sun, 24 Oct 2021 09:37:35 +0200
Subject: [PATCH 1/2] tests: py: Move netdev-specific tests to appropriate
subdirectory
The fwd and dup statements are specific to netdev hooks, so move their tests to the appropriate subdirectory.
--- tests/py/any/dup.t | 7 ------ tests/py/any/dup.t.json | 30 ------------------------- tests/py/any/dup.t.payload | 14 ------------ tests/py/any/fwd.t | 8 ------- tests/py/any/fwd.t.json | 47 --------------------------------------- tests/py/any/fwd.t.json.output | 27 ---------------------- tests/py/any/fwd.t.payload | 20 ----------------- tests/py/netdev/dup.t | 7 ++++++ tests/py/netdev/dup.t.json | 30 +++++++++++++++++++++++++ tests/py/netdev/dup.t.payload | 14 ++++++++++++ tests/py/netdev/fwd.t | 8 +++++++ tests/py/netdev/fwd.t.json | 47 +++++++++++++++++++++++++++++++++++++++ tests/py/netdev/fwd.t.json.output | 27 ++++++++++++++++++++++ tests/py/netdev/fwd.t.payload | 20 +++++++++++++++++ 14 files changed, 153 insertions(+), 153 deletions(-) delete mode 100644 tests/py/any/dup.t delete mode 100644 tests/py/any/dup.t.json delete mode 100644 tests/py/any/dup.t.payload delete mode 100644 tests/py/any/fwd.t delete mode 100644 tests/py/any/fwd.t.json delete mode 100644 tests/py/any/fwd.t.json.output delete mode 100644 tests/py/any/fwd.t.payload create mode 100644 tests/py/netdev/dup.t create mode 100644 tests/py/netdev/dup.t.json create mode 100644 tests/py/netdev/dup.t.payload create mode 100644 tests/py/netdev/fwd.t create mode 100644 tests/py/netdev/fwd.t.json create mode 100644 tests/py/netdev/fwd.t.json.output create mode 100644 tests/py/netdev/fwd.t.payload
tests/py/any/dup.t deleted +0 -7
@@ -1,7 +0,0 @@ -:ingress;type filter hook ingress device lo priority 0 - -*netdev;test-netdev;ingress - -dup to "lo";ok -dup to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"};ok -
tests/py/any/dup.t.json deleted +0 -30
@@ -1,30 +0,0 @@ -# dup to "lo" -[ - { - "dup": { - "addr": "lo" - } - } -] - -# dup to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} -[ - { - "dup": { - "addr": { - "map": { - "key": { - "meta": { "key": "mark" } - }, - "data": { - "set": [ - [ 1, "lo" ], - [ 2, "lo" ] - ] - } - } - } - } - } -] -
tests/py/any/dup.t.payload deleted +0 -14
@@ -1,14 +0,0 @@ -# dup to "lo" -netdev test-netdev ingress - [ immediate reg 1 0x00000001 ] - [ dup sreg_dev 1 ] - -# dup to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} -__map%d test-netdev b -__map%d test-netdev 0 - element 00000001 : 00000001 0 [end] element 00000002 : 00000001 0 [end] -netdev test-netdev ingress - [ meta load mark => reg 1 ] - [ lookup reg 1 set __map%d dreg 1 ] - [ dup sreg_dev 1 ] -
tests/py/any/fwd.t deleted +0 -8
@@ -1,8 +0,0 @@ -:ingress;type filter hook ingress device lo priority 0 - -*netdev;test-netdev;ingress - -fwd to "lo";ok -fwd to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"};ok - -fwd ip to 192.168.2.200 device "lo";ok
tests/py/any/fwd.t.json deleted +0 -47
47 lines not on this page · raw message
tests/py/any/fwd.t.json.output deleted +0 -27
@@ -1,27 +0,0 @@ -# fwd to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} -[ - { - "fwd": { - "dev": { - "map": { - "key": { - "meta": { "key": "mark" } - }, - "data": { - "set": [ - [ - 1, - "lo" - ], - [ - 2, - "lo" - ] - ] - } - } - } - } - } -] -
tests/py/any/fwd.t.payload deleted +0 -20
@@ -1,20 +0,0 @@ -# fwd to "lo" -netdev test-netdev ingress - [ immediate reg 1 0x00000001 ] - [ fwd sreg_dev 1 ] - -# fwd to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} -__map%d test-netdev b -__map%d test-netdev 0 - element 00000001 : 00000001 0 [end] element 00000002 : 00000001 0 [end] -netdev test-netdev ingress - [ meta load mark => reg 1 ] - [ lookup reg 1 set __map%d dreg 1 ] - [ fwd sreg_dev 1 ] - -# fwd ip to 192.168.2.200 device "lo" -netdev test-netdev ingress - [ immediate reg 1 0x00000001 ] - [ immediate reg 2 0xc802a8c0 ] - [ fwd sreg_dev 1 sreg_addr 2 nfproto 2 ] -
tests/py/netdev/dup.t new file +7 -0
@@ -0,0 +1,7 @@ +:ingress;type filter hook ingress device lo priority 0 + +*netdev;test-netdev;ingress + +dup to "lo";ok +dup to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"};ok +
tests/py/netdev/dup.t.json new file +30 -0
@@ -0,0 +1,30 @@ +# dup to "lo" +[ + { + "dup": { + "addr": "lo" + } + } +] + +# dup to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} +[ + { + "dup": { + "addr": { + "map": { + "key": { + "meta": { "key": "mark" } + }, + "data": { + "set": [ + [ 1, "lo" ], + [ 2, "lo" ] + ] + } + } + } + } + } +] +
tests/py/netdev/dup.t.payload new file +14 -0
@@ -0,0 +1,14 @@ +# dup to "lo" +netdev test-netdev ingress + [ immediate reg 1 0x00000001 ] + [ dup sreg_dev 1 ] + +# dup to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} +__map%d test-netdev b +__map%d test-netdev 0 + element 00000001 : 00000001 0 [end] element 00000002 : 00000001 0 [end] +netdev test-netdev ingress + [ meta load mark => reg 1 ] + [ lookup reg 1 set __map%d dreg 1 ] + [ dup sreg_dev 1 ] +
tests/py/netdev/fwd.t new file +8 -0
@@ -0,0 +1,8 @@ +:ingress;type filter hook ingress device lo priority 0 + +*netdev;test-netdev;ingress + +fwd to "lo";ok +fwd to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"};ok + +fwd ip to 192.168.2.200 device "lo";ok
tests/py/netdev/fwd.t.json new file +47 -0
47 lines not on this page · raw message
tests/py/netdev/fwd.t.json.output new file +27 -0
@@ -0,0 +1,27 @@ +# fwd to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} +[ + { + "fwd": { + "dev": { + "map": { + "key": { + "meta": { "key": "mark" } + }, + "data": { + "set": [ + [ + 1, + "lo" + ], + [ + 2, + "lo" + ] + ] + } + } + } + } + } +] +
tests/py/netdev/fwd.t.payload new file +20 -0
@@ -0,0 +1,20 @@ +# fwd to "lo" +netdev test-netdev ingress + [ immediate reg 1 0x00000001 ] + [ fwd sreg_dev 1 ] + +# fwd to meta mark map { 0x00000001 : "lo", 0x00000002 : "lo"} +__map%d test-netdev b +__map%d test-netdev 0 + element 00000001 : 00000001 0 [end] element 00000002 : 00000001 0 [end] +netdev test-netdev ingress + [ meta load mark => reg 1 ] + [ lookup reg 1 set __map%d dreg 1 ] + [ fwd sreg_dev 1 ] + +# fwd ip to 192.168.2.200 device "lo" +netdev test-netdev ingress + [ immediate reg 1 0x00000001 ] + [ immediate reg 2 0xc802a8c0 ] + [ fwd sreg_dev 1 sreg_addr 2 nfproto 2 ] +
Signature · 1 line
2.31.1
From 1c61def0bfcdb2cda9301e6c93e5272aa6a0a91f Mon Sep 17 00:00:00 2001
From: Lukas Wunner <[email protected]>
Date: Wed, 11 Mar 2020 13:20:06 +0100
Subject: [PATCH 2/2] src: Support netdev egress hook
Add userspace support for the netdev egress hook which is queued up for v5.16-rc1, complete with documentation and tests. Usage is identical to the ingress hook.
--- doc/nft.txt | 34 +- doc/statements.txt | 6 +- include/linux/netfilter.h | 1 + src/evaluate.c | 2 + src/rule.c | 3 + tests/py/any/icmpX.t.netdev | 3 +- tests/py/any/limit.t | 3 +- tests/py/any/meta.t | 3 +- tests/py/any/objects.t | 3 +- tests/py/any/quota.t | 3 +- tests/py/any/rawpayload.t | 3 +- tests/py/arp/arp.t | 3 +- tests/py/bridge/vlan.t | 3 +- tests/py/inet/ah.t | 3 +- tests/py/inet/comp.t | 3 +- tests/py/inet/dccp.t | 3 +- tests/py/inet/esp.t | 3 +- tests/py/inet/ether-ip.t | 3 +- tests/py/inet/ether.t | 3 +- tests/py/inet/ip.t | 3 +- tests/py/inet/ip.t.payload.netdev | 14 + tests/py/inet/ip_tcp.t | 3 +- tests/py/inet/map.t | 3 +- tests/py/inet/sctp.t | 3 +- tests/py/inet/sets.t | 3 +- tests/py/inet/tcp.t | 3 +- tests/py/inet/udp.t | 3 +- tests/py/inet/udplite.t | 3 +- tests/py/ip/ip.t | 3 +- tests/py/ip/ip_tcp.t | 2 + tests/py/ip/ip_tcp.t.payload.netdev | 93 + tests/py/ip/sets.t | 3 +- tests/py/ip6/frag.t | 2 + tests/py/ip6/frag.t.payload.netdev | 2186 +++++++++++++++++++++ tests/py/ip6/sets.t | 3 +- tests/py/ip6/vmap.t | 3 +- tests/py/netdev/dup.t | 3 +- tests/py/netdev/fwd.t | 3 +- tests/shell/testcases/chains/0021prio_0 | 1 + tests/shell/testcases/chains/0026prio_netdev_1 | 4 +- tests/shell/testcases/chains/dumps/0021prio_0.nft | 20 + 41 files changed, 2413 insertions(+), 39 deletions(-) create mode 100644 tests/py/ip/ip_tcp.t.payload.netdev create mode 100644 tests/py/ip6/frag.t.payload.netdev
doc/nft.txt +27 -7
@@ -193,7 +193,7 @@ packet processing paths, which invoke nftables if rules for these hooks exist. *inet*:: Internet (IPv4/IPv6) address family. *arp*:: ARP address family, handling IPv4 ARP packets. *bridge*:: Bridge address family, handling packets which traverse a bridge device. -*netdev*:: Netdev address family, handling packets from ingress. +*netdev*:: Netdev address family, handling packets on ingress and egress. All nftables objects exist in address family specific namespaces, therefore all identifiers include an address family. If an identifier is specified without an
@@ -251,9 +251,9 @@ The list of supported hooks is identical to IPv4/IPv6/Inet address families abov NETDEV ADDRESS FAMILY ~~~~~~~~~~~~~~~~~~~~ -The Netdev address family handles packets from the device ingress path. This -family allows you to filter packets of any ethertype such as ARP, VLAN 802.1q, -VLAN 802.1ad (Q-in-Q) as well as IPv4 and IPv6 packets. +The Netdev address family handles packets from the device ingress and egress +path. This family allows you to filter packets of any ethertype such as ARP, +VLAN 802.1q, VLAN 802.1ad (Q-in-Q) as well as IPv4 and IPv6 packets. .Netdev address family hooks [options="header"]
@@ -263,8 +263,27 @@ VLAN 802.1ad (Q-in-Q) as well as IPv4 and IPv6 packets. All packets entering the system are processed by this hook. It is invoked after the network taps (ie. *tcpdump*), right after *tc* ingress and before layer 3 protocol handlers, it can be used for early filtering and policing. +|egress | +All packets leaving the system are processed by this hook. It is invoked after +layer 3 protocol handlers and before *tc* egress. It can be used for late +filtering and policing. |================= +Tunneled packets (such as *vxlan*) are processed by netdev family hooks both +in decapsulated and encapsulated (tunneled) form. So a packet can be filtered +on the overlay network as well as on the underlying network. + +Note that the order of netfilter and *tc* is mirrored on ingress versus egress. +This ensures symmetry for NAT and other packet mangling. + +Ingress packets which are redirected out some other interface are only +processed by netfilter on egress if they have passed through netfilter ingress +processing before. Thus, ingress packets which are redirected by *tc* are not +subjected to netfilter. But they are if they are redirected by *netfilter* on +ingress. Conceptually, tc and netfilter can be thought of as layers, with +netfilter layered above tc: If the packet hasn't been passed up from the +tc layer to the netfilter layer, it's not subjected to netfilter on egress. + RULESET ------- [verse]
@@ -388,9 +407,10 @@ Apart from the special cases illustrated above (e.g. *nat* type not supporting *forward* hook or *route* type only supporting *output* hook), there are three further quirks worth noticing: -* The netdev family supports merely a single combination, namely *filter* type and - *ingress* hook. Base chains in this family also require the *device* parameter - to be present since they exist per incoming interface only. +* The netdev family supports merely two combinations, namely *filter* type with + *ingress* hook and *filter* type with *egress* hook. Base chains in this + family also require the *device* parameter to be present since they exist per + interface only. * The arp family supports only the *input* and *output* hooks, both in chains of type *filter*. * The inet family also supports the *ingress* hook (since Linux kernel 5.10),
doc/statements.txt +3 -3
@@ -657,7 +657,7 @@ string ip filter forward dup to 10.2.3.4 device "eth0" # copy raw frame to another interface -netdetv ingress dup to "eth0" +netdev ingress dup to "eth0" dup to "eth0" # combine with map dst addr to gateways
@@ -667,8 +667,8 @@ dup to ip daddr map { 192.168.7.1 : "eth0", 192.168.7.2 : "eth1" } FWD STATEMENT ~~~~~~~~~~~~~ The fwd statement is used to redirect a raw packet to another interface. It is -only available in the netdev family ingress hook. It is similar to the dup -statement except that no copy is made. +only available in the netdev family ingress and egress hooks. It is similar to +the dup statement except that no copy is made. *fwd to* 'device'
include/linux/netfilter.h +1 -0
@@ -54,6 +54,7 @@ enum nf_inet_hooks {enum nf_dev_hooks {NF_NETDEV_INGRESS , +NF_NETDEV_EGRESS ,NF_NETDEV_NUMHOOKS };
src/evaluate.c +2 -0
@@ -4296,6 +4296,8 @@ static uint32_t str2hooknum(uint32_t family, const char *hook)case NFPROTO_NETDEV :if (!strcmp (hook,"ingress" ))return NF_NETDEV_INGRESS ; +else if (!strcmp (hook,"egress" )) +return NF_NETDEV_EGRESS ;break ;default :break ;
src/rule.c +3 -0
@@ -675,6 +675,7 @@ static const char * const chain_hookname_str_array[] = {"postrouting" ,"output" ,"ingress" , +"egress" , NULL, };
@@ -832,6 +833,8 @@ const char *hooknum2str(unsigned int family, unsigned int hooknum)switch (hooknum) {case NF_NETDEV_INGRESS :return "ingress" ; +case NF_NETDEV_EGRESS : +return "egress" ; }break ;default :
tests/py/any/icmpX.t.netdev +2 -1
@@ -1,6 +1,7 @@ :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress ip protocol icmp icmp type echo-request;ok;icmp type echo-request icmp type echo-request;ok
tests/py/any/limit.t +2 -1
@@ -1,12 +1,13 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;output *ip6;test-ip6;output *inet;test-inet;output *arp;test-arp;output *bridge;test-bridge;output -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress limit rate 400/minute;ok limit rate 20/second;ok
tests/py/any/meta.t +2 -1
@@ -1,12 +1,13 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input *arp;test-arp;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress meta length 1000;ok meta length 22;ok
tests/py/any/objects.t +2 -1
@@ -1,12 +1,13 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;output *ip6;test-ip6;output *inet;test-inet;output *arp;test-arp;output *bridge;test-bridge;output -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress %cnt1 type counter;ok %qt1 type quota 25 mbytes;ok
tests/py/any/quota.t +2 -1
@@ -1,12 +1,13 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;output *ip6;test-ip6;output *inet;test-inet;output *arp;test-arp;output *bridge;test-bridge;output -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress quota 1025 bytes;ok quota 1 kbytes;ok
tests/py/any/rawpayload.t +2 -1
@@ -1,8 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress meta l4proto { tcp, udp, sctp} @th,16,16 { 22, 23, 80 };ok;meta l4proto { 6, 17, 132} th dport { 22, 23, 80} meta l4proto tcp @th,16,16 { 22, 23, 80};ok;tcp dport { 22, 23, 80}
tests/py/arp/arp.t +2 -1
@@ -1,9 +1,10 @@ # filter chains available are: input, output, forward :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *arp;test-arp;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress arp htype 1;ok arp htype != 1;ok
tests/py/bridge/vlan.t +2 -1
@@ -1,8 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress vlan id 4094;ok vlan id 0;ok
tests/py/inet/ah.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress - ah nexthdr esp;ok - ah nexthdr ah;ok
tests/py/inet/comp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress # BUG: nft: payload.c:88: payload_expr_pctx_update: Assertion `left->payload.base + 1 <= (__PROTO_BASE_MAX - 1)' failed. - comp nexthdr esp;ok;comp nexthdr 50
tests/py/inet/dccp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress dccp sport 21-35;ok dccp sport != 21-35;ok
tests/py/inet/esp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress esp spi 100;ok esp spi != 100;ok
tests/py/inet/ether-ip.t +2 -1
@@ -1,8 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress tcp dport 22 iiftype ether ip daddr 1.2.3.4 ether saddr 00:0f:54:0c:11:4 accept;ok;tcp dport 22 ether saddr 00:0f:54:0c:11:04 ip daddr 1.2.3.4 accept tcp dport 22 ip daddr 1.2.3.4 ether saddr 00:0f:54:0c:11:04;ok
tests/py/inet/ether.t +2 -1
@@ -1,11 +1,12 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress tcp dport 22 iiftype ether ether saddr 00:0f:54:0c:11:4 accept;ok;tcp dport 22 ether saddr 00:0f:54:0c:11:04 accept tcp dport 22 ether saddr 00:0f:54:0c:11:04 accept;ok
tests/py/inet/ip.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress ip saddr . ip daddr . ether saddr { 1.1.1.1 . 2.2.2.2 . ca:fe:ca:fe:ca:fe };ok ip saddr vmap { 10.0.1.0-10.0.1.255 : accept, 10.0.1.1-10.0.2.255 : drop };fail
tests/py/inet/ip.t.payload.netdev +14 -0
@@ -12,3 +12,17 @@ netdev test-netdev ingress [ payload load 6b @ link header + 6 => reg 10 ] [ lookup reg 1 set __set%d ] +# meta protocol ip ip saddr . ip daddr . ether saddr { 1.1.1.1 . 2.2.2.2 . ca:fe:ca:fe:ca:fe } +__set%d test-netdev 3 +__set%d test-netdev 0 + element 01010101 02020202 fecafeca 0000feca : 0 [end] +netdev test-netdev egress + [ meta load protocol => reg 1 ] + [ cmp eq reg 1 0x00000008 ] + [ meta load iiftype => reg 1 ] + [ cmp eq reg 1 0x00000001 ] + [ payload load 4b @ network header + 12 => reg 1 ] + [ payload load 4b @ network header + 16 => reg 9 ] + [ payload load 6b @ link header + 6 => reg 10 ] + [ lookup reg 1 set __set%d ] +
tests/py/inet/ip_tcp.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress # must not remove ip dependency -- ONLY ipv4 packets should be matched ip protocol tcp tcp dport 22;ok;ip protocol 6 tcp dport 22
tests/py/inet/map.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress mark set ip saddr map { 10.2.3.2 : 0x0000002a, 10.2.3.1 : 0x00000017};ok;meta mark set ip saddr map { 10.2.3.1 : 0x00000017, 10.2.3.2 : 0x0000002a} mark set ip hdrlength map { 5 : 0x00000017, 4 : 0x00000001};ok;meta mark set ip hdrlength map { 4 : 0x00000001, 5 : 0x00000017}
tests/py/inet/sctp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress sctp sport 23;ok sctp sport != 23;ok
tests/py/inet/sets.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *inet;test-inet;input *bridge;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress !set1 type ipv4_addr timeout 60s;ok ?set1 192.168.3.4 timeout 30s, 10.2.1.1;ok
tests/py/inet/tcp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress tcp dport set {1, 2, 3};fail
tests/py/inet/udp.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress udp sport 80 accept;ok udp sport != 60 accept;ok
tests/py/inet/udplite.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *ip6;test-ip6;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress udplite sport 80 accept;ok udplite sport != 60 accept;ok
tests/py/ip/ip.t +2 -1
@@ -1,10 +1,11 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input *bridge;test-bridge;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress - ip version 2;ok
tests/py/ip/ip_tcp.t +2 -0
@@ -1,7 +1,9 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip;input +*netdev;test-netdev;ingress,egress # can remove ip dependency -- its redundant in ip family ip protocol tcp tcp dport 22;ok;tcp dport 22
tests/py/ip/ip_tcp.t.payload.netdev new file +93 -0
93 lines not on this page · raw message
tests/py/ip/sets.t +2 -1
@@ -1,9 +1,10 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip;test-ip4;input *inet;test-inet;input -*netdev;test-netdev;ingress +*netdev;test-netdev;ingress,egress !w type ipv4_addr;ok !x type inet_proto;ok
tests/py/ip6/frag.t +2 -0
@@ -1,8 +1,10 @@ :output;type filter hook output priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook egress device lo priority 0 *ip6;test-ip6;output *inet;test-inet;output +*netdev;test-netdev;ingress,egress frag nexthdr tcp;ok;frag nexthdr 6 frag nexthdr != icmp;ok;frag nexthdr != 1
tests/py/ip6/frag.t.payload.netdev new file +2186 -0
2,170 lines not on this page · raw message
tests/shell/testcases/chains/0021prio_0 +1 -0
Lines of this file are not shown. View the raw message.
tests/shell/testcases/chains/0026prio_netdev_1 +3 -1
Lines of this file are not shown. View the raw message.
tests/shell/testcases/chains/dumps/0021prio_0.nft +20 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.31.1
Part of the diff is not shown here. View the raw message.
Pablo Neira Ayuso
maintainerQuoted 10 lines · Lukas Wunner
Quoted 4 lines · Pablo Neira Ayuso
Hi Lukas,
This is the rebase I'm using here locally for testing, let me know if you have more pending updates on your side.
I'm using the attached two patches. The first one moves Python tests dup.t and fwd.t to the netdev directory, the second one adds nft egress support.
Quoted 5 lines
Phil and Florian noted back in January that the payload dumps should contain "oiftype" instead of "iiftype". That's the only remaining issue not yet addressed in the attached patches:
See:
https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/
to generalize the iftype.
I still have to post a patch to update libnftnl, then update all dumps to refer to iftype instead of iiftype.
Quoted 10 lines
The difference between the patch you've posted here and the attached ones are primarily more extensive docs. Also, the following two issues are not present in my version:
Review
Quoted 2 lines
(quoted diff) +2
-0+All packets leaving the system are processed by this hook. It is invoked after +layer 3 protocol handlers and after *tc* egress. It can be used for late^^^^^ before
Quoted 8 lines
tests/py/inet/ah.t line 3
Quoted 6 lines
tests/py/inet/ah.t +1
-0@@ -1,10 +1,12 @@ :input;type filter hook input priority 0 :ingress;type filter hook ingress device lo priority 0 +:egress;type filter hook ingress device lo priority 0^^^^^^^ egress
I'll apply these two patches if you are fine with their state.
I'd just would like to have this in the tree for easier testing, I have to switch over several local branches here, one less makes it slightly easier for me. And to include this in the next release.
Thanks.
Quoted 1 line · Pablo Neira Ayuso
I'll apply these two patches if you are fine with their state.
I'm fine with them. Do you want me to resend them as patches (instead of as attachments)?
When running tests I noted an oddity:
tests/shell/testcases/0031set_timeout_size_0 fails because 1d2h3m4s10ms is reported as 1d2h3m4s8ms, so 2 msec less. Might be caused by the kernel I tested against (v5.13.12), doesn't seem related to my patches, but odd nevertheless.
Thanks,
Lukas
Pablo Neira Ayuso
maintainerQuoted 5 lines · Lukas Wunner
Quoted 1 line · Pablo Neira Ayuso
I'll apply these two patches if you are fine with their state.
I'm fine with them. Do you want me to resend them as patches (instead of as attachments)?
No need to.
Quoted 6 lines
When running tests I noted an oddity:
tests/shell/testcases/0031set_timeout_size_0 fails because 1d2h3m4s10ms is reported as 1d2h3m4s8ms, so 2 msec less. Might be caused by the kernel I tested against (v5.13.12), doesn't seem related to my patches, but odd nevertheless.
Likely related to:
commit c9c5b5f621c37d17140dac682d211825ef321093
Author: Phil Sutter <[email protected]> Date: Mon Jul 26 15:27:32 2021 +0200
tests: shell: Fix bogus testsuite failure with 100Hz
[+cc Phil]
Quoted 8 lines · Pablo Neira Ayuso
Quoted 6 lines · Lukas Wunner
When running tests I noted an oddity:
tests/shell/testcases/0031set_timeout_size_0 fails because 1d2h3m4s10ms is reported as 1d2h3m4s8ms, so 2 msec less. Might be caused by the kernel I tested against (v5.13.12), doesn't seem related to my patches, but odd nevertheless.
Quoted 7 lines
Likely related to:
commit
c9c5b5f621c37d17140dac682d211825ef321093Author: Phil Sutter <[email protected]> Date: Mon Jul 26 15:27:32 2021 +0200tests: shell: Fix bogus testsuite failure with 100Hz
Debian uses CONFIG_HZ_250=y in their x86_64 default config, that's what I'm using. I guess changing the regex to match (8|10)ms would fix the issue.
Thanks,
Lukas
Pablo Neira Ayuso
maintainerQuoted 7 lines · Lukas Wunner
Quoted 4 lines · Pablo Neira Ayuso
Hi Lukas,
This is the rebase I'm using here locally for testing, let me know if you have more pending updates on your side.
I'm using the attached two patches.
Both patches are applied, thanks.