Skip to content

Commit d12af67

Browse files
ebiedermLinus Torvalds
authored andcommitted
sysctl: fix neighbour table sysctls.
- In ipv6 ndisc_ifinfo_syctl_change so it doesn't depend on binary sysctl names for a function that works with proc. - In neighbour.c reorder the table to put the possibly unused entries at the end so we can remove them by terminating the table early. - In neighbour.c kill the entries with questionable binary sysctl handling behavior. - In neighbour.c if we don't have a strategy routine remove the binary path. So we don't the default sysctl strategy routine on data that is not ready for it. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Alexey Dobriyan <adobriyan@sw.ru> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f5ead5c commit d12af67

2 files changed

Lines changed: 49 additions & 50 deletions

File tree

‎net/core/neighbour.c‎

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,6 @@ static struct neigh_sysctl_table {
24962496
.proc_handler = &proc_dointvec,
24972497
},
24982498
{
2499-
.ctl_name = NET_NEIGH_RETRANS_TIME,
25002499
.procname = "retrans_time",
25012500
.maxlen = sizeof(int),
25022501
.mode = 0644,
@@ -2541,26 +2540,39 @@ static struct neigh_sysctl_table {
25412540
.proc_handler = &proc_dointvec,
25422541
},
25432542
{
2544-
.ctl_name = NET_NEIGH_ANYCAST_DELAY,
25452543
.procname = "anycast_delay",
25462544
.maxlen = sizeof(int),
25472545
.mode = 0644,
25482546
.proc_handler = &proc_dointvec_userhz_jiffies,
25492547
},
25502548
{
2551-
.ctl_name = NET_NEIGH_PROXY_DELAY,
25522549
.procname = "proxy_delay",
25532550
.maxlen = sizeof(int),
25542551
.mode = 0644,
25552552
.proc_handler = &proc_dointvec_userhz_jiffies,
25562553
},
25572554
{
2558-
.ctl_name = NET_NEIGH_LOCKTIME,
25592555
.procname = "locktime",
25602556
.maxlen = sizeof(int),
25612557
.mode = 0644,
25622558
.proc_handler = &proc_dointvec_userhz_jiffies,
25632559
},
2560+
{
2561+
.ctl_name = NET_NEIGH_RETRANS_TIME_MS,
2562+
.procname = "retrans_time_ms",
2563+
.maxlen = sizeof(int),
2564+
.mode = 0644,
2565+
.proc_handler = &proc_dointvec_ms_jiffies,
2566+
.strategy = &sysctl_ms_jiffies,
2567+
},
2568+
{
2569+
.ctl_name = NET_NEIGH_REACHABLE_TIME_MS,
2570+
.procname = "base_reachable_time_ms",
2571+
.maxlen = sizeof(int),
2572+
.mode = 0644,
2573+
.proc_handler = &proc_dointvec_ms_jiffies,
2574+
.strategy = &sysctl_ms_jiffies,
2575+
},
25642576
{
25652577
.ctl_name = NET_NEIGH_GC_INTERVAL,
25662578
.procname = "gc_interval",
@@ -2590,22 +2602,7 @@ static struct neigh_sysctl_table {
25902602
.mode = 0644,
25912603
.proc_handler = &proc_dointvec,
25922604
},
2593-
{
2594-
.ctl_name = NET_NEIGH_RETRANS_TIME_MS,
2595-
.procname = "retrans_time_ms",
2596-
.maxlen = sizeof(int),
2597-
.mode = 0644,
2598-
.proc_handler = &proc_dointvec_ms_jiffies,
2599-
.strategy = &sysctl_ms_jiffies,
2600-
},
2601-
{
2602-
.ctl_name = NET_NEIGH_REACHABLE_TIME_MS,
2603-
.procname = "base_reachable_time_ms",
2604-
.maxlen = sizeof(int),
2605-
.mode = 0644,
2606-
.proc_handler = &proc_dointvec_ms_jiffies,
2607-
.strategy = &sysctl_ms_jiffies,
2608-
},
2605+
{}
26092606
},
26102607
.neigh_dev = {
26112608
{
@@ -2658,42 +2655,48 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
26582655
t->neigh_vars[9].data = &p->anycast_delay;
26592656
t->neigh_vars[10].data = &p->proxy_delay;
26602657
t->neigh_vars[11].data = &p->locktime;
2658+
t->neigh_vars[12].data = &p->retrans_time;
2659+
t->neigh_vars[13].data = &p->base_reachable_time;
26612660

26622661
if (dev) {
26632662
dev_name_source = dev->name;
26642663
t->neigh_dev[0].ctl_name = dev->ifindex;
2665-
t->neigh_vars[12].procname = NULL;
2666-
t->neigh_vars[13].procname = NULL;
2667-
t->neigh_vars[14].procname = NULL;
2668-
t->neigh_vars[15].procname = NULL;
2664+
/* Terminate the table early */
2665+
memset(&t->neigh_vars[14], 0, sizeof(t->neigh_vars[14]));
26692666
} else {
26702667
dev_name_source = t->neigh_dev[0].procname;
2671-
t->neigh_vars[12].data = (int *)(p + 1);
2672-
t->neigh_vars[13].data = (int *)(p + 1) + 1;
2673-
t->neigh_vars[14].data = (int *)(p + 1) + 2;
2674-
t->neigh_vars[15].data = (int *)(p + 1) + 3;
2668+
t->neigh_vars[14].data = (int *)(p + 1);
2669+
t->neigh_vars[15].data = (int *)(p + 1) + 1;
2670+
t->neigh_vars[16].data = (int *)(p + 1) + 2;
2671+
t->neigh_vars[17].data = (int *)(p + 1) + 3;
26752672
}
26762673

2677-
t->neigh_vars[16].data = &p->retrans_time;
2678-
t->neigh_vars[17].data = &p->base_reachable_time;
26792674

26802675
if (handler || strategy) {
26812676
/* RetransTime */
26822677
t->neigh_vars[3].proc_handler = handler;
26832678
t->neigh_vars[3].strategy = strategy;
26842679
t->neigh_vars[3].extra1 = dev;
2680+
if (!strategy)
2681+
t->neigh_vars[3].ctl_name = CTL_UNNUMBERED;
26852682
/* ReachableTime */
26862683
t->neigh_vars[4].proc_handler = handler;
26872684
t->neigh_vars[4].strategy = strategy;
26882685
t->neigh_vars[4].extra1 = dev;
2686+
if (!strategy)
2687+
t->neigh_vars[4].ctl_name = CTL_UNNUMBERED;
26892688
/* RetransTime (in milliseconds)*/
2690-
t->neigh_vars[16].proc_handler = handler;
2691-
t->neigh_vars[16].strategy = strategy;
2692-
t->neigh_vars[16].extra1 = dev;
2689+
t->neigh_vars[12].proc_handler = handler;
2690+
t->neigh_vars[12].strategy = strategy;
2691+
t->neigh_vars[12].extra1 = dev;
2692+
if (!strategy)
2693+
t->neigh_vars[12].ctl_name = CTL_UNNUMBERED;
26932694
/* ReachableTime (in milliseconds) */
2694-
t->neigh_vars[17].proc_handler = handler;
2695-
t->neigh_vars[17].strategy = strategy;
2696-
t->neigh_vars[17].extra1 = dev;
2695+
t->neigh_vars[13].proc_handler = handler;
2696+
t->neigh_vars[13].strategy = strategy;
2697+
t->neigh_vars[13].extra1 = dev;
2698+
if (!strategy)
2699+
t->neigh_vars[13].ctl_name = CTL_UNNUMBERED;
26972700
}
26982701

26992702
dev_name = kstrdup(dev_name_source, GFP_KERNEL);

‎net/ipv6/ndisc.c‎

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,30 +1658,26 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, struct file * f
16581658
struct inet6_dev *idev;
16591659
int ret;
16601660

1661-
if (ctl->ctl_name == NET_NEIGH_RETRANS_TIME ||
1662-
ctl->ctl_name == NET_NEIGH_REACHABLE_TIME)
1661+
if ((strcmp(ctl->procname, "retrans_time") == 0) ||
1662+
(strcmp(ctl->procname, "base_reachable_time") == 0))
16631663
ndisc_warn_deprecated_sysctl(ctl, "syscall", dev ? dev->name : "default");
16641664

1665-
switch (ctl->ctl_name) {
1666-
case NET_NEIGH_RETRANS_TIME:
1665+
if (strcmp(ctl->procname, "retrans_time") == 0)
16671666
ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
1668-
break;
1669-
case NET_NEIGH_REACHABLE_TIME:
1667+
1668+
else if (strcmp(ctl->procname, "base_reachable_time") == 0)
16701669
ret = proc_dointvec_jiffies(ctl, write,
16711670
filp, buffer, lenp, ppos);
1672-
break;
1673-
case NET_NEIGH_RETRANS_TIME_MS:
1674-
case NET_NEIGH_REACHABLE_TIME_MS:
1671+
1672+
else if ((strcmp(ctl->procname, "retrans_time_ms") == 0) ||
1673+
(strcmp(ctl->procname, "base_reacable_time_ms") == 0))
16751674
ret = proc_dointvec_ms_jiffies(ctl, write,
16761675
filp, buffer, lenp, ppos);
1677-
break;
1678-
default:
1676+
else
16791677
ret = -1;
1680-
}
16811678

16821679
if (write && ret == 0 && dev && (idev = in6_dev_get(dev)) != NULL) {
1683-
if (ctl->ctl_name == NET_NEIGH_REACHABLE_TIME ||
1684-
ctl->ctl_name == NET_NEIGH_REACHABLE_TIME_MS)
1680+
if (ctl->data == &idev->nd_parms->base_reachable_time)
16851681
idev->nd_parms->reachable_time = neigh_rand_reach_time(idev->nd_parms->base_reachable_time);
16861682
idev->tstamp = jiffies;
16871683
inet6_ifinfo_notify(RTM_NEWLINK, idev);

0 commit comments

Comments
 (0)