Commit deef4b52 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

bridge: Use consistent NF_DROP returns in nf_pre_routing

The nf_pre_routing functions in bridging have collected two
distinct ways of returning NF_DROP over the years, inline and
via goto.  There is no reason for preferring either one.

So this patch arbitrarily picks the inline variant and converts
the all the gotos.

Also removes a redundant comment.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c053fd96
...@@ -562,26 +562,26 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook, ...@@ -562,26 +562,26 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook,
u32 pkt_len; u32 pkt_len;
if (skb->len < sizeof(struct ipv6hdr)) if (skb->len < sizeof(struct ipv6hdr))
goto inhdr_error; return NF_DROP;
if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
goto inhdr_error; return NF_DROP;
hdr = ipv6_hdr(skb); hdr = ipv6_hdr(skb);
if (hdr->version != 6) if (hdr->version != 6)
goto inhdr_error; return NF_DROP;
pkt_len = ntohs(hdr->payload_len); pkt_len = ntohs(hdr->payload_len);
if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) { if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) {
if (pkt_len + sizeof(struct ipv6hdr) > skb->len) if (pkt_len + sizeof(struct ipv6hdr) > skb->len)
goto inhdr_error; return NF_DROP;
if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr))) if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
goto inhdr_error; return NF_DROP;
} }
if (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb)) if (hdr->nexthdr == NEXTHDR_HOP && check_hbh_len(skb))
goto inhdr_error; return NF_DROP;
nf_bridge_put(skb->nf_bridge); nf_bridge_put(skb->nf_bridge);
if (!nf_bridge_alloc(skb)) if (!nf_bridge_alloc(skb))
...@@ -594,9 +594,6 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook, ...@@ -594,9 +594,6 @@ static unsigned int br_nf_pre_routing_ipv6(unsigned int hook,
br_nf_pre_routing_finish_ipv6); br_nf_pre_routing_finish_ipv6);
return NF_STOLEN; return NF_STOLEN;
inhdr_error:
return NF_DROP;
} }
/* Direct IPv6 traffic to br_nf_pre_routing_ipv6. /* Direct IPv6 traffic to br_nf_pre_routing_ipv6.
...@@ -615,11 +612,11 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb, ...@@ -615,11 +612,11 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb,
__u32 len = nf_bridge_encap_header_len(skb); __u32 len = nf_bridge_encap_header_len(skb);
if (unlikely(!pskb_may_pull(skb, len))) if (unlikely(!pskb_may_pull(skb, len)))
goto out; return NF_DROP;
p = br_port_get_rcu(in); p = br_port_get_rcu(in);
if (p == NULL) if (p == NULL)
goto out; return NF_DROP;
br = p->br; br = p->br;
if (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) || if (skb->protocol == htons(ETH_P_IPV6) || IS_VLAN_IPV6(skb) ||
...@@ -641,8 +638,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb, ...@@ -641,8 +638,7 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb,
nf_bridge_pull_encap_header_rcsum(skb); nf_bridge_pull_encap_header_rcsum(skb);
if (br_parse_ip_options(skb)) if (br_parse_ip_options(skb))
/* Drop invalid packet */ return NF_DROP;
goto out;
nf_bridge_put(skb->nf_bridge); nf_bridge_put(skb->nf_bridge);
if (!nf_bridge_alloc(skb)) if (!nf_bridge_alloc(skb))
...@@ -656,9 +652,6 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb, ...@@ -656,9 +652,6 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff *skb,
br_nf_pre_routing_finish); br_nf_pre_routing_finish);
return NF_STOLEN; return NF_STOLEN;
out:
return NF_DROP;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment