Skip to content

Commit

Permalink
ipv6: Fix sysctl unregistration deadlock
Browse files Browse the repository at this point in the history
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Mar 3, 2009
1 parent 5a5990d commit b325fdd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions net/ipv6/addrconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,17 @@ static void addrconf_forward_change(struct net *net, __s32 newf)
read_unlock(&dev_base_lock);
}

static void addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old)
static int addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old)
{
struct net *net;

net = (struct net *)table->extra2;
if (p == &net->ipv6.devconf_dflt->forwarding)
return;
return 0;

if (!rtnl_trylock())
return -ERESTARTSYS;

rtnl_lock();
if (p == &net->ipv6.devconf_all->forwarding) {
__s32 newf = net->ipv6.devconf_all->forwarding;
net->ipv6.devconf_dflt->forwarding = newf;
Expand All @@ -512,6 +514,7 @@ static void addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old)

if (*p)
rt6_purge_dflt_routers(net);
return 1;
}
#endif

Expand Down Expand Up @@ -3983,7 +3986,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);

if (write)
addrconf_fixup_forwarding(ctl, valp, val);
ret = addrconf_fixup_forwarding(ctl, valp, val);
return ret;
}

Expand Down Expand Up @@ -4019,8 +4022,7 @@ static int addrconf_sysctl_forward_strategy(ctl_table *table,
}

*valp = new;
addrconf_fixup_forwarding(table, valp, val);
return 1;
return addrconf_fixup_forwarding(table, valp, val);
}

static struct addrconf_sysctl_table
Expand Down

0 comments on commit b325fdd

Please sign in to comment.