Skip to content

Commit 73af614

Browse files
jpirkodavem330
authored andcommitted
neigh: use tbl->family to distinguish ipv4 from ipv6
Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cb5b09c commit 73af614

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

include/net/neighbour.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ struct neigh_table {
202202
struct pneigh_entry **phash_buckets;
203203
};
204204

205+
static inline int neigh_parms_family(struct neigh_parms *p)
206+
{
207+
return p->tbl->family;
208+
}
209+
205210
#define NEIGH_PRIV_ALIGN sizeof(long long)
206211
#define NEIGH_ENTRY_SIZE(size) ALIGN((size), NEIGH_PRIV_ALIGN)
207212

@@ -306,7 +311,7 @@ int neigh_proc_dointvec_ms_jiffies(struct ctl_table *ctl, int write,
306311
size_t *lenp, loff_t *ppos);
307312

308313
int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
309-
char *p_name, proc_handler *proc_handler);
314+
proc_handler *proc_handler);
310315
void neigh_sysctl_unregister(struct neigh_parms *p);
311316

312317
static inline void __neigh_parms_put(struct neigh_parms *parms)

net/core/neighbour.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2947,12 +2947,13 @@ static struct neigh_sysctl_table {
29472947
};
29482948

29492949
int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
2950-
char *p_name, proc_handler *handler)
2950+
proc_handler *handler)
29512951
{
29522952
int i;
29532953
struct neigh_sysctl_table *t;
29542954
const char *dev_name_source;
29552955
char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ];
2956+
char *p_name;
29562957

29572958
t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL);
29582959
if (!t)
@@ -2991,6 +2992,17 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
29912992
if (neigh_parms_net(p)->user_ns != &init_user_ns)
29922993
t->neigh_vars[0].procname = NULL;
29932994

2995+
switch (neigh_parms_family(p)) {
2996+
case AF_INET:
2997+
p_name = "ipv4";
2998+
break;
2999+
case AF_INET6:
3000+
p_name = "ipv6";
3001+
break;
3002+
default:
3003+
BUG();
3004+
}
3005+
29943006
snprintf(neigh_path, sizeof(neigh_path), "net/%s/neigh/%s",
29953007
p_name, dev_name_source);
29963008
t->sysctl_header =

net/ipv4/arp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ void __init arp_init(void)
12871287
dev_add_pack(&arp_packet_type);
12881288
arp_proc_init();
12891289
#ifdef CONFIG_SYSCTL
1290-
neigh_sysctl_register(NULL, &arp_tbl.parms, "ipv4", NULL);
1290+
neigh_sysctl_register(NULL, &arp_tbl.parms, NULL);
12911291
#endif
12921292
register_netdevice_notifier(&arp_netdev_notifier);
12931293
}

net/ipv4/devinet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,7 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)
21602160

21612161
static void devinet_sysctl_register(struct in_device *idev)
21622162
{
2163-
neigh_sysctl_register(idev->dev, idev->arp_parms, "ipv4", NULL);
2163+
neigh_sysctl_register(idev->dev, idev->arp_parms, NULL);
21642164
__devinet_sysctl_register(dev_net(idev->dev), idev->dev->name,
21652165
&idev->cnf);
21662166
}

net/ipv6/addrconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5028,7 +5028,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)
50285028

50295029
static void addrconf_sysctl_register(struct inet6_dev *idev)
50305030
{
5031-
neigh_sysctl_register(idev->dev, idev->nd_parms, "ipv6",
5031+
neigh_sysctl_register(idev->dev, idev->nd_parms,
50325032
&ndisc_ifinfo_sysctl_change);
50335033
__addrconf_sysctl_register(dev_net(idev->dev), idev->dev->name,
50345034
idev, &idev->cnf);

net/ipv6/ndisc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1730,7 +1730,7 @@ int __init ndisc_init(void)
17301730
neigh_table_init(&nd_tbl);
17311731

17321732
#ifdef CONFIG_SYSCTL
1733-
err = neigh_sysctl_register(NULL, &nd_tbl.parms, "ipv6",
1733+
err = neigh_sysctl_register(NULL, &nd_tbl.parms,
17341734
&ndisc_ifinfo_sysctl_change);
17351735
if (err)
17361736
goto out_unregister_pernet;

0 commit comments

Comments
 (0)