Commit 73af614a authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

neigh: use tbl->family to distinguish ipv4 from ipv6

Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb5b09c1
...@@ -202,6 +202,11 @@ struct neigh_table { ...@@ -202,6 +202,11 @@ struct neigh_table {
struct pneigh_entry **phash_buckets; 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_PRIV_ALIGN sizeof(long long)
#define NEIGH_ENTRY_SIZE(size) ALIGN((size), NEIGH_PRIV_ALIGN) #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, ...@@ -306,7 +311,7 @@ int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write,
size_t *lenp, loff_t *ppos); size_t *lenp, loff_t *ppos);
int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, 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); void neigh_sysctl_unregister(struct neigh_parms *p);
static inline void __neigh_parms_put(struct neigh_parms *parms) static inline void __neigh_parms_put(struct neigh_parms *parms)
......
...@@ -2947,12 +2947,13 @@ static struct neigh_sysctl_table { ...@@ -2947,12 +2947,13 @@ static struct neigh_sysctl_table {
}; };
int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
char *p_name, proc_handler *handler) proc_handler *handler)
{ {
int i; int i;
struct neigh_sysctl_table *t; struct neigh_sysctl_table *t;
const char *dev_name_source; const char *dev_name_source;
char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ]; char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ];
char *p_name;
t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL); t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL);
if (!t) if (!t)
...@@ -2991,6 +2992,17 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, ...@@ -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) if (neigh_parms_net(p)->user_ns != &init_user_ns)
t->neigh_vars[0].procname = NULL; 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", snprintf(neigh_path, sizeof(neigh_path), "net/%s/neigh/%s",
p_name, dev_name_source); p_name, dev_name_source);
t->sysctl_header = t->sysctl_header =
......
...@@ -1287,7 +1287,7 @@ void __init arp_init(void) ...@@ -1287,7 +1287,7 @@ void __init arp_init(void)
dev_add_pack(&arp_packet_type); dev_add_pack(&arp_packet_type);
arp_proc_init(); arp_proc_init();
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
neigh_sysctl_register(NULL, &arp_tbl.parms, "ipv4", NULL); neigh_sysctl_register(NULL, &arp_tbl.parms, NULL);
#endif #endif
register_netdevice_notifier(&arp_netdev_notifier); register_netdevice_notifier(&arp_netdev_notifier);
} }
......
...@@ -2160,7 +2160,7 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf) ...@@ -2160,7 +2160,7 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)
static void devinet_sysctl_register(struct in_device *idev) 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, __devinet_sysctl_register(dev_net(idev->dev), idev->dev->name,
&idev->cnf); &idev->cnf);
} }
......
...@@ -5028,7 +5028,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p) ...@@ -5028,7 +5028,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
static void addrconf_sysctl_register(struct inet6_dev *idev) 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); &ndisc_ifinfo_sysctl_change);
__addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name, __addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name,
idev, &idev->cnf); idev, &idev->cnf);
......
...@@ -1730,7 +1730,7 @@ int __init ndisc_init(void) ...@@ -1730,7 +1730,7 @@ int __init ndisc_init(void)
neigh_table_init(&nd_tbl); neigh_table_init(&nd_tbl);
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
err = neigh_sysctl_register(NULL, &nd_tbl.parms, "ipv6", err = neigh_sysctl_register(NULL, &nd_tbl.parms,
&ndisc_ifinfo_sysctl_change); &ndisc_ifinfo_sysctl_change);
if (err) if (err)
goto out_unregister_pernet; goto out_unregister_pernet;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment