netfilter: nft_fib: ignore icmpv6 packets from ::
Subsystems (3)
Florian Westphal
maintainercover netfilter: nft_fib: ignore icmpv6 packets from ::
Quoting nf bugzilla:
--------
Using the following for
reverse path filtering breaks IPv6 duplicate address detection:
table inet ip46_firewall {
chain ip46_rpfilter {
type filter hook prerouting priority raw;
fib saddr . iif oif missing log prefix "RPFILTER: " drop
}
}This is because packets from :: to ff02::1:ff00/104 will be dropped and thus other hosts on the network cannot detect that this host already has the same address assigned. The problem can be worked around in nft rules by handling such packets specially but I guess it should work as is.
In the kernel in ip6t_rpfilter.c the function rpfilter_mt() checks for saddrtype == IPV6_ADDR_ANY. nft_fib_ipv6.c doesn't seem to have an equivalent check for this special case.
--------
First patch adds a test case for this, second patch makes icmpv6 from any to link-local bypass the fib lookup, just like loopback packets.
Florian Westphal (2):
selftests: netfilter: add fib test case
netfilter: ipv6: skip ipv6 packets from any to link-local
net/ipv6/netfilter/nft_fib_ipv6.c | 22 +- tools/testing/selftests/netfilter/Makefile | 2 +- tools/testing/selftests/netfilter/nft_fib.sh | 221 +++++++++++++++++++ 3 files changed, 240 insertions(+), 5 deletions(-) create mode 100755 tools/testing/selftests/netfilter/nft_fib.sh
Signature · 1 line
2.31.1
Florian Westphal
maintainerPATCH 1/2 selftests: netfilter: add fib test case
There is a bug report on netfilter.org bugzilla pointing to fib expression dropping ipv6 DAD packets.
Add a test case that demonstrates this problem.
Next patch excludes icmpv6 packets coming from any to linklocal.
--- tools/testing/selftests/netfilter/Makefile | 2 +- tools/testing/selftests/netfilter/nft_fib.sh | 221 +++++++++++++++++++ 2 files changed, 222 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/netfilter/nft_fib.sh
tools/testing/selftests/netfilter/Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for netfilter selftests -TEST_PROGS := nft_trans_stress.sh nft_nat.sh bridge_brouter.sh \ +TEST_PROGS := nft_trans_stress.sh nft_fib.sh nft_nat.sh bridge_brouter.sh \ conntrack_icmp_related.sh nft_flowtable.sh ipvs.sh \ nft_concat_range.sh nft_conntrack_helper.sh \ nft_queue.sh nft_meta.sh nf_nat_edemux.sh \
tools/testing/selftests/netfilter/nft_fib.sh new file +221 -0
221 lines not on this page · raw message
Signature · 1 line
2.31.1
Florian Westphal
maintainerPATCH 2/2 netfilter: ipv6: skip ipv6 packets from any to link-local
In reply to Florian WestphalThe ip6tables rpfilter match has an extra check to skip packets with "::" source address.
Extend this to ipv6 fib expression. Else ipv6 duplicate address detection packets will fail rpf route check -- lookup returns -ENETUNREACH.
While at it, extend the prerouting check to also cover the ingress hook.
--- net/ipv6/netfilter/nft_fib_ipv6.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
net/ipv6/netfilter/nft_fib_ipv6.c +18 -4
@@ -135,6 +135,17 @@ void nft_fib6_eval_type(const struct nft_expr *expr, struct nft_regs *regs, }EXPORT_SYMBOL_GPL (nft_fib6_eval_type); +static bool nft_fib_v6_skip_icmpv6 (const struct sk_buff *skb,u8 next,const struct ipv6hdr *iph) +{ +if (likely (next !=IPPROTO_ICMPV6 )) +return false; + +if (ipv6_addr_type (&iph->saddr) !=IPV6_ADDR_ANY ) +return false; + +return ipv6_addr_type (&iph->daddr) &IPV6_ADDR_LINKLOCAL ; +} +void nft_fib6_eval (const struct nft_expr *expr,struct nft_regs *regs,const struct nft_pktinfo *pkt) {
@@ -163,10 +174,13 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, lookup_flags =nft_fib6_flowi_init (&fl6, priv, pkt, oif, iph); -if (nft_hook (pkt) ==NF_INET_PRE_ROUTING && -nft_fib_is_loopback (pkt->skb,nft_in (pkt))) { -nft_fib_store_result (dest, priv,nft_in (pkt)); -return ; +if (nft_hook (pkt) ==NF_INET_PRE_ROUTING || +nft_hook (pkt) ==NF_INET_INGRESS ) { +if (nft_fib_is_loopback (pkt->skb,nft_in (pkt)) || +nft_fib_v6_skip_icmpv6 (pkt->skb, pkt->tprot, iph)) { +nft_fib_store_result (dest, priv,nft_in (pkt)); +return ; + } } *dest =0 ;
Signature · 1 line
2.31.1
Quoted 17 lines · Florian Westphal
Quoting nf bugzilla:
--------
Using the following for
reverse path filtering breaks IPv6 duplicate address detection:table inet ip46_firewall { chain ip46_rpfilter { type filter hook prerouting priority raw; fib saddr . iif oif missing log prefix "RPFILTER: " drop } }This is because packets from :: to ff02::1:ff00/104 will be dropped and thus other hosts on the network cannot detect that this host already has the same address assigned. The problem can be worked around in nft rules by handling such packets specially but I guess it should work as is.
Quoted 7 lines
In the kernel in
ip6t_rpfilter.cthe functionrpfilter_mt()checks for saddrtype ==IPV6_ADDR_ANY.nft_fib_ipv6.cdoesn't seem to have an equivalent check for this special case.
--------First patch adds a test case for this, second patch makes icmpv6 from any to link-local bypass the fib lookup, just like loopback packets.
Applied, thanks.