netfilter: bridge: forward IPv6 fragmented packets
Subsystems (3)
PATCH v7 4/4 netfilter: bridge: forward IPv6 fragmented packets
IPv6 fragmented packets are not forwarded on an ethernet bridge with netfilter ip6_tables loaded. e.g. steps to reproduce
1) create a simple bridge like this
modprobe br_netfilter
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth2
ifconfig eth0 up
ifconfig eth2 up
ifconfig br0 up
2) place a host with an IPv6 address on each side of the bridge
set IPv6 address on host A:
ip -6 addr add fd01:2345:6789:1::1/64 dev eth0
set IPv6 address on host B:
ip -6 addr add fd01:2345:6789:1::2/64 dev eth0
3) run a simple ping command on host A with packets > MTU
ping6 -s 4000 fd01:2345:6789:1::2
4) wait some time and run e.g. "ip6tables -t nat -nvL" on the bridge
IPv6 fragmented packets traverse the bridge cleanly until somebody runs. "ip6tables -t nat -nvL". As soon as it is run (and netfilter modules are loaded) IPv6 fragmented packets do not traverse the bridge any more (you see no more responses in ping's output).
After applying this patch IPv6 fragmented packets traverse the bridge cleanly in above scenario.
---
Patch revision history:
v7
* split into several patches
* re-order patches in patch series
* remove unneeded comment
v6
* rebase to current davem/net-next
* include netfilter in subject line
v5
* rebase to davem's current net-next
* remove EXPORT_SYMBOL() for ip6_fragment()
* simplify conditionals within br_nf_dev_queue_xmit()
v4
* added ip6_fragment() to nf_ipv6_ops to call it indirectly from br_nf_dev_queue_xmit() when needed as suggested by Florian Westphal
v3
* changes in net/bridge/br_netfilter.c to combine checks on IPv6 header already performed in br_nf_pre_routing_finish_ipv6() with newly created br_parse_ip6_options()
* rename br_parse_ip6_options() to br_validate_ipv6()
* br_validate_ipv6() still performed in br_nf_pre_routing_finish_ipv6() and br_nf_dev_queue_xmit() to make sure even locally generated packets with SOCK_RAW are checked
* all changes based on suggestions by Florian Westphal on PATCHv2
v2
* removed changes to IP6_INC_STATS() calls in net/ipv6/ip6_output.c
* changed net/bridge/br_private.h to use union for fake_rtable and fake_rt6_info as suggested by Pablo Neira Ayuso
include/linux/netfilter_ipv6.h | 2 + net/bridge/br_netfilter.c | 139 ++++++++++++++++++++++++++++------------ net/bridge/br_private.h | 6 +- net/ipv6/netfilter.c | 3 +- 4 files changed, 108 insertions(+), 42 deletions(-)
include/linux/netfilter_ipv6.h +2 -0
@@ -26,6 +26,8 @@ struct nf_ipv6_ops {int (*chk_addr)(struct net *net,const struct in6_addr *addr,const struct net_device *dev,int strict);void (*route_input)(struct sk_buff *skb); +int (*fragment)(struct sock *sk,struct sk_buff *skb, +int (*output)(struct sock *,struct sk_buff *)); };extern const struct nf_ipv6_ops __rcu *nf_ipv6_ops;
net/bridge/br_netfilter.c +99 -40
222 lines not on this page · raw message
net/bridge/br_private.h +5 -1
@@ -18,6 +18,7 @@#include <linux/netpoll.h> #include <linux/u64_stats_sync.h> #include <net/route.h> +#include <net/ip6_fib.h> #include <linux/if_vlan.h> #define BR_HASH_BITS 8
@@ -214,7 +215,10 @@ struct net_bridgespinlock_t hash_lock;struct hlist_head hash[BR_HASH_SIZE ];#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER ) -struct rtable fake_rtable; +union { +struct rtable fake_rtable; +struct rt6_info fake_rt6_info; + };bool nf_call_iptables;bool nf_call_ip6tables;bool nf_call_arptables;
net/ipv6/netfilter.c +2 -1
@@ -191,7 +191,8 @@ static __sum16 nf_ip6_checksum_partial(struct sk_buff *skb, unsigned int hook,static const struct nf_ipv6_ops ipv6ops = { .chk_addr = ipv6_chk_addr, - .route_input = ip6_route_input + .route_input = ip6_route_input, + .fragment = ip6_fragment };static const struct nf_afinfo nf_ip6_afinfo = {
Signature · 1 line
1.7.10.4
Quoted 27 lines · Bernhard Thaler
IPv6 fragmented packets are not forwarded on an ethernet bridge with netfilter
ip6_tablesloaded. e.g. steps to reproduce1) create a simple bridge like this
modprobe
br_netfilter
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth2
ifconfig eth0 up
ifconfig eth2 up
ifconfig br0 up2) place a host with an IPv6 address on each side of the bridge
set IPv6 address on host A:
ip -6 addr add fd01:2345:6789:1::1/64 dev eth0set IPv6 address on host B:
ip -6 addr add fd01:2345:6789:1::2/64 dev eth03) run a simple ping command on host A with packets > MTU
ping6 -s 4000 fd01:2345:6789:1::24) wait some time and run e.g. "ip6tables -t nat -nvL" on the bridge
Quoted 7 lines
IPv6 fragmented packets traverse the bridge cleanly until somebody runs. "ip6tables -t nat -nvL". As soon as it is run (and netfilter modules are loaded) IPv6 fragmented packets do not traverse the bridge any more (you see no more responses in ping's output).
After applying this patch IPv6 fragmented packets traverse the bridge cleanly in above scenario.
Applied, thanks Bernhard.