From: Florian Westphal <fw@strlen.de>
To: Fernando Fernandez Mancera <fmancera@suse.de>
Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org
Subject: Re: [PATCH nft] tests: shell: add packetpath test for meta ibrhwdr
Date: Fri, 10 Oct 2025 14:46:56 +0200 [thread overview]
Message-ID: <aOkAQFrmZzKs_2X2@strlen.de> (raw)
In-Reply-To: <20251009162439.4232-1-fmancera@suse.de>
Fernando Fernandez Mancera <fmancera@suse.de> wrote:
> The test checks that the packets are processed by the bridge device and
> not forwarded.
OK, I think it would make sense to also check that we can do something
useful with the packet.
> +
> +ip -net "$ns1" link set veth0 up
> +ip -net "$ns2" link set veth0 up
> +ip -net "$ns3" link set veth1 up
> +ip -net "$ns2" link set veth1 up
> +ip -net "$ns2" link set br0 up
> +
> +ip -net "$ns1" addr add 10.1.1.10/24 dev veth0
> +ip -net "$ns3" addr add 10.1.1.20/24 dev veth1
> +
> +ip netns exec "$ns2" $NFT -f /dev/stdin <<"EOF"
> +table bridge nat {
> + chain PREROUTING {
> + type filter hook prerouting priority 0; policy accept;
> + ether daddr de:ad:00:00:be:ef meta pkttype set host ether daddr set meta ibrhwdr
While this indeed is enough to check the bridge 'redirect to input'
maybe it would make sense to also check that we can do something useful
with it?
The bridge has no ip address, so I don't really see the point why anyone
would redirect the packet locally to begin with.
> +table bridge donotprocess {
> + chain FORWARD {
> + type filter hook forward priority 0; policy accept;
> + ip protocol icmp ether saddr da:d3:00:01:02:03 counter
> + }
> +}
> +EOF
> +
> +ip netns exec "$ns1" ping -c 1 10.1.1.20 || true
> +
> +set +e
> +
> +ip netns exec "$ns2" $NFT list table bridge process | grep 'counter packets 0'
> +if [ $? -eq 0 ]
> +then
> + exit 1
I think it would be nice to display WHERE its failing so that someone
looking at testout.log doesn't have to re-run with added "set -x" or "echo
failed at".
To give some ideas (this isn't fleshed out):
diff --git a/tests/shell/testcases/packetpath/bridge_pass_up b/tests/shell/testcases/packetpath/bridge_pass_up
--- a/tests/shell/testcases/packetpath/bridge_pass_up
+++ b/tests/shell/testcases/packetpath/bridge_pass_up
@@ -38,14 +38,18 @@ ip -net "$ns3" link set veth1 up
ip -net "$ns2" link set veth1 up
ip -net "$ns2" link set br0 up
+ip netns exec "$ns2" sysctl -q net.ipv4.ip_forward=1
+
ip -net "$ns1" addr add 10.1.1.10/24 dev veth0
ip -net "$ns3" addr add 10.1.1.20/24 dev veth1
+ip -net "$ns2" addr add 10.1.1.1/24 dev br0
ip netns exec "$ns2" $NFT -f /dev/stdin <<"EOF"
table bridge nat {
chain PREROUTING {
type filter hook prerouting priority 0; policy accept;
- ether daddr de:ad:00:00:be:ef meta pkttype set host ether daddr set meta ibrhwdr
+ ether daddr de:ad:00:00:be:ef meta pkttype set host ether daddr set meta ibrhwdr meta mark set 1
}
}
@@ -62,9 +66,19 @@ table bridge donotprocess {
ip protocol icmp ether saddr da:d3:00:01:02:03 counter
}
}
+
+table ip process {
+ chain FORWARD {
+ type filter hook forward priority 0; policy accept;
+ ip protocol icmp mark 1 counter
+ }
+
+}
EOF
ALTERNATIVELY one could check INPUT instead (no fwd sysctl)
by also doing 'ip daddr set 10.1.1.1' in bridge or ip prerouting
and then checking if the packet made it to the ip input hook.
I only ever saw 3 cases of this 'bridge hijacking' implemented
via meta ibrhwdr:
1. Push packets up to mangle them via NAT. In most cases
people did this with br_netfilter + iptables, but it would be nice
to make sure we have a working alternative to that thing.
2. Push packet to local host/application, e.g. for TPROXY intercept.
3. Push packet to local host for forwarding/policy routing.
I think that 'it arrived in ip input or forwarding'
would be good because then the above (tproxy, nat, etc. should "just work").
But if you think checking bridge input is enough, thats fine.
next prev parent reply other threads:[~2025-10-10 12:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 16:24 [PATCH nft] tests: shell: add packetpath test for meta ibrhwdr Fernando Fernandez Mancera
2025-10-09 16:32 ` Fernando Fernandez Mancera
2025-10-09 23:37 ` Florian Westphal
2025-10-10 8:59 ` Fernando Fernandez Mancera
2025-10-10 12:46 ` Florian Westphal [this message]
2025-10-13 7:48 ` Fernando Fernandez Mancera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aOkAQFrmZzKs_2X2@strlen.de \
--to=fw@strlen.de \
--cc=coreteam@netfilter.org \
--cc=fmancera@suse.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).