Skip to content

Commit aa04c6f

Browse files
Huajian Yangummakynes
authored andcommitted
netfilter: bridge: Move specific fragmented packet to slow_path instead of dropping it
The config NF_CONNTRACK_BRIDGE will change the bridge forwarding for fragmented packets. The original bridge does not know that it is a fragmented packet and forwards it directly, after NF_CONNTRACK_BRIDGE is enabled, function nf_br_ip_fragment and br_ip6_fragment will check the headroom. In original br_forward, insufficient headroom of skb may indeed exist, but there's still a way to save the skb in the device driver after dev_queue_xmit.So droping the skb will change the original bridge forwarding in some cases. Fixes: 3c171f4 ("netfilter: bridge: add connection tracking system") Signed-off-by: Huajian Yang <huajianyang@asrmicro.com> Reviewed-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 836b313 commit aa04c6f

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

net/bridge/netfilter/nf_conntrack_bridge.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ static int nf_br_ip_fragment(struct net *net, struct sock *sk,
6060
struct ip_fraglist_iter iter;
6161
struct sk_buff *frag;
6262

63-
if (first_len - hlen > mtu ||
64-
skb_headroom(skb) < ll_rs)
63+
if (first_len - hlen > mtu)
6564
goto blackhole;
6665

67-
if (skb_cloned(skb))
66+
if (skb_cloned(skb) ||
67+
skb_headroom(skb) < ll_rs)
6868
goto slow_path;
6969

7070
skb_walk_frags(skb, frag) {
71-
if (frag->len > mtu ||
72-
skb_headroom(frag) < hlen + ll_rs)
71+
if (frag->len > mtu)
7372
goto blackhole;
7473

75-
if (skb_shared(frag))
74+
if (skb_shared(frag) ||
75+
skb_headroom(frag) < hlen + ll_rs)
7676
goto slow_path;
7777
}
7878

net/ipv6/netfilter.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,20 @@ int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
164164
struct ip6_fraglist_iter iter;
165165
struct sk_buff *frag2;
166166

167-
if (first_len - hlen > mtu ||
168-
skb_headroom(skb) < (hroom + sizeof(struct frag_hdr)))
167+
if (first_len - hlen > mtu)
169168
goto blackhole;
170169

171-
if (skb_cloned(skb))
170+
if (skb_cloned(skb) ||
171+
skb_headroom(skb) < (hroom + sizeof(struct frag_hdr)))
172172
goto slow_path;
173173

174174
skb_walk_frags(skb, frag2) {
175-
if (frag2->len > mtu ||
176-
skb_headroom(frag2) < (hlen + hroom + sizeof(struct frag_hdr)))
175+
if (frag2->len > mtu)
177176
goto blackhole;
178177

179178
/* Partially cloned skb? */
180-
if (skb_shared(frag2))
179+
if (skb_shared(frag2) ||
180+
skb_headroom(frag2) < (hlen + hroom + sizeof(struct frag_hdr)))
181181
goto slow_path;
182182
}
183183

0 commit comments

Comments
 (0)