Skip to content

Commit d01ed32

Browse files
atenartummakynes
authored andcommitted
netfilter: br_netfilter: remove unused conditional and dead code
The SKB_DROP_REASON_IP_INADDRERRORS drop reason is never returned from any function, as such it cannot be returned from the ip_route_input call tree. The 'reason != SKB_DROP_REASON_IP_INADDRERRORS' conditional is thus always true. Looking back at history, commit 50038bf ("net: ip: make ip_route_input() return drop reasons") changed the ip_route_input returned value check in br_nf_pre_routing_finish from -EHOSTUNREACH to SKB_DROP_REASON_IP_INADDRERRORS. It turns out -EHOSTUNREACH could not be returned either from the ip_route_input call tree and this since commit 251da41 ("ipv4: Cache ip_error() routes even when not forwarding."). Not a fix as this won't change the behavior. While at it use kfree_skb_reason. Signed-off-by: Antoine Tenart <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 8d738c1 commit d01ed32

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

net/bridge/br_netfilter_hooks.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -393,38 +393,10 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
393393
reason = ip_route_input(skb, iph->daddr, iph->saddr,
394394
ip4h_dscp(iph), dev);
395395
if (reason) {
396-
struct in_device *in_dev = __in_dev_get_rcu(dev);
397-
398-
/* If err equals -EHOSTUNREACH the error is due to a
399-
* martian destination or due to the fact that
400-
* forwarding is disabled. For most martian packets,
401-
* ip_route_output_key() will fail. It won't fail for 2 types of
402-
* martian destinations: loopback destinations and destination
403-
* 0.0.0.0. In both cases the packet will be dropped because the
404-
* destination is the loopback device and not the bridge. */
405-
if (reason != SKB_DROP_REASON_IP_INADDRERRORS || !in_dev ||
406-
IN_DEV_FORWARD(in_dev))
407-
goto free_skb;
408-
409-
rt = ip_route_output(net, iph->daddr, 0,
410-
ip4h_dscp(iph), 0,
411-
RT_SCOPE_UNIVERSE);
412-
if (!IS_ERR(rt)) {
413-
/* - Bridged-and-DNAT'ed traffic doesn't
414-
* require ip_forwarding. */
415-
if (rt->dst.dev == dev) {
416-
skb_dst_drop(skb);
417-
skb_dst_set(skb, &rt->dst);
418-
goto bridged_dnat;
419-
}
420-
ip_rt_put(rt);
421-
}
422-
free_skb:
423-
kfree_skb(skb);
396+
kfree_skb_reason(skb, reason);
424397
return 0;
425398
} else {
426399
if (skb_dst(skb)->dev == dev) {
427-
bridged_dnat:
428400
skb->dev = br_indev;
429401
nf_bridge_update_protocol(skb);
430402
nf_bridge_push_encap_header(skb);

0 commit comments

Comments
 (0)