]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv6/addrconf.c
[DCCP]: Perform SHUT_RD and SHUT_WR on receiving close
[net-next-2.6.git] / net / ipv6 / addrconf.c
index dbff389b70030ac51c965e1cd29a51f9eba39675..ba6f7925c17829fa16272f05e014fe338c376780 100644 (file)
@@ -256,16 +256,13 @@ static void addrconf_mod_timer(struct inet6_ifaddr *ifp,
 static int snmp6_alloc_dev(struct inet6_dev *idev)
 {
        if (snmp_mib_init((void **)idev->stats.ipv6,
-                         sizeof(struct ipstats_mib),
-                         __alignof__(struct ipstats_mib)) < 0)
+                         sizeof(struct ipstats_mib)) < 0)
                goto err_ip;
        if (snmp_mib_init((void **)idev->stats.icmpv6,
-                         sizeof(struct icmpv6_mib),
-                         __alignof__(struct icmpv6_mib)) < 0)
+                         sizeof(struct icmpv6_mib)) < 0)
                goto err_icmp;
        if (snmp_mib_init((void **)idev->stats.icmpv6msg,
-                         sizeof(struct icmpv6msg_mib),
-                         __alignof__(struct icmpv6msg_mib)) < 0)
+                         sizeof(struct icmpv6msg_mib)) < 0)
                goto err_icmpmsg;
 
        return 0;
@@ -476,6 +473,21 @@ static void addrconf_forward_change(void)
        }
        read_unlock(&dev_base_lock);
 }
+
+static void addrconf_fixup_forwarding(struct ctl_table *table, int *p, int old)
+{
+       if (p == &ipv6_devconf_dflt.forwarding)
+               return;
+
+       if (p == &ipv6_devconf.forwarding) {
+               ipv6_devconf_dflt.forwarding = ipv6_devconf.forwarding;
+               addrconf_forward_change();
+       } else if ((!*p) ^ (!old))
+               dev_forward_change((struct inet6_dev *)table->extra1);
+
+       if (*p)
+               rt6_purge_dflt_routers();
+}
 #endif
 
 /* Nobody refers to this ifaddr, destroy it */
@@ -3771,22 +3783,8 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write, struct file * filp,
 
        ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
 
-       if (write && valp != &ipv6_devconf_dflt.forwarding) {
-               if (valp != &ipv6_devconf.forwarding) {
-                       if ((!*valp) ^ (!val)) {
-                               struct inet6_dev *idev = (struct inet6_dev *)ctl->extra1;
-                               if (idev == NULL)
-                                       return ret;
-                               dev_forward_change(idev);
-                       }
-               } else {
-                       ipv6_devconf_dflt.forwarding = ipv6_devconf.forwarding;
-                       addrconf_forward_change();
-               }
-               if (*valp)
-                       rt6_purge_dflt_routers();
-       }
-
+       if (write)
+               addrconf_fixup_forwarding(ctl, valp, val);
        return ret;
 }
 
@@ -3797,6 +3795,7 @@ static int addrconf_sysctl_forward_strategy(ctl_table *table,
                                            void __user *newval, size_t newlen)
 {
        int *valp = table->data;
+       int val = *valp;
        int new;
 
        if (!newval || !newlen)
@@ -3821,26 +3820,8 @@ static int addrconf_sysctl_forward_strategy(ctl_table *table,
                }
        }
 
-       if (valp != &ipv6_devconf_dflt.forwarding) {
-               if (valp != &ipv6_devconf.forwarding) {
-                       struct inet6_dev *idev = (struct inet6_dev *)table->extra1;
-                       int changed;
-                       if (unlikely(idev == NULL))
-                               return -ENODEV;
-                       changed = (!*valp) ^ (!new);
-                       *valp = new;
-                       if (changed)
-                               dev_forward_change(idev);
-               } else {
-                       *valp = new;
-                       addrconf_forward_change();
-               }
-
-               if (*valp)
-                       rt6_purge_dflt_routers();
-       } else
-               *valp = new;
-
+       *valp = new;
+       addrconf_fixup_forwarding(table, valp, val);
        return 1;
 }