提交 aac4dddc 编写于 作者: E Eric Dumazet 提交者: David S. Miller

ipv6: get rid of ipip6_prl_lock

As noticed by Julia Lawall, ipip6_tunnel_add_prl() incorrectly calls 
kzallloc(..., GFP_KERNEL) while a spinlock is held. She provided
a patch to use GFP_ATOMIC instead.

One possibility would be to convert this spinlock to a mutex, or
preallocate the thing before taking the lock.

After RCU conversion, it appears we dont need this lock, since 
caller already holds RTNL
Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 95e3bb7a
...@@ -249,8 +249,6 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct net *net, ...@@ -249,8 +249,6 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct net *net,
return NULL; return NULL;
} }
static DEFINE_SPINLOCK(ipip6_prl_lock);
#define for_each_prl_rcu(start) \ #define for_each_prl_rcu(start) \
for (prl = rcu_dereference(start); \ for (prl = rcu_dereference(start); \
prl; \ prl; \
...@@ -340,7 +338,7 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg) ...@@ -340,7 +338,7 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
if (a->addr == htonl(INADDR_ANY)) if (a->addr == htonl(INADDR_ANY))
return -EINVAL; return -EINVAL;
spin_lock(&ipip6_prl_lock); ASSERT_RTNL();
for (p = t->prl; p; p = p->next) { for (p = t->prl; p; p = p->next) {
if (p->addr == a->addr) { if (p->addr == a->addr) {
...@@ -370,7 +368,6 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg) ...@@ -370,7 +368,6 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
t->prl_count++; t->prl_count++;
rcu_assign_pointer(t->prl, p); rcu_assign_pointer(t->prl, p);
out: out:
spin_unlock(&ipip6_prl_lock);
return err; return err;
} }
...@@ -397,7 +394,7 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) ...@@ -397,7 +394,7 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)
struct ip_tunnel_prl_entry *x, **p; struct ip_tunnel_prl_entry *x, **p;
int err = 0; int err = 0;
spin_lock(&ipip6_prl_lock); ASSERT_RTNL();
if (a && a->addr != htonl(INADDR_ANY)) { if (a && a->addr != htonl(INADDR_ANY)) {
for (p = &t->prl; *p; p = &(*p)->next) { for (p = &t->prl; *p; p = &(*p)->next) {
...@@ -419,7 +416,6 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a) ...@@ -419,7 +416,6 @@ ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)
} }
} }
out: out:
spin_unlock(&ipip6_prl_lock);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册