ip6tnl: less dev_put() calls
Using dev_get_by_index_rcu() in ip6_tnl_rcv_ctl() & ip6_tnl_xmit_ctl() avoids touching device refcount. Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
654d1f8a01
commit
f1a28eab20
|
@ -658,6 +658,7 @@ static void ip6ip6_dscp_ecn_decapsulate(struct ip6_tnl *t,
|
||||||
IP6_ECN_set_ce(ipv6_hdr(skb));
|
IP6_ECN_set_ce(ipv6_hdr(skb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* called with rcu_read_lock() */
|
||||||
static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
|
static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
|
||||||
{
|
{
|
||||||
struct ip6_tnl_parm *p = &t->parms;
|
struct ip6_tnl_parm *p = &t->parms;
|
||||||
|
@ -668,15 +669,13 @@ static inline int ip6_tnl_rcv_ctl(struct ip6_tnl *t)
|
||||||
struct net_device *ldev = NULL;
|
struct net_device *ldev = NULL;
|
||||||
|
|
||||||
if (p->link)
|
if (p->link)
|
||||||
ldev = dev_get_by_index(net, p->link);
|
ldev = dev_get_by_index_rcu(net, p->link);
|
||||||
|
|
||||||
if ((ipv6_addr_is_multicast(&p->laddr) ||
|
if ((ipv6_addr_is_multicast(&p->laddr) ||
|
||||||
likely(ipv6_chk_addr(net, &p->laddr, ldev, 0))) &&
|
likely(ipv6_chk_addr(net, &p->laddr, ldev, 0))) &&
|
||||||
likely(!ipv6_chk_addr(net, &p->raddr, NULL, 0)))
|
likely(!ipv6_chk_addr(net, &p->raddr, NULL, 0)))
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
if (ldev)
|
|
||||||
dev_put(ldev);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -804,8 +803,9 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
|
||||||
if (p->flags & IP6_TNL_F_CAP_XMIT) {
|
if (p->flags & IP6_TNL_F_CAP_XMIT) {
|
||||||
struct net_device *ldev = NULL;
|
struct net_device *ldev = NULL;
|
||||||
|
|
||||||
|
rcu_read_lock();
|
||||||
if (p->link)
|
if (p->link)
|
||||||
ldev = dev_get_by_index(net, p->link);
|
ldev = dev_get_by_index_rcu(net, p->link);
|
||||||
|
|
||||||
if (unlikely(!ipv6_chk_addr(net, &p->laddr, ldev, 0)))
|
if (unlikely(!ipv6_chk_addr(net, &p->laddr, ldev, 0)))
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
|
@ -819,8 +819,7 @@ static inline int ip6_tnl_xmit_ctl(struct ip6_tnl *t)
|
||||||
p->name);
|
p->name);
|
||||||
else
|
else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
if (ldev)
|
rcu_read_unlock();
|
||||||
dev_put(ldev);
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue