mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
Merge branch 'net-sysctl-sentinel'
Joel Granados says:
====================
sysctl: Remove sentinel elements from networking
What?
These commits remove the sentinel element (last empty element) from the
sysctl arrays of all the files under the "net/" directory that register
a sysctl array. The merging of the preparation patches [4] to mainline
allows us to just remove sentinel elements without changing behavior.
This is safe because the sysctl registration code (register_sysctl() and
friends) use the array size in addition to checking for a sentinel [1].
Why?
By removing the sysctl sentinel elements we avoid kernel bloat as
ctl_table arrays get moved out of kernel/sysctl.c into their own
respective subsystems. This move was started long ago to avoid merge
conflicts; the sentinel removal bit came after Mathew Wilcox suggested
it to avoid bloating the kernel by one element as arrays moved out. This
patchset will reduce the overall build time size of the kernel and run
time memory bloat by about ~64 bytes per declared ctl_table array (more
info here [5]).
When are we done?
There are 4 patchest (25 commits [2]) that are still outstanding to
completely remove the sentinels: files under "net/" (this patchset),
files under "kernel/" dir, misc dirs (files under mm/ security/ and
others) and the final set that removes the unneeded check for ->procname
== NULL.
Testing:
* Ran sysctl selftests (./tools/testing/selftests/sysctl/sysctl.sh)
* Ran this through 0-day with no errors or warnings
Savings in vmlinux:
A total of 64 bytes per sentinel is saved after removal; I measured in
x86_64 to give an idea of the aggregated savings. The actual savings
will depend on individual kernel configuration.
* bloat-o-meter
- The "yesall" config saves 3976 bytes (bloat-o-meter output [6])
- A reduced config [3] saves 1263 bytes (bloat-o-meter output [7])
Savings in allocated memory:
None in this set but will occur when the superfluous allocations are
removed from proc_sysctl.c. I include it here for context. The
estimated savings during boot for config [3] are 6272 bytes. See [8]
for how to measure it.
Comments/feedback greatly appreciated
Changes in v6:
- Rebased onto net-next/main.
- Besides re-running my cocci scripts, I ran a new find script [9].
Found 0 hits in net/
- Moved "i" variable declaraction out of for() in sysctl_core_net_init
- Removed forgotten sentinel in mpls_table
- Removed CONFIG_AX25_DAMA_SLAVE guard from net/ax25/ax25_ds_timer.c. It
is not needed because that file is compiled only when
CONFIG_AX25_DAMA_SLAVE is set.
- When traversing smc_table, stop on ARRAY_SIZE instead of ARRAY_SIZE-1.
- Link to v5: https://lore.kernel.org/r/20240426-jag-sysctl_remset_net-v5-0-e3b12f6111a6@samsung.com
Changes in v5:
- Added net files with additional variable to my test .config so the
typo can be caught next time.
- Fixed typo tabel_size -> table_size
- Link to v4: https://lore.kernel.org/r/20240425-jag-sysctl_remset_net-v4-0-9e82f985777d@samsung.com
Changes in v4:
- Keep reverse xmas tree order when introducing new variables
- Use a table_size variable to keep the value of ARRAY_SIZE
- Separated the original "networking: Remove the now superfluous
sentinel elements from ctl_table arra" into smaller commits to ease
review
- Merged x.25 and ax.25 commits together.
- Removed any SOB from the commits that were changed
- Link to v3: https://lore.kernel.org/r/20240412-jag-sysctl_remset_net-v3-0-11187d13c211@samsung.com
Changes in v3:
- Reworkded ax.25
- Added a BUILD_BUG_ON for the ax.25 commit
- Added a CONFIG_AX25_DAMA_SLAVE guard where needed
- Link to v2: https://lore.kernel.org/r/20240328-jag-sysctl_remset_net-v2-0-52c9fad9a1af@samsung.com
Changes in v2:
- Rebased to v6.9-rc1
- Removed unneeded comment from sysctl_net_ax25.c
- Link to v1: https://lore.kernel.org/r/20240314-jag-sysctl_remset_net-v1-0-aa26b44d29d9@samsung.com
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
5829614a7b
|
|
@ -139,7 +139,9 @@ enum {
|
|||
AX25_VALUES_N2, /* Default N2 value */
|
||||
AX25_VALUES_PACLEN, /* AX.25 MTU */
|
||||
AX25_VALUES_PROTOCOL, /* Std AX.25, DAMA Slave, DAMA Master */
|
||||
#ifdef CONFIG_AX25_DAMA_SLAVE
|
||||
AX25_VALUES_DS_TIMEOUT, /* DAMA Slave timeout */
|
||||
#endif
|
||||
AX25_MAX_VALUES /* THIS MUST REMAIN THE LAST ENTRY OF THIS LIST */
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ static struct ctl_table atalk_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
static struct ctl_table_header *atalk_table_header;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,10 @@ void ax25_dev_device_up(struct net_device *dev)
|
|||
ax25_dev->values[AX25_VALUES_N2] = AX25_DEF_N2;
|
||||
ax25_dev->values[AX25_VALUES_PACLEN] = AX25_DEF_PACLEN;
|
||||
ax25_dev->values[AX25_VALUES_PROTOCOL] = AX25_DEF_PROTOCOL;
|
||||
|
||||
#ifdef CONFIG_AX25_DAMA_SLAVE
|
||||
ax25_dev->values[AX25_VALUES_DS_TIMEOUT]= AX25_DEF_DS_TIMEOUT;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_AX25_DAMA_SLAVE) || defined(CONFIG_AX25_DAMA_MASTER)
|
||||
ax25_ds_setup_timer(ax25_dev);
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ void ax25_ds_set_timer(ax25_dev *ax25_dev)
|
|||
ax25_dev->dama.slave_timeout =
|
||||
msecs_to_jiffies(ax25_dev->values[AX25_VALUES_DS_TIMEOUT]) / 10;
|
||||
mod_timer(&ax25_dev->dama.slave_timer, jiffies + HZ);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -141,8 +141,6 @@ static const struct ctl_table ax25_param_table[] = {
|
|||
.extra2 = &max_ds_timeout
|
||||
},
|
||||
#endif
|
||||
|
||||
{ } /* that's all, folks! */
|
||||
};
|
||||
|
||||
int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
|
||||
|
|
@ -155,6 +153,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
|
|||
if (!table)
|
||||
return -ENOMEM;
|
||||
|
||||
BUILD_BUG_ON(ARRAY_SIZE(ax25_param_table) != AX25_MAX_VALUES);
|
||||
for (k = 0; k < AX25_MAX_VALUES; k++)
|
||||
table[k].data = &ax25_dev->values[k];
|
||||
|
||||
|
|
|
|||
|
|
@ -1226,7 +1226,6 @@ static struct ctl_table brnf_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = brnf_sysctl_call_tables,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static inline void br_netfilter_sysctl_default(struct brnf_net *brnf)
|
||||
|
|
|
|||
|
|
@ -3733,7 +3733,7 @@ static int neigh_proc_base_reachable_time(struct ctl_table *ctl, int write,
|
|||
|
||||
static struct neigh_sysctl_table {
|
||||
struct ctl_table_header *sysctl_header;
|
||||
struct ctl_table neigh_vars[NEIGH_VAR_MAX + 1];
|
||||
struct ctl_table neigh_vars[NEIGH_VAR_MAX];
|
||||
} neigh_sysctl_template __read_mostly = {
|
||||
.neigh_vars = {
|
||||
NEIGH_SYSCTL_ZERO_INTMAX_ENTRY(MCAST_PROBES, "mcast_solicit"),
|
||||
|
|
@ -3784,7 +3784,6 @@ static struct neigh_sysctl_table {
|
|||
.extra2 = SYSCTL_INT_MAX,
|
||||
.proc_handler = proc_dointvec_minmax,
|
||||
},
|
||||
{},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -3812,8 +3811,6 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
|
|||
if (dev) {
|
||||
dev_name_source = dev->name;
|
||||
/* Terminate the table early */
|
||||
memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0,
|
||||
sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL]));
|
||||
neigh_vars_size = NEIGH_VAR_BASE_REACHABLE_TIME_MS + 1;
|
||||
} else {
|
||||
struct neigh_table *tbl = p->tbl;
|
||||
|
|
|
|||
|
|
@ -661,7 +661,6 @@ static struct ctl_table net_core_table[] = {
|
|||
.proc_handler = proc_dointvec_minmax,
|
||||
.extra1 = SYSCTL_ZERO,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct ctl_table netns_core_table[] = {
|
||||
|
|
@ -698,7 +697,6 @@ static struct ctl_table netns_core_table[] = {
|
|||
.extra2 = SYSCTL_ONE,
|
||||
.proc_handler = proc_dou8vec_minmax,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init fb_tunnels_only_for_init_net_sysctl_setup(char *str)
|
||||
|
|
@ -716,20 +714,21 @@ __setup("fb_tunnels=", fb_tunnels_only_for_init_net_sysctl_setup);
|
|||
|
||||
static __net_init int sysctl_core_net_init(struct net *net)
|
||||
{
|
||||
struct ctl_table *tbl, *tmp;
|
||||
size_t table_size = ARRAY_SIZE(netns_core_table);
|
||||
struct ctl_table *tbl;
|
||||
|
||||
tbl = netns_core_table;
|
||||
if (!net_eq(net, &init_net)) {
|
||||
int i;
|
||||
tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
|
||||
if (tbl == NULL)
|
||||
goto err_dup;
|
||||
|
||||
for (tmp = tbl; tmp->procname; tmp++)
|
||||
tmp->data += (char *)net - (char *)&init_net;
|
||||
for (i = 0; i < table_size; ++i)
|
||||
tbl[i].data += (char *)net - (char *)&init_net;
|
||||
}
|
||||
|
||||
net->core.sysctl_hdr = register_net_sysctl_sz(net, "net/core", tbl,
|
||||
ARRAY_SIZE(netns_core_table));
|
||||
net->core.sysctl_hdr = register_net_sysctl_sz(net, "net/core", tbl, table_size);
|
||||
if (net->core.sysctl_hdr == NULL)
|
||||
goto err_reg;
|
||||
|
||||
|
|
|
|||
|
|
@ -90,8 +90,6 @@ static struct ctl_table dccp_default_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_ms_jiffies,
|
||||
},
|
||||
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct ctl_table_header *dccp_table_header;
|
||||
|
|
|
|||
|
|
@ -338,7 +338,6 @@ static struct ctl_table lowpan_frags_ns_ctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
/* secret interval has been deprecated */
|
||||
|
|
@ -351,7 +350,6 @@ static struct ctl_table lowpan_frags_ctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
|
||||
|
|
@ -370,10 +368,8 @@ static int __net_init lowpan_frags_ns_sysctl_register(struct net *net)
|
|||
goto err_alloc;
|
||||
|
||||
/* Don't export sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns) {
|
||||
table[0].procname = NULL;
|
||||
if (net->user_ns != &init_user_ns)
|
||||
table_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
table[0].data = &ieee802154_lowpan->fqdir->high_thresh;
|
||||
|
|
|
|||
|
|
@ -2520,7 +2520,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
|
|||
|
||||
static struct devinet_sysctl_table {
|
||||
struct ctl_table_header *sysctl_header;
|
||||
struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
|
||||
struct ctl_table devinet_vars[IPV4_DEVCONF_MAX];
|
||||
} devinet_sysctl = {
|
||||
.devinet_vars = {
|
||||
DEVINET_SYSCTL_COMPLEX_ENTRY(FORWARDING, "forwarding",
|
||||
|
|
@ -2583,7 +2583,7 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name,
|
|||
if (!t)
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
|
||||
for (i = 0; i < ARRAY_SIZE(t->devinet_vars); i++) {
|
||||
t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
|
||||
t->devinet_vars[i].extra1 = p;
|
||||
t->devinet_vars[i].extra2 = net;
|
||||
|
|
@ -2657,7 +2657,6 @@ static struct ctl_table ctl_forward_entry[] = {
|
|||
.extra1 = &ipv4_devconf,
|
||||
.extra2 = &init_net,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -580,7 +580,6 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = {
|
|||
.proc_handler = proc_dointvec_minmax,
|
||||
.extra1 = &dist_min,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
/* secret interval has been deprecated */
|
||||
|
|
@ -593,7 +592,6 @@ static struct ctl_table ip4_frags_ctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __net_init ip4_frags_ns_ctl_register(struct net *net)
|
||||
|
|
|
|||
|
|
@ -3496,7 +3496,6 @@ static struct ctl_table ipv4_route_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static const char ipv4_route_flush_procname[] = "flush";
|
||||
|
|
@ -3530,7 +3529,6 @@ static struct ctl_table ipv4_route_netns_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
static __net_init int sysctl_route_net_init(struct net *net)
|
||||
|
|
@ -3548,16 +3546,14 @@ static __net_init int sysctl_route_net_init(struct net *net)
|
|||
|
||||
/* Don't export non-whitelisted sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns) {
|
||||
if (tbl[0].procname != ipv4_route_flush_procname) {
|
||||
tbl[0].procname = NULL;
|
||||
if (tbl[0].procname != ipv4_route_flush_procname)
|
||||
table_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the variables to point into the current struct net
|
||||
* except for the first element flush
|
||||
*/
|
||||
for (i = 1; i < ARRAY_SIZE(ipv4_route_netns_table) - 1; i++)
|
||||
for (i = 1; i < table_size; i++)
|
||||
tbl[i].data += (void *)net - (void *)&init_net;
|
||||
}
|
||||
tbl[0].extra1 = net;
|
||||
|
|
|
|||
|
|
@ -575,7 +575,6 @@ static struct ctl_table ipv4_table[] = {
|
|||
.extra1 = &sysctl_fib_sync_mem_min,
|
||||
.extra2 = &sysctl_fib_sync_mem_max,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct ctl_table ipv4_net_table[] = {
|
||||
|
|
@ -1502,11 +1501,11 @@ static struct ctl_table ipv4_net_table[] = {
|
|||
.proc_handler = proc_dou8vec_minmax,
|
||||
.extra1 = SYSCTL_ONE,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static __net_init int ipv4_sysctl_init_net(struct net *net)
|
||||
{
|
||||
size_t table_size = ARRAY_SIZE(ipv4_net_table);
|
||||
struct ctl_table *table;
|
||||
|
||||
table = ipv4_net_table;
|
||||
|
|
@ -1517,7 +1516,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
|
|||
if (!table)
|
||||
goto err_alloc;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) {
|
||||
for (i = 0; i < table_size; i++) {
|
||||
if (table[i].data) {
|
||||
/* Update the variables to point into
|
||||
* the current struct net
|
||||
|
|
@ -1533,7 +1532,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
|
|||
}
|
||||
|
||||
net->ipv4.ipv4_hdr = register_net_sysctl_sz(net, "net/ipv4", table,
|
||||
ARRAY_SIZE(ipv4_net_table));
|
||||
table_size);
|
||||
if (!net->ipv4.ipv4_hdr)
|
||||
goto err_reg;
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ static struct ctl_table xfrm4_policy_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static __net_init int xfrm4_net_sysctl_init(struct net *net)
|
||||
|
|
|
|||
|
|
@ -7184,14 +7184,12 @@ static const struct ctl_table addrconf_sysctl[] = {
|
|||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_TWO,
|
||||
},
|
||||
{
|
||||
/* sentinel */
|
||||
}
|
||||
};
|
||||
|
||||
static int __addrconf_sysctl_register(struct net *net, char *dev_name,
|
||||
struct inet6_dev *idev, struct ipv6_devconf *p)
|
||||
{
|
||||
size_t table_size = ARRAY_SIZE(addrconf_sysctl);
|
||||
int i, ifindex;
|
||||
struct ctl_table *table;
|
||||
char path[sizeof("net/ipv6/conf/") + IFNAMSIZ];
|
||||
|
|
@ -7200,7 +7198,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
|
|||
if (!table)
|
||||
goto out;
|
||||
|
||||
for (i = 0; table[i].data; i++) {
|
||||
for (i = 0; i < table_size; i++) {
|
||||
table[i].data += (char *)p - (char *)&ipv6_devconf;
|
||||
/* If one of these is already set, then it is not safe to
|
||||
* overwrite either of them: this makes proc_dointvec_minmax
|
||||
|
|
@ -7215,7 +7213,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
|
|||
snprintf(path, sizeof(path), "net/ipv6/conf/%s", dev_name);
|
||||
|
||||
p->sysctl_header = register_net_sysctl_sz(net, path, table,
|
||||
ARRAY_SIZE(addrconf_sysctl));
|
||||
table_size);
|
||||
if (!p->sysctl_header)
|
||||
goto free;
|
||||
|
||||
|
|
|
|||
|
|
@ -1206,7 +1206,6 @@ static struct ctl_table ipv6_icmp_table_template[] = {
|
|||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_ONE,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_doulongvec_minmax,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int nf_ct_frag6_sysctl_register(struct net *net)
|
||||
|
|
|
|||
|
|
@ -436,7 +436,6 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
/* secret interval has been deprecated */
|
||||
|
|
@ -449,7 +448,6 @@ static struct ctl_table ip6_frags_ctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
|
||||
|
|
|
|||
|
|
@ -6428,7 +6428,6 @@ static struct ctl_table ipv6_route_table_template[] = {
|
|||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_ONE,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
|
||||
|
|
@ -6452,10 +6451,6 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
|
|||
table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
|
||||
table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
|
||||
table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
|
||||
|
||||
/* Don't export sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns)
|
||||
table[1].procname = NULL;
|
||||
}
|
||||
|
||||
return table;
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ static struct ctl_table ipv6_table_template[] = {
|
|||
.proc_handler = proc_doulongvec_minmax,
|
||||
.extra2 = &ioam6_id_wide_max,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct ctl_table ipv6_rotable[] = {
|
||||
|
|
@ -248,11 +247,11 @@ static struct ctl_table ipv6_rotable[] = {
|
|||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
#endif /* CONFIG_NETLABEL */
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __net_init ipv6_sysctl_net_init(struct net *net)
|
||||
{
|
||||
size_t table_size = ARRAY_SIZE(ipv6_table_template);
|
||||
struct ctl_table *ipv6_table;
|
||||
struct ctl_table *ipv6_route_table;
|
||||
struct ctl_table *ipv6_icmp_table;
|
||||
|
|
@ -264,7 +263,7 @@ static int __net_init ipv6_sysctl_net_init(struct net *net)
|
|||
if (!ipv6_table)
|
||||
goto out;
|
||||
/* Update the variables to point into the current struct net */
|
||||
for (i = 0; i < ARRAY_SIZE(ipv6_table_template) - 1; i++)
|
||||
for (i = 0; i < table_size; i++)
|
||||
ipv6_table[i].data += (void *)net - (void *)&init_net;
|
||||
|
||||
ipv6_route_table = ipv6_route_sysctl_init(net);
|
||||
|
|
@ -276,8 +275,7 @@ static int __net_init ipv6_sysctl_net_init(struct net *net)
|
|||
goto out_ipv6_route_table;
|
||||
|
||||
net->ipv6.sysctl.hdr = register_net_sysctl_sz(net, "net/ipv6",
|
||||
ipv6_table,
|
||||
ARRAY_SIZE(ipv6_table_template));
|
||||
ipv6_table, table_size);
|
||||
if (!net->ipv6.sysctl.hdr)
|
||||
goto out_ipv6_icmp_table;
|
||||
|
||||
|
|
|
|||
|
|
@ -184,7 +184,6 @@ static struct ctl_table xfrm6_policy_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __net_init xfrm6_net_sysctl_init(struct net *net)
|
||||
|
|
|
|||
|
|
@ -44,11 +44,6 @@ static struct ctl_table llc2_timeout_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
static struct ctl_table llc_station_table[] = {
|
||||
{ },
|
||||
};
|
||||
|
||||
static struct ctl_table_header *llc2_timeout_header;
|
||||
|
|
@ -56,8 +51,9 @@ static struct ctl_table_header *llc_station_header;
|
|||
|
||||
int __init llc_sysctl_init(void)
|
||||
{
|
||||
struct ctl_table empty[1] = {};
|
||||
llc2_timeout_header = register_net_sysctl(&init_net, "net/llc/llc2/timeout", llc2_timeout_table);
|
||||
llc_station_header = register_net_sysctl(&init_net, "net/llc/station", llc_station_table);
|
||||
llc_station_header = register_net_sysctl_sz(&init_net, "net/llc/station", empty, 0);
|
||||
|
||||
if (!llc2_timeout_header || !llc_station_header) {
|
||||
llc_sysctl_exit();
|
||||
|
|
|
|||
|
|
@ -1377,13 +1377,13 @@ static const struct ctl_table mpls_dev_table[] = {
|
|||
.proc_handler = mpls_conf_proc,
|
||||
.data = MPLS_PERDEV_SYSCTL_OFFSET(input_enabled),
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int mpls_dev_sysctl_register(struct net_device *dev,
|
||||
struct mpls_dev *mdev)
|
||||
{
|
||||
char path[sizeof("net/mpls/conf/") + IFNAMSIZ];
|
||||
size_t table_size = ARRAY_SIZE(mpls_dev_table);
|
||||
struct net *net = dev_net(dev);
|
||||
struct ctl_table *table;
|
||||
int i;
|
||||
|
|
@ -1395,7 +1395,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
|
|||
/* Table data contains only offsets relative to the base of
|
||||
* the mdev at this point, so make them absolute.
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(mpls_dev_table); i++) {
|
||||
for (i = 0; i < table_size; i++) {
|
||||
table[i].data = (char *)mdev + (uintptr_t)table[i].data;
|
||||
table[i].extra1 = mdev;
|
||||
table[i].extra2 = net;
|
||||
|
|
@ -1403,8 +1403,7 @@ static int mpls_dev_sysctl_register(struct net_device *dev,
|
|||
|
||||
snprintf(path, sizeof(path), "net/mpls/conf/%s", dev->name);
|
||||
|
||||
mdev->sysctl = register_net_sysctl_sz(net, path, table,
|
||||
ARRAY_SIZE(mpls_dev_table));
|
||||
mdev->sysctl = register_net_sysctl_sz(net, path, table, table_size);
|
||||
if (!mdev->sysctl)
|
||||
goto free;
|
||||
|
||||
|
|
@ -2653,11 +2652,11 @@ static const struct ctl_table mpls_table[] = {
|
|||
.extra1 = SYSCTL_ONE,
|
||||
.extra2 = &ttl_max,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int mpls_net_init(struct net *net)
|
||||
{
|
||||
size_t table_size = ARRAY_SIZE(mpls_table);
|
||||
struct ctl_table *table;
|
||||
int i;
|
||||
|
||||
|
|
@ -2673,11 +2672,11 @@ static int mpls_net_init(struct net *net)
|
|||
/* Table data contains only offsets relative to the base of
|
||||
* the mdev at this point, so make them absolute.
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(mpls_table) - 1; i++)
|
||||
for (i = 0; i < table_size; i++)
|
||||
table[i].data = (char *)net + (uintptr_t)table[i].data;
|
||||
|
||||
net->mpls.ctl = register_net_sysctl_sz(net, "net/mpls", table,
|
||||
ARRAY_SIZE(mpls_table));
|
||||
table_size);
|
||||
if (net->mpls.ctl == NULL) {
|
||||
kfree(table);
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -156,7 +156,6 @@ static struct ctl_table mptcp_sysctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet)
|
||||
|
|
|
|||
|
|
@ -2263,7 +2263,6 @@ static struct ctl_table vs_vars[] = {
|
|||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
#endif
|
||||
{ }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -4286,10 +4285,8 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)
|
|||
return -ENOMEM;
|
||||
|
||||
/* Don't export sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns) {
|
||||
tbl[0].procname = NULL;
|
||||
if (net->user_ns != &init_user_ns)
|
||||
ctl_table_size = 0;
|
||||
}
|
||||
} else
|
||||
tbl = vs_vars;
|
||||
/* Initialize sysctl defaults */
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ static struct ctl_table vs_vars_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
@ -563,10 +562,8 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
|
|||
return -ENOMEM;
|
||||
|
||||
/* Don't export sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns) {
|
||||
ipvs->lblc_ctl_table[0].procname = NULL;
|
||||
if (net->user_ns != &init_user_ns)
|
||||
vars_table_size = 0;
|
||||
}
|
||||
|
||||
} else
|
||||
ipvs->lblc_ctl_table = vs_vars_table;
|
||||
|
|
|
|||
|
|
@ -294,7 +294,6 @@ static struct ctl_table vs_vars_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
@ -749,10 +748,8 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
|
|||
return -ENOMEM;
|
||||
|
||||
/* Don't export sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns) {
|
||||
ipvs->lblcr_ctl_table[0].procname = NULL;
|
||||
if (net->user_ns != &init_user_ns)
|
||||
vars_table_size = 0;
|
||||
}
|
||||
} else
|
||||
ipvs->lblcr_ctl_table = vs_vars_table;
|
||||
ipvs->sysctl_lblcr_expiration = DEFAULT_EXPIRATION;
|
||||
|
|
|
|||
|
|
@ -616,11 +616,9 @@ enum nf_ct_sysctl_index {
|
|||
NF_SYSCTL_CT_LWTUNNEL,
|
||||
#endif
|
||||
|
||||
__NF_SYSCTL_CT_LAST_SYSCTL,
|
||||
NF_SYSCTL_CT_LAST_SYSCTL,
|
||||
};
|
||||
|
||||
#define NF_SYSCTL_CT_LAST_SYSCTL (__NF_SYSCTL_CT_LAST_SYSCTL + 1)
|
||||
|
||||
static struct ctl_table nf_ct_sysctl_table[] = {
|
||||
[NF_SYSCTL_CT_MAX] = {
|
||||
.procname = "nf_conntrack_max",
|
||||
|
|
@ -957,7 +955,6 @@ static struct ctl_table nf_ct_sysctl_table[] = {
|
|||
.proc_handler = nf_hooks_lwtunnel_sysctl_handler,
|
||||
},
|
||||
#endif
|
||||
{}
|
||||
};
|
||||
|
||||
static struct ctl_table nf_ct_netfilter_table[] = {
|
||||
|
|
@ -968,7 +965,6 @@ static struct ctl_table nf_ct_netfilter_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static void nf_conntrack_standalone_init_tcp_sysctl(struct net *net,
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ static const struct seq_operations nflog_seq_ops = {
|
|||
|
||||
#ifdef CONFIG_SYSCTL
|
||||
static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
|
||||
static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
|
||||
static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO];
|
||||
static struct ctl_table_header *nf_log_sysctl_fhdr;
|
||||
|
||||
static struct ctl_table nf_log_sysctl_ftable[] = {
|
||||
|
|
@ -406,7 +406,6 @@ static struct ctl_table nf_log_sysctl_ftable[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int nf_log_proc_dostring(struct ctl_table *table, int write,
|
||||
|
|
|
|||
|
|
@ -140,7 +140,6 @@ static struct ctl_table nr_table[] = {
|
|||
.extra1 = &min_reset,
|
||||
.extra2 = &max_reset
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
int __init nr_register_sysctl(void)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ static struct ctl_table phonet_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_local_port_range,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
int __init phonet_sysctl_init(void)
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ static struct ctl_table rds_ib_sysctl_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
void rds_ib_sysctl_exit(void)
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ static struct ctl_table rds_sysctl_rds_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
void rds_sysctl_exit(void)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ static struct ctl_table rds_tcp_sysctl_table[] = {
|
|||
.proc_handler = rds_tcp_skbuf_handler,
|
||||
.extra1 = &rds_tcp_min_rcvbuf,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
u32 rds_tcp_write_seq(struct rds_tcp_connection *tc)
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ static struct ctl_table rose_table[] = {
|
|||
.extra1 = &min_window,
|
||||
.extra2 = &max_window
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
void __init rose_register_sysctl(void)
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ static struct ctl_table rxrpc_sysctl_table[] = {
|
|||
.extra1 = (void *)SYSCTL_ONE,
|
||||
.extra2 = (void *)&four,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
int __init rxrpc_sysctl_init(void)
|
||||
|
|
|
|||
|
|
@ -80,8 +80,6 @@ static struct ctl_table sctp_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
/* The following index defines are used in sctp_sysctl_net_register().
|
||||
|
|
@ -384,8 +382,6 @@ static struct ctl_table sctp_net_table[] = {
|
|||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = &pf_expose_max,
|
||||
},
|
||||
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
|
||||
|
|
@ -597,6 +593,7 @@ static int proc_sctp_do_probe_interval(struct ctl_table *ctl, int write,
|
|||
|
||||
int sctp_sysctl_net_register(struct net *net)
|
||||
{
|
||||
size_t table_size = ARRAY_SIZE(sctp_net_table);
|
||||
struct ctl_table *table;
|
||||
int i;
|
||||
|
||||
|
|
@ -604,7 +601,7 @@ int sctp_sysctl_net_register(struct net *net)
|
|||
if (!table)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; table[i].data; i++)
|
||||
for (i = 0; i < table_size; i++)
|
||||
table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
|
||||
|
||||
table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max;
|
||||
|
|
@ -613,8 +610,7 @@ int sctp_sysctl_net_register(struct net *net)
|
|||
table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans;
|
||||
|
||||
net->sctp.sysctl_header = register_net_sysctl_sz(net, "net/sctp",
|
||||
table,
|
||||
ARRAY_SIZE(sctp_net_table));
|
||||
table, table_size);
|
||||
if (net->sctp.sysctl_header == NULL) {
|
||||
kfree(table);
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -90,11 +90,11 @@ static struct ctl_table smc_table[] = {
|
|||
.extra1 = &conns_per_lgr_min,
|
||||
.extra2 = &conns_per_lgr_max,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
int __net_init smc_sysctl_net_init(struct net *net)
|
||||
{
|
||||
size_t table_size = ARRAY_SIZE(smc_table);
|
||||
struct ctl_table *table;
|
||||
|
||||
table = smc_table;
|
||||
|
|
@ -105,12 +105,12 @@ int __net_init smc_sysctl_net_init(struct net *net)
|
|||
if (!table)
|
||||
goto err_alloc;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++)
|
||||
for (i = 0; i < table_size; i++)
|
||||
table[i].data += (void *)net - (void *)&init_net;
|
||||
}
|
||||
|
||||
net->smc.smc_hdr = register_net_sysctl_sz(net, "net/smc", table,
|
||||
ARRAY_SIZE(smc_table));
|
||||
table_size);
|
||||
if (!net->smc.smc_hdr)
|
||||
goto err_reg;
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ static struct ctl_table debug_table[] = {
|
|||
.mode = 0444,
|
||||
.proc_handler = proc_do_xprt,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -209,7 +209,6 @@ static struct ctl_table svcrdma_parm_table[] = {
|
|||
.extra1 = &zero,
|
||||
.extra2 = &zero,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
static void svc_rdma_proc_cleanup(void)
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@ static struct ctl_table xr_tunables_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -160,7 +160,6 @@ static struct ctl_table xs_tunables_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_jiffies,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ static struct ctl_table tipc_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_doulongvec_minmax,
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
int tipc_register_sysctl(void)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ static struct ctl_table unix_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
int __net_init unix_sysctl_register(struct net *net)
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ static struct ctl_table x25_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
|
||||
int __init x25_register_sysctl(void)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ static struct ctl_table xfrm_table[] = {
|
|||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
int __net_init xfrm_sysctl_init(struct net *net)
|
||||
|
|
@ -57,10 +56,8 @@ int __net_init xfrm_sysctl_init(struct net *net)
|
|||
table[3].data = &net->xfrm.sysctl_acq_expires;
|
||||
|
||||
/* Don't export sysctls to unprivileged users */
|
||||
if (net->user_ns != &init_user_ns) {
|
||||
table[0].procname = NULL;
|
||||
if (net->user_ns != &init_user_ns)
|
||||
table_size = 0;
|
||||
}
|
||||
|
||||
net->xfrm.sysctl_hdr = register_net_sysctl_sz(net, "net/core", table,
|
||||
table_size);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user