]> git.hungrycats.org Git - linux/commitdiff
[IPV6]: strategy handler for net.ipv6.conf.* forwarding.
authorHideaki Yoshifuji <yoshfuji@linux-ipv6.org>
Sat, 9 Aug 2003 07:47:05 +0000 (00:47 -0700)
committerDavid S. Miller <davem@nuts.ninka.net>
Sat, 9 Aug 2003 07:47:05 +0000 (00:47 -0700)
net/ipv6/addrconf.c

index 925effb2390cd28c971b0212a95a782f2c2f8276..774ae2156efa8f3bbb3109f53bffa66b57c4a7ff 100644 (file)
@@ -2593,6 +2593,53 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
         return ret;
 }
 
+static int addrconf_sysctl_forward_strategy(ctl_table *table, 
+                                           int *name, int nlen,
+                                           void *oldval, size_t *oldlenp,
+                                           void *newval, size_t newlen,
+                                           void **context)
+{
+       int *valp = table->data;
+       int new;
+
+       if (!newval || !newlen)
+               return 0;
+       if (newlen != sizeof(int))
+               return -EINVAL;
+       if (get_user(new, (int *)newval))
+               return -EFAULT;
+       if (new == *valp)
+               return 0;
+       if (oldval && oldlenp) {
+               size_t len;
+               if (get_user(len, oldlenp))
+                       return -EFAULT;
+               if (len) {
+                       if (len > table->maxlen)
+                               len = table->maxlen;
+                       if (copy_to_user(oldval, valp, len))
+                               return -EFAULT;
+                       if (put_user(len, oldlenp))
+                               return -EFAULT;
+               }
+       }
+
+       if (valp != &ipv6_devconf_dflt.forwarding) {
+               struct inet6_dev *idev;
+               if (valp != &ipv6_devconf.forwarding) {
+                       idev = (struct inet6_dev *)table->extra1;
+                       if (unlikely(idev == NULL))
+                               return -ENODEV;
+               } else
+                       idev = NULL;
+               *valp = new;
+               addrconf_forward_change(idev);
+       } else
+               *valp = new;
+
+       return 1;
+}
+
 static struct addrconf_sysctl_table
 {
        struct ctl_table_header *sysctl_header;
@@ -2611,6 +2658,7 @@ static struct addrconf_sysctl_table
                        .maxlen         =       sizeof(int),
                        .mode           =       0644,
                        .proc_handler   =       &addrconf_sysctl_forward,
+                       .strategy       =       &addrconf_sysctl_forward_strategy,
                },
                {
                        .ctl_name       =       NET_IPV6_HOP_LIMIT,