]> 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 348bd8d061125f61932c74d683e6a3f8d69c28e6..ba6f7925c17829fa16272f05e014fe338c376780 100644 (file)
 #define TIME_DELTA(a,b) ((unsigned long)((long)(a) - (long)(b)))
 
 #ifdef CONFIG_SYSCTL
-static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf *p);
+static void addrconf_sysctl_register(struct inet6_dev *idev);
 static void addrconf_sysctl_unregister(struct ipv6_devconf *p);
 #endif
 
@@ -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;
@@ -366,9 +363,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
        in6_dev_hold(ndev);
 
 #ifdef CONFIG_IPV6_PRIVACY
-       init_timer(&ndev->regen_timer);
-       ndev->regen_timer.function = ipv6_regen_rndid;
-       ndev->regen_timer.data = (unsigned long) ndev;
+       setup_timer(&ndev->regen_timer, ipv6_regen_rndid, (unsigned long)ndev);
        if ((dev->flags&IFF_LOOPBACK) ||
            dev->type == ARPHRD_TUNNEL ||
 #if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
@@ -379,6 +374,13 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
                       "%s: Disabled Privacy Extensions\n",
                       dev->name);
                ndev->cnf.use_tempaddr = -1;
+
+               if (dev->type == ARPHRD_SIT && (dev->priv_flags & IFF_ISATAP)) {
+                       printk(KERN_INFO
+                              "%s: Disabled Multicast RS\n",
+                              dev->name);
+                       ndev->cnf.rtr_solicits = 0;
+               }
        } else {
                in6_dev_hold(ndev);
                ipv6_regen_rndid((unsigned long) ndev);
@@ -395,7 +397,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
                              NET_IPV6_NEIGH, "ipv6",
                              &ndisc_ifinfo_sysctl_change,
                              NULL);
-       addrconf_sysctl_register(ndev, &ndev->cnf);
+       addrconf_sysctl_register(ndev);
 #endif
        /* protected by rtnl_lock */
        rcu_assign_pointer(dev->ip6_ptr, ndev);
@@ -471,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 */
@@ -876,35 +893,6 @@ static inline int ipv6_saddr_preferred(int type)
        return 0;
 }
 
-/* static matching label */
-static inline int ipv6_saddr_label(const struct in6_addr *addr, int type)
-{
- /*
-  *    prefix (longest match)  label
-  *    -----------------------------
-  *    ::1/128                 0
-  *    ::/0                    1
-  *    2002::/16               2
-  *    ::/96                   3
-  *    ::ffff:0:0/96           4
-  *    fc00::/7                5
-  *    2001::/32               6
-  */
-       if (type & IPV6_ADDR_LOOPBACK)
-               return 0;
-       else if (type & IPV6_ADDR_COMPATv4)
-               return 3;
-       else if (type & IPV6_ADDR_MAPPED)
-               return 4;
-       else if (addr->s6_addr32[0] == htonl(0x20010000))
-               return 6;
-       else if (addr->s6_addr16[0] == htons(0x2002))
-               return 2;
-       else if ((addr->s6_addr[0] & 0xfe) == 0xfc)
-               return 5;
-       return 1;
-}
-
 int ipv6_dev_get_saddr(struct net_device *daddr_dev,
                       struct in6_addr *daddr, struct in6_addr *saddr)
 {
@@ -912,7 +900,8 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
        struct inet6_ifaddr *ifa_result = NULL;
        int daddr_type = __ipv6_addr_type(daddr);
        int daddr_scope = __ipv6_addr_src_scope(daddr_type);
-       u32 daddr_label = ipv6_saddr_label(daddr, daddr_type);
+       int daddr_ifindex = daddr_dev ? daddr_dev->ifindex : 0;
+       u32 daddr_label = ipv6_addr_label(daddr, daddr_type, daddr_ifindex);
        struct net_device *dev;
 
        memset(&hiscore, 0, sizeof(hiscore));
@@ -967,7 +956,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
                        if (unlikely(score.addr_type == IPV6_ADDR_ANY ||
                                     score.addr_type & IPV6_ADDR_MULTICAST)) {
                                LIMIT_NETDEBUG(KERN_DEBUG
-                                              "ADDRCONF: unspecified / multicast address"
+                                              "ADDRCONF: unspecified / multicast address "
                                               "assigned as unicast address on %s",
                                               dev->name);
                                continue;
@@ -1085,11 +1074,15 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
 
                        /* Rule 6: Prefer matching label */
                        if (hiscore.rule < 6) {
-                               if (ipv6_saddr_label(&ifa_result->addr, hiscore.addr_type) == daddr_label)
+                               if (ipv6_addr_label(&ifa_result->addr,
+                                                   hiscore.addr_type,
+                                                   ifa_result->idev->dev->ifindex) == daddr_label)
                                        hiscore.attrs |= IPV6_SADDR_SCORE_LABEL;
                                hiscore.rule++;
                        }
-                       if (ipv6_saddr_label(&ifa->addr, score.addr_type) == daddr_label) {
+                       if (ipv6_addr_label(&ifa->addr,
+                                           score.addr_type,
+                                           ifa->idev->dev->ifindex) == daddr_label) {
                                score.attrs |= IPV6_SADDR_SCORE_LABEL;
                                if (!(hiscore.attrs & IPV6_SADDR_SCORE_LABEL)) {
                                        score.rule = 6;
@@ -1435,6 +1428,9 @@ static int ipv6_generate_eui64(u8 *eui, struct net_device *dev)
                return addrconf_ifid_arcnet(eui, dev);
        case ARPHRD_INFINIBAND:
                return addrconf_ifid_infiniband(eui, dev);
+       case ARPHRD_SIT:
+               if (dev->priv_flags & IFF_ISATAP)
+                       return ipv6_isatap_eui64(eui, *(__be32 *)dev->dev_addr);
        }
        return -1;
 }
@@ -1470,7 +1466,7 @@ regen:
         *
         *  - Reserved subnet anycast (RFC 2526)
         *      11111101 11....11 1xxxxxxx
-        *  - ISATAP (draft-ietf-ngtrans-isatap-13.txt) 5.1
+        *  - ISATAP (RFC4214) 6.1
         *      00-00-5E-FE-xx-xx-xx-xx
         *  - value 0
         *  - XXX: already assigned to an address on the device
@@ -2201,6 +2197,16 @@ static void addrconf_sit_config(struct net_device *dev)
                return;
        }
 
+       if (dev->priv_flags & IFF_ISATAP) {
+               struct in6_addr addr;
+
+               ipv6_addr_set(&addr,  htonl(0xFE800000), 0, 0, 0);
+               addrconf_prefix_route(&addr, 64, dev, 0, 0);
+               if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
+                       addrconf_add_linklocal(idev, &addr);
+               return;
+       }
+
        sit_add_v4_addrs(idev);
 
        if (dev->flags&IFF_POINTOPOINT) {
@@ -2293,6 +2299,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
                                break;
                        }
 
+                       if (!idev && dev->mtu >= IPV6_MIN_MTU)
+                               idev = ipv6_add_dev(dev);
+
                        if (idev)
                                idev->if_flags |= IF_READY;
                } else {
@@ -2357,12 +2366,18 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
                break;
 
        case NETDEV_CHANGEMTU:
-               if ( idev && dev->mtu >= IPV6_MIN_MTU) {
+               if (idev && dev->mtu >= IPV6_MIN_MTU) {
                        rt6_mtu_change(dev, dev->mtu);
                        idev->cnf.mtu6 = dev->mtu;
                        break;
                }
 
+               if (!idev && dev->mtu >= IPV6_MIN_MTU) {
+                       idev = ipv6_add_dev(dev);
+                       if (idev)
+                               break;
+               }
+
                /* MTU falled under IPV6_MIN_MTU. Stop IPv6 on this interface. */
 
        case NETDEV_DOWN:
@@ -2383,7 +2398,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
                                              NET_IPV6, NET_IPV6_NEIGH, "ipv6",
                                              &ndisc_ifinfo_sysctl_change,
                                              NULL);
-                       addrconf_sysctl_register(idev, &idev->cnf);
+                       addrconf_sysctl_register(idev);
 #endif
                        err = snmp6_register_dev(idev);
                        if (err)
@@ -2988,11 +3003,15 @@ static const struct nla_policy ifa_ipv6_policy[IFA_MAX+1] = {
 static int
 inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct ifaddrmsg *ifm;
        struct nlattr *tb[IFA_MAX+1];
        struct in6_addr *pfx;
        int err;
 
+       if (net != &init_net)
+               return -EINVAL;
+
        err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
        if (err < 0)
                return err;
@@ -3045,6 +3064,7 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, u8 ifa_flags,
 static int
 inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct ifaddrmsg *ifm;
        struct nlattr *tb[IFA_MAX+1];
        struct in6_addr *pfx;
@@ -3054,6 +3074,9 @@ inet6_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
        u8 ifa_flags;
        int err;
 
+       if (net != &init_net)
+               return -EINVAL;
+
        err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
        if (err < 0)
                return err;
@@ -3327,26 +3350,42 @@ done:
 
 static int inet6_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        enum addr_type_t type = UNICAST_ADDR;
+
+       if (net != &init_net)
+               return 0;
+
        return inet6_dump_addr(skb, cb, type);
 }
 
 static int inet6_dump_ifmcaddr(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        enum addr_type_t type = MULTICAST_ADDR;
+
+       if (net != &init_net)
+               return 0;
+
        return inet6_dump_addr(skb, cb, type);
 }
 
 
 static int inet6_dump_ifacaddr(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        enum addr_type_t type = ANYCAST_ADDR;
+
+       if (net != &init_net)
+               return 0;
+
        return inet6_dump_addr(skb, cb, type);
 }
 
 static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
                             void *arg)
 {
+       struct net *net = in_skb->sk->sk_net;
        struct ifaddrmsg *ifm;
        struct nlattr *tb[IFA_MAX+1];
        struct in6_addr *addr = NULL;
@@ -3355,6 +3394,9 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
        struct sk_buff *skb;
        int err;
 
+       if (net != &init_net)
+               return -EINVAL;
+
        err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
        if (err < 0)
                goto errout;
@@ -3387,7 +3429,7 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr* nlh,
                kfree_skb(skb);
                goto errout_ifa;
        }
-       err = rtnl_unicast(skb, NETLINK_CB(in_skb).pid);
+       err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid);
 errout_ifa:
        in6_ifa_put(ifa);
 errout:
@@ -3410,10 +3452,10 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
                kfree_skb(skb);
                goto errout;
        }
-       err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
+       err = rtnl_notify(skb, &init_net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
-               rtnl_set_sk_err(RTNLGRP_IPV6_IFADDR, err);
+               rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_IFADDR, err);
 }
 
 static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
@@ -3572,11 +3614,15 @@ nla_put_failure:
 
 static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        int idx, err;
        int s_idx = cb->args[0];
        struct net_device *dev;
        struct inet6_dev *idev;
 
+       if (net != &init_net)
+               return 0;
+
        read_lock(&dev_base_lock);
        idx = 0;
        for_each_netdev(&init_net, dev) {
@@ -3614,10 +3660,10 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
                kfree_skb(skb);
                goto errout;
        }
-       err = rtnl_notify(skb, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
+       err = rtnl_notify(skb, &init_net, 0, RTNLGRP_IPV6_IFADDR, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
-               rtnl_set_sk_err(RTNLGRP_IPV6_IFADDR, err);
+               rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_IFADDR, err);
 }
 
 static inline size_t inet6_prefix_nlmsg_size(void)
@@ -3683,10 +3729,10 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
                kfree_skb(skb);
                goto errout;
        }
-       err = rtnl_notify(skb, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC);
+       err = rtnl_notify(skb, &init_net, 0, RTNLGRP_IPV6_PREFIX, NULL, GFP_ATOMIC);
 errout:
        if (err < 0)
-               rtnl_set_sk_err(RTNLGRP_IPV6_PREFIX, err);
+               rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_PREFIX, err);
 }
 
 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
@@ -3737,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;
 }
 
@@ -3763,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)
@@ -3787,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;
 }
 
@@ -3814,10 +3829,7 @@ static struct addrconf_sysctl_table
 {
        struct ctl_table_header *sysctl_header;
        ctl_table addrconf_vars[__NET_IPV6_MAX];
-       ctl_table addrconf_dev[2];
-       ctl_table addrconf_conf_dir[2];
-       ctl_table addrconf_proto_dir[2];
-       ctl_table addrconf_root_dir[2];
+       char *dev_name;
 } addrconf_sysctl __read_mostly = {
        .sysctl_header = NULL,
        .addrconf_vars = {
@@ -4038,113 +4050,75 @@ static struct addrconf_sysctl_table
                        .ctl_name       =       0,      /* sentinel */
                }
        },
-       .addrconf_dev = {
-               {
-                       .ctl_name       =       NET_PROTO_CONF_ALL,
-                       .procname       =       "all",
-                       .mode           =       0555,
-                       .child          =       addrconf_sysctl.addrconf_vars,
-               },
-               {
-                       .ctl_name       =       0,      /* sentinel */
-               }
-       },
-       .addrconf_conf_dir = {
-               {
-                       .ctl_name       =       NET_IPV6_CONF,
-                       .procname       =       "conf",
-                       .mode           =       0555,
-                       .child          =       addrconf_sysctl.addrconf_dev,
-               },
-               {
-                       .ctl_name       =       0,      /* sentinel */
-               }
-       },
-       .addrconf_proto_dir = {
-               {
-                       .ctl_name       =       NET_IPV6,
-                       .procname       =       "ipv6",
-                       .mode           =       0555,
-                       .child          =       addrconf_sysctl.addrconf_conf_dir,
-               },
-               {
-                       .ctl_name       =       0,      /* sentinel */
-               }
-       },
-       .addrconf_root_dir = {
-               {
-                       .ctl_name       =       CTL_NET,
-                       .procname       =       "net",
-                       .mode           =       0555,
-                       .child          =       addrconf_sysctl.addrconf_proto_dir,
-               },
-               {
-                       .ctl_name       =       0,      /* sentinel */
-               }
-       },
 };
 
-static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf *p)
+static void __addrconf_sysctl_register(char *dev_name, int ctl_name,
+               struct inet6_dev *idev, struct ipv6_devconf *p)
 {
        int i;
-       struct net_device *dev = idev ? idev->dev : NULL;
        struct addrconf_sysctl_table *t;
-       char *dev_name = NULL;
+
+#define ADDRCONF_CTL_PATH_DEV  3
+
+       struct ctl_path addrconf_ctl_path[] = {
+               { .procname = "net", .ctl_name = CTL_NET, },
+               { .procname = "ipv6", .ctl_name = NET_IPV6, },
+               { .procname = "conf", .ctl_name = NET_IPV6_CONF, },
+               { /* to be set */ },
+               { },
+       };
+
 
        t = kmemdup(&addrconf_sysctl, sizeof(*t), GFP_KERNEL);
        if (t == NULL)
-               return;
+               goto out;
+
        for (i=0; t->addrconf_vars[i].data; i++) {
                t->addrconf_vars[i].data += (char*)p - (char*)&ipv6_devconf;
                t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */
        }
-       if (dev) {
-               dev_name = dev->name;
-               t->addrconf_dev[0].ctl_name = dev->ifindex;
-       } else {
-               dev_name = "default";
-               t->addrconf_dev[0].ctl_name = NET_PROTO_CONF_DEFAULT;
-       }
 
        /*
         * Make a copy of dev_name, because '.procname' is regarded as const
         * by sysctl and we wouldn't want anyone to change it under our feet
         * (see SIOCSIFNAME).
         */
-       dev_name = kstrdup(dev_name, GFP_KERNEL);
-       if (!dev_name)
-           goto free;
+       t->dev_name = kstrdup(dev_name, GFP_KERNEL);
+       if (!t->dev_name)
+               goto free;
 
-       t->addrconf_dev[0].procname = dev_name;
+       addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].procname = t->dev_name;
+       addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV].ctl_name = ctl_name;
 
-       t->addrconf_dev[0].child = t->addrconf_vars;
-       t->addrconf_conf_dir[0].child = t->addrconf_dev;
-       t->addrconf_proto_dir[0].child = t->addrconf_conf_dir;
-       t->addrconf_root_dir[0].child = t->addrconf_proto_dir;
-
-       t->sysctl_header = register_sysctl_table(t->addrconf_root_dir);
+       t->sysctl_header = register_sysctl_paths(addrconf_ctl_path,
+                       t->addrconf_vars);
        if (t->sysctl_header == NULL)
                goto free_procname;
-       else
-               p->sysctl = t;
+
+       p->sysctl = t;
        return;
 
-       /* error path */
- free_procname:
-       kfree(dev_name);
- free:
+free_procname:
+       kfree(t->dev_name);
+free:
        kfree(t);
-
+out:
        return;
 }
 
+static void addrconf_sysctl_register(struct inet6_dev *idev)
+{
+       __addrconf_sysctl_register(idev->dev->name, idev->dev->ifindex,
+                       idev, &idev->cnf);
+}
+
 static void addrconf_sysctl_unregister(struct ipv6_devconf *p)
 {
        if (p->sysctl) {
                struct addrconf_sysctl_table *t = p->sysctl;
                p->sysctl = NULL;
                unregister_sysctl_table(t->sysctl_header);
-               kfree(t->addrconf_dev[0].procname);
+               kfree(t->dev_name);
                kfree(t);
        }
 }
@@ -4176,7 +4150,13 @@ EXPORT_SYMBOL(unregister_inet6addr_notifier);
 
 int __init addrconf_init(void)
 {
-       int err = 0;
+       int err;
+
+       if ((err = ipv6_addr_label_init()) < 0) {
+               printk(KERN_CRIT "IPv6 Addrconf: cannot initialize default policy table: %d.\n",
+                       err);
+               return err;
+       }
 
        /* The addrconf netdev notifier requires that loopback_dev
         * has it's ipv6 private information allocated and setup
@@ -4227,10 +4207,13 @@ int __init addrconf_init(void)
        __rtnl_register(PF_INET6, RTM_GETMULTICAST, NULL, inet6_dump_ifmcaddr);
        __rtnl_register(PF_INET6, RTM_GETANYCAST, NULL, inet6_dump_ifacaddr);
 
+       ipv6_addr_label_rtnl_register();
+
 #ifdef CONFIG_SYSCTL
-       addrconf_sysctl.sysctl_header =
-               register_sysctl_table(addrconf_sysctl.addrconf_root_dir);
-       addrconf_sysctl_register(NULL, &ipv6_devconf_dflt);
+       __addrconf_sysctl_register("all", NET_PROTO_CONF_ALL,
+                       NULL, &ipv6_devconf);
+       __addrconf_sysctl_register("default", NET_PROTO_CONF_DEFAULT,
+                       NULL, &ipv6_devconf_dflt);
 #endif
 
        return 0;
@@ -4288,8 +4271,4 @@ void __exit addrconf_cleanup(void)
        del_timer(&addr_chk_timer);
 
        rtnl_unlock();
-
-#ifdef CONFIG_PROC_FS
-       proc_net_remove(&init_net, "if_inet6");
-#endif
 }