Commit 0c5794a6 authored by stephen hemminger's avatar stephen hemminger Committed by David S. Miller

gre: remove unnecessary rcu_read_lock/unlock

The gre function pointers for receive and error handling are
always called (from gre.c) with rcu_read_lock already held.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d2083287
...@@ -557,37 +557,34 @@ static void ipgre_err(struct sk_buff *skb, u32 info) ...@@ -557,37 +557,34 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
break; break;
} }
rcu_read_lock();
t = ipgre_tunnel_lookup(skb->dev, iph->daddr, iph->saddr, t = ipgre_tunnel_lookup(skb->dev, iph->daddr, iph->saddr,
flags, key, p[1]); flags, key, p[1]);
if (t == NULL) if (t == NULL)
goto out; return;
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
ipv4_update_pmtu(skb, dev_net(skb->dev), info, ipv4_update_pmtu(skb, dev_net(skb->dev), info,
t->parms.link, 0, IPPROTO_GRE, 0); t->parms.link, 0, IPPROTO_GRE, 0);
goto out; return;
} }
if (type == ICMP_REDIRECT) { if (type == ICMP_REDIRECT) {
ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0, ipv4_redirect(skb, dev_net(skb->dev), t->parms.link, 0,
IPPROTO_GRE, 0); IPPROTO_GRE, 0);
goto out; return;
} }
if (t->parms.iph.daddr == 0 || if (t->parms.iph.daddr == 0 ||
ipv4_is_multicast(t->parms.iph.daddr)) ipv4_is_multicast(t->parms.iph.daddr))
goto out; return;
if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED) if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
goto out; return;
if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO)) if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO))
t->err_count++; t->err_count++;
else else
t->err_count = 1; t->err_count = 1;
t->err_time = jiffies; t->err_time = jiffies;
out:
rcu_read_unlock();
} }
static inline void ipgre_ecn_decapsulate(const struct iphdr *iph, struct sk_buff *skb) static inline void ipgre_ecn_decapsulate(const struct iphdr *iph, struct sk_buff *skb)
...@@ -625,7 +622,7 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -625,7 +622,7 @@ static int ipgre_rcv(struct sk_buff *skb)
__be16 gre_proto; __be16 gre_proto;
if (!pskb_may_pull(skb, 16)) if (!pskb_may_pull(skb, 16))
goto drop_nolock; goto drop;
iph = ip_hdr(skb); iph = ip_hdr(skb);
h = skb->data; h = skb->data;
...@@ -636,7 +633,7 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -636,7 +633,7 @@ static int ipgre_rcv(struct sk_buff *skb)
- We do not support routing headers. - We do not support routing headers.
*/ */
if (flags&(GRE_VERSION|GRE_ROUTING)) if (flags&(GRE_VERSION|GRE_ROUTING))
goto drop_nolock; goto drop;
if (flags&GRE_CSUM) { if (flags&GRE_CSUM) {
switch (skb->ip_summed) { switch (skb->ip_summed) {
...@@ -664,7 +661,6 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -664,7 +661,6 @@ static int ipgre_rcv(struct sk_buff *skb)
gre_proto = *(__be16 *)(h + 2); gre_proto = *(__be16 *)(h + 2);
rcu_read_lock();
tunnel = ipgre_tunnel_lookup(skb->dev, tunnel = ipgre_tunnel_lookup(skb->dev,
iph->saddr, iph->daddr, flags, key, iph->saddr, iph->daddr, flags, key,
gre_proto); gre_proto);
...@@ -740,14 +736,11 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -740,14 +736,11 @@ static int ipgre_rcv(struct sk_buff *skb)
netif_rx(skb); netif_rx(skb);
rcu_read_unlock();
return 0; return 0;
} }
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
drop: drop:
rcu_read_unlock();
drop_nolock:
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
......
...@@ -437,14 +437,12 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -437,14 +437,12 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
ipv6h = (const struct ipv6hdr *)skb->data; ipv6h = (const struct ipv6hdr *)skb->data;
p = (__be16 *)(skb->data + offset); p = (__be16 *)(skb->data + offset);
rcu_read_lock();
t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr, t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
flags & GRE_KEY ? flags & GRE_KEY ?
*(((__be32 *)p) + (grehlen / 4) - 1) : 0, *(((__be32 *)p) + (grehlen / 4) - 1) : 0,
p[1]); p[1]);
if (t == NULL) if (t == NULL)
goto out; return;
switch (type) { switch (type) {
__u32 teli; __u32 teli;
...@@ -489,8 +487,6 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -489,8 +487,6 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
else else
t->err_count = 1; t->err_count = 1;
t->err_time = jiffies; t->err_time = jiffies;
out:
rcu_read_unlock();
} }
static inline void ip6gre_ecn_decapsulate_ipv4(const struct ip6_tnl *t, static inline void ip6gre_ecn_decapsulate_ipv4(const struct ip6_tnl *t,
...@@ -528,7 +524,7 @@ static int ip6gre_rcv(struct sk_buff *skb) ...@@ -528,7 +524,7 @@ static int ip6gre_rcv(struct sk_buff *skb)
__be16 gre_proto; __be16 gre_proto;
if (!pskb_may_pull(skb, sizeof(struct in6_addr))) if (!pskb_may_pull(skb, sizeof(struct in6_addr)))
goto drop_nolock; goto drop;
ipv6h = ipv6_hdr(skb); ipv6h = ipv6_hdr(skb);
h = skb->data; h = skb->data;
...@@ -539,7 +535,7 @@ static int ip6gre_rcv(struct sk_buff *skb) ...@@ -539,7 +535,7 @@ static int ip6gre_rcv(struct sk_buff *skb)
- We do not support routing headers. - We do not support routing headers.
*/ */
if (flags&(GRE_VERSION|GRE_ROUTING)) if (flags&(GRE_VERSION|GRE_ROUTING))
goto drop_nolock; goto drop;
if (flags&GRE_CSUM) { if (flags&GRE_CSUM) {
switch (skb->ip_summed) { switch (skb->ip_summed) {
...@@ -567,7 +563,6 @@ static int ip6gre_rcv(struct sk_buff *skb) ...@@ -567,7 +563,6 @@ static int ip6gre_rcv(struct sk_buff *skb)
gre_proto = *(__be16 *)(h + 2); gre_proto = *(__be16 *)(h + 2);
rcu_read_lock();
tunnel = ip6gre_tunnel_lookup(skb->dev, tunnel = ip6gre_tunnel_lookup(skb->dev,
&ipv6h->saddr, &ipv6h->daddr, key, &ipv6h->saddr, &ipv6h->daddr, key,
gre_proto); gre_proto);
...@@ -646,14 +641,11 @@ static int ip6gre_rcv(struct sk_buff *skb) ...@@ -646,14 +641,11 @@ static int ip6gre_rcv(struct sk_buff *skb)
netif_rx(skb); netif_rx(skb);
rcu_read_unlock();
return 0; return 0;
} }
icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0); icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
drop: drop:
rcu_read_unlock();
drop_nolock:
kfree_skb(skb); kfree_skb(skb);
return 0; return 0;
} }
......
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