}
static struct ip_tunnel_prl_entry *
-ipip6_tunnel_locate_prl(struct ip_tunnel *t, __be32 addr)
+__ipip6_tunnel_locate_prl(struct ip_tunnel *t, __be32 addr)
{
struct ip_tunnel_prl_entry *p = (struct ip_tunnel_prl_entry *)NULL;
ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
{
struct ip_tunnel_prl_entry *p;
+ int err = 0;
+
+ write_lock(&ipip6_lock);
for (p = t->prl; p; p = p->next) {
if (p->entry.addr == a->addr) {
- if (chg) {
- p->entry = *a;
- return 0;
- }
- return -EEXIST;
+ if (chg)
+ goto update;
+ err = -EEXIST;
+ goto out;
}
}
- if (chg)
- return -ENXIO;
+ if (chg) {
+ err = -ENXIO;
+ goto out;
+ }
p = kzalloc(sizeof(struct ip_tunnel_prl_entry), GFP_KERNEL);
- if (!p)
- return -ENOBUFS;
+ if (!p) {
+ err = -ENOBUFS;
+ goto out;
+ }
- p->entry = *a;
p->next = t->prl;
t->prl = p;
- return 0;
+update:
+ p->entry = *a;
+out:
+ write_unlock(&ipip6_lock);
+ return err;
}
static int
ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)
{
struct ip_tunnel_prl_entry *x, **p;
+ int err = 0;
+
+ write_lock(&ipip6_lock);
if (a) {
for (p = &t->prl; *p; p = &(*p)->next) {
x = *p;
*p = x->next;
kfree(x);
- return 0;
+ goto out;
}
}
- return -ENXIO;
+ err = -ENXIO;
} else {
while (t->prl) {
x = t->prl;
kfree(x);
}
}
+out:
+ write_unlock(&ipip6_lock);
return 0;
}
static int
isatap_chksrc(struct sk_buff *skb, struct iphdr *iph, struct ip_tunnel *t)
{
- struct ip_tunnel_prl_entry *p = ipip6_tunnel_locate_prl(t, iph->saddr);
+ struct ip_tunnel_prl_entry *p;
int ok = 1;
+ read_lock(&ipip6_lock);
+ p = __ipip6_tunnel_locate_prl(t, iph->saddr);
if (p) {
if (p->entry.flags & PRL_DEFAULT)
skb->ndisc_nodetype = NDISC_NODETYPE_DEFAULT;
else
ok = 0;
}
+ read_unlock(&ipip6_lock);
return ok;
}
if (!(t = netdev_priv(dev)))
goto done;
- ipip6_tunnel_unlink(t);
if (cmd == SIOCDELPRL)
err = ipip6_tunnel_del_prl(t, &prl);
else
err = ipip6_tunnel_add_prl(t, &prl, cmd == SIOCCHGPRL);
- ipip6_tunnel_link(t);
netdev_state_change(dev);
break;