summaryrefslogtreecommitdiff
path: root/net/ipv4/devinet.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2010-02-19 13:22:59 +0000
committerDavid S. Miller <davem@davemloft.net>2010-02-19 15:40:50 -0800
commit88af182e389097997c5e2a0b42285b3522796759 (patch)
treeb2df5a8589aaee30073665da46523a3908e8870a /net/ipv4/devinet.c
parentb0483e78e5c4c9871fc5541875b3bc006846d46b (diff)
downloadlinux-3.10-88af182e389097997c5e2a0b42285b3522796759.tar.gz
linux-3.10-88af182e389097997c5e2a0b42285b3522796759.tar.bz2
linux-3.10-88af182e389097997c5e2a0b42285b3522796759.zip
net: Fix sysctl restarts...
Yuck. It turns out that when we restart sysctls we were restarting with the values already changed. Which unfortunately meant that the second time through we thought there was no change and skipped all kinds of work, despite the fact that there was indeed a change. I have fixed this the simplest way possible by restoring the changed values when we restart the sysctl write. One of my coworkers spotted this bug when after disabling forwarding on an interface pings were still forwarded. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r--net/ipv4/devinet.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 040c4f05b65..26dec2be961 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1317,14 +1317,19 @@ static int devinet_sysctl_forward(ctl_table *ctl, int write,
{
int *valp = ctl->data;
int val = *valp;
+ loff_t pos = *ppos;
int ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
if (write && *valp != val) {
struct net *net = ctl->extra2;
if (valp != &IPV4_DEVCONF_DFLT(net, FORWARDING)) {
- if (!rtnl_trylock())
+ if (!rtnl_trylock()) {
+ /* Restore the original values before restarting */
+ *valp = val;
+ *ppos = pos;
return restart_syscall();
+ }
if (valp == &IPV4_DEVCONF_ALL(net, FORWARDING)) {
inet_forward_change(net);
} else if (*valp) {