Skip to content

Commit 635470e

Browse files
Joelgranadosdavem330
authored andcommitted
netfilter: Remove the now superfluous sentinel elements from ctl_table array
This commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link : https://lore.kernel.org/all/ZO5Yx5JFogGi%[email protected]/) * Remove sentinel elements from ctl_table structs * Remove instances where an array element is zeroed out to make it look like a sentinel. This is not longer needed and is safe after commit c899710 ("networking: Update to register_net_sysctl_sz") added the array size to the ctl_table registration * Remove the need for having __NF_SYSCTL_CT_LAST_SYSCTL as the sysctl array size is now in NF_SYSCTL_CT_LAST_SYSCTL * Remove extra element in ctl_table arrays declarations Acked-by: Kees Cook <[email protected]> # loadpin & yama Signed-off-by: Joel Granados <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 73dbd8c commit 635470e

File tree

7 files changed

+5
-21
lines changed

7 files changed

+5
-21
lines changed

net/bridge/br_netfilter_hooks.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,6 @@ static struct ctl_table brnf_table[] = {
12261226
.mode = 0644,
12271227
.proc_handler = brnf_sysctl_call_tables,
12281228
},
1229-
{ }
12301229
};
12311230

12321231
static inline void br_netfilter_sysctl_default(struct brnf_net *brnf)

net/ipv6/netfilter/nf_conntrack_reasm.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
6262
.mode = 0644,
6363
.proc_handler = proc_doulongvec_minmax,
6464
},
65-
{ }
6665
};
6766

6867
static int nf_ct_frag6_sysctl_register(struct net *net)

net/netfilter/ipvs/ip_vs_ctl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,6 @@ static struct ctl_table vs_vars[] = {
22632263
.proc_handler = proc_dointvec,
22642264
},
22652265
#endif
2266-
{ }
22672266
};
22682267

22692268
#endif
@@ -4286,10 +4285,8 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)
42864285
return -ENOMEM;
42874286

42884287
/* Don't export sysctls to unprivileged users */
4289-
if (net->user_ns != &init_user_ns) {
4290-
tbl[0].procname = NULL;
4288+
if (net->user_ns != &init_user_ns)
42914289
ctl_table_size = 0;
4292-
}
42934290
} else
42944291
tbl = vs_vars;
42954292
/* Initialize sysctl defaults */

net/netfilter/ipvs/ip_vs_lblc.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ static struct ctl_table vs_vars_table[] = {
123123
.mode = 0644,
124124
.proc_handler = proc_dointvec_jiffies,
125125
},
126-
{ }
127126
};
128127
#endif
129128

@@ -563,10 +562,8 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
563562
return -ENOMEM;
564563

565564
/* Don't export sysctls to unprivileged users */
566-
if (net->user_ns != &init_user_ns) {
567-
ipvs->lblc_ctl_table[0].procname = NULL;
565+
if (net->user_ns != &init_user_ns)
568566
vars_table_size = 0;
569-
}
570567

571568
} else
572569
ipvs->lblc_ctl_table = vs_vars_table;

net/netfilter/ipvs/ip_vs_lblcr.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ static struct ctl_table vs_vars_table[] = {
294294
.mode = 0644,
295295
.proc_handler = proc_dointvec_jiffies,
296296
},
297-
{ }
298297
};
299298
#endif
300299

@@ -749,10 +748,8 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
749748
return -ENOMEM;
750749

751750
/* Don't export sysctls to unprivileged users */
752-
if (net->user_ns != &init_user_ns) {
753-
ipvs->lblcr_ctl_table[0].procname = NULL;
751+
if (net->user_ns != &init_user_ns)
754752
vars_table_size = 0;
755-
}
756753
} else
757754
ipvs->lblcr_ctl_table = vs_vars_table;
758755
ipvs->sysctl_lblcr_expiration = DEFAULT_EXPIRATION;

net/netfilter/nf_conntrack_standalone.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,9 @@ enum nf_ct_sysctl_index {
616616
NF_SYSCTL_CT_LWTUNNEL,
617617
#endif
618618

619-
__NF_SYSCTL_CT_LAST_SYSCTL,
619+
NF_SYSCTL_CT_LAST_SYSCTL,
620620
};
621621

622-
#define NF_SYSCTL_CT_LAST_SYSCTL (__NF_SYSCTL_CT_LAST_SYSCTL + 1)
623-
624622
static struct ctl_table nf_ct_sysctl_table[] = {
625623
[NF_SYSCTL_CT_MAX] = {
626624
.procname = "nf_conntrack_max",
@@ -957,7 +955,6 @@ static struct ctl_table nf_ct_sysctl_table[] = {
957955
.proc_handler = nf_hooks_lwtunnel_sysctl_handler,
958956
},
959957
#endif
960-
{}
961958
};
962959

963960
static struct ctl_table nf_ct_netfilter_table[] = {
@@ -968,7 +965,6 @@ static struct ctl_table nf_ct_netfilter_table[] = {
968965
.mode = 0644,
969966
.proc_handler = proc_dointvec,
970967
},
971-
{ }
972968
};
973969

974970
static void nf_conntrack_standalone_init_tcp_sysctl(struct net *net,

net/netfilter/nf_log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static const struct seq_operations nflog_seq_ops = {
395395

396396
#ifdef CONFIG_SYSCTL
397397
static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
398-
static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
398+
static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO];
399399
static struct ctl_table_header *nf_log_sysctl_fhdr;
400400

401401
static struct ctl_table nf_log_sysctl_ftable[] = {
@@ -406,7 +406,6 @@ static struct ctl_table nf_log_sysctl_ftable[] = {
406406
.mode = 0644,
407407
.proc_handler = proc_dointvec,
408408
},
409-
{ }
410409
};
411410

412411
static int nf_log_proc_dostring(struct ctl_table *table, int write,

0 commit comments

Comments
 (0)