neigh: use tbl->family to distinguish ipv4 from ipv6
authorJiri Pirko <jiri@resnulli.us>
Sat, 7 Dec 2013 18:26:55 +0000 (19:26 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 10 Dec 2013 01:56:12 +0000 (20:56 -0500)
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/neighbour.h
net/core/neighbour.c
net/ipv4/arp.c
net/ipv4/devinet.c
net/ipv6/addrconf.c
net/ipv6/ndisc.c

index ed7eba0452979620353453e160b5f258f38c9cd8..95615c9ad13abf2a9fc76854a52f4043a34f42d0 100644 (file)
@@ -202,6 +202,11 @@ struct neigh_table {
        struct pneigh_entry     **phash_buckets;
 };
 
+static inline int neigh_parms_family(struct neigh_parms *p)
+{
+       return p->tbl->family;
+}
+
 #define NEIGH_PRIV_ALIGN       sizeof(long long)
 #define NEIGH_ENTRY_SIZE(size) ALIGN((size), NEIGH_PRIV_ALIGN)
 
@@ -306,7 +311,7 @@ int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write,
                                   size_t *lenp, loff_t *ppos);
 
 int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
-                         char *p_name, proc_handler *proc_handler);
+                         proc_handler *proc_handler);
 void neigh_sysctl_unregister(struct neigh_parms *p);
 
 static inline void __neigh_parms_put(struct neigh_parms *parms)
index 60edd97ad2bc4a4919f5fbded28537622589f1b8..65ead080167b2fe6bb3ab9ee923de2b5b3b99711 100644 (file)
@@ -2947,12 +2947,13 @@ static struct neigh_sysctl_table {
 };
 
 int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
-                         char *p_name, proc_handler *handler)
+                         proc_handler *handler)
 {
        int i;
        struct neigh_sysctl_table *t;
        const char *dev_name_source;
        char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ];
+       char *p_name;
 
        t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL);
        if (!t)
@@ -2991,6 +2992,17 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
        if (neigh_parms_net(p)->user_ns != &init_user_ns)
                t->neigh_vars[0].procname = NULL;
 
+       switch (neigh_parms_family(p)) {
+       case AF_INET:
+             p_name = "ipv4";
+             break;
+       case AF_INET6:
+             p_name = "ipv6";
+             break;
+       default:
+             BUG();
+       }
+
        snprintf(neigh_path, sizeof(neigh_path), "net/%s/neigh/%s",
                p_name, dev_name_source);
        t->sysctl_header =
index 3a37c7df2a2f1275ec9673c82d0ef91054a4b338..f0418586394053e764d5e1cc1e3d9466f931e320 100644 (file)
@@ -1287,7 +1287,7 @@ void __init arp_init(void)
        dev_add_pack(&arp_packet_type);
        arp_proc_init();
 #ifdef CONFIG_SYSCTL
-       neigh_sysctl_register(NULL, &arp_tbl.parms, "ipv4", NULL);
+       neigh_sysctl_register(NULL, &arp_tbl.parms, NULL);
 #endif
        register_netdevice_notifier(&arp_netdev_notifier);
 }
index a1b5bcbd04ae01e358d1542c354fac083c9f8582..e1c19535fe38532f81d297ceb6817ce9639a4eda 100644 (file)
@@ -2160,7 +2160,7 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)
 
 static void devinet_sysctl_register(struct in_device *idev)
 {
-       neigh_sysctl_register(idev->dev, idev->arp_parms, "ipv4", NULL);
+       neigh_sysctl_register(idev->dev, idev->arp_parms, NULL);
        __devinet_sysctl_register(dev_net(idev->dev), idev->dev->name,
                                        &idev->cnf);
 }
index 55dc56f9072ca314838e8aaf203ee9d0e2d4046b..ea8a475fa8c5d4356a90338339c064d886c9e701 100644 (file)
@@ -5028,7 +5028,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
 
 static void addrconf_sysctl_register(struct inet6_dev *idev)
 {
-       neigh_sysctl_register(idev->dev, idev->nd_parms, "ipv6",
+       neigh_sysctl_register(idev->dev, idev->nd_parms,
                              &ndisc_ifinfo_sysctl_change);
        __addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name,
                                        idev, &idev->cnf);
index 5fc6f69652b8eea0bad4539c03ffd419bc95acdd..09a22f4f36c9e069c6dfb3074909691ef2c82399 100644 (file)
@@ -1730,7 +1730,7 @@ int __init ndisc_init(void)
        neigh_table_init(&nd_tbl);
 
 #ifdef CONFIG_SYSCTL
-       err = neigh_sysctl_register(NULL, &nd_tbl.parms, "ipv6",
+       err = neigh_sysctl_register(NULL, &nd_tbl.parms,
                                    &ndisc_ifinfo_sysctl_change);
        if (err)
                goto out_unregister_pernet;