Skip to contentSkip to conversation

AX.25: Fix sysctl registration if !CONFIG_AX25_DAMA_SLAVE

PATCH Applied Ralf Baechle 4 participants 4 messages Aug 5, 2008 – Aug 6, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 AX.25: Fix sysctl registration if !CONFIG_AX25_DAMA_SLAVE

Since 49ffcf8f99e8d33ec8afb450956804af518fd788
setting struct ctl_table.procname = NULL does no longer work as it used to the way the AX.25 code is expecting it to resulting in the AX.25 sysctl registration code to break if CONFIG_AX25_DAMA_SLAVE was not set as in some distribution kernels. Kernel releases from 2.6.24 are affected.

net/ax25/sysctl_net_ax25.c +4 -10
index f597987..f288fc4 100644
@@ -36,6 +36,7 @@ static struct ctl_path ax25_path[] = {
 	{ .procname = "ax25", .ctl_name = NET_AX25, },
 	{ }
 };
+
 static const ctl_table ax25_param_table[] = {
 	{
 		.ctl_name	= NET_AX25_IP_DEFAULT_MODE,
@@ -167,6 +168,7 @@ static const ctl_table ax25_param_table[] = {
 		.extra1		= &min_proto,
 		.extra2		= &max_proto
 	},
+#ifdef CONFIG_AX25_DAMA_SLAVE
 	{
 		.ctl_name	= NET_AX25_DAMA_SLAVE_TIMEOUT,
 		.procname	= "dama_slave_timeout",
@@ -177,6 +179,8 @@ static const ctl_table ax25_param_table[] = {
 		.extra1		= &min_ds_timeout,
 		.extra2		= &max_ds_timeout
 	},
+#endif
+
 	{ .ctl_name = 0 }	/* that's all, folks! */
 };
 
@@ -210,16 +214,6 @@ void ax25_register_sysctl(void)
 		ax25_table[n].procname     = ax25_dev->dev->name;
 		ax25_table[n].mode         = 0555;
 
-#ifndef CONFIG_AX25_DAMA_SLAVE
-		/*
-		 * We do not wish to have a representation of this parameter
-		 * in /proc/sys/ when configured *not* to include the
-		 * AX.25 DAMA slave code, do we?
-		 */
-
-		child[AX25_VALUES_DS_TIMEOUT].procname = NULL;
-#endif
-
 		child[AX25_MAX_VALUES].ctl_name = 0;	/* just in case... */
 
 		for (k = 0; k < AX25_MAX_VALUES; k++)
maintainer Applied
#1 lore raw

From: Ralf Baechle <[email protected]>
Date: Tue, 5 Aug 2008 23:37:36 +0100

Quoted 7 lines

Since 49ffcf8f99e8d33ec8afb450956804af518fd788
setting struct ctl_table.procname = NULL does no longer work as it used to the way the AX.25 code is expecting it to resulting in the AX.25 sysctl registration code to break if CONFIG_AX25_DAMA_SLAVE was not set as in some distribution kernels. Kernel releases from 2.6.24 are affected.

Applied, and I'll queue it up for -stable too.

Thanks Ralf.

#2 lore raw
Quoted 9 lines · David Miller

From: Ralf Baechle <[email protected]>
Date: Tue, 5 Aug 2008 23:37:36 +0100

Quoted 6 lines

Since 49ffcf8f99e8d33ec8afb450956804af518fd788
setting struct ctl_table.procname = NULL does no longer work as it used to the way the AX.25 code is expecting it to resulting in the AX.25 sysctl registration code to break if CONFIG_AX25_DAMA_SLAVE was not set as in some distribution kernels. Kernel releases from 2.6.24 are affected.

Quoted 3 lines
Quoted 1 line

Applied, and I'll queue it up for -stable too.

BTW, here's netfilter sysctl one:

---

net/netfilter/core.c +6 -0
index 292fa28..655d743 100644
@@ -264,6 +264,12 @@ EXPORT_SYMBOL(proc_net_netfilter);
 void __init netfilter_init(void)
 {
 	int i, h;
+
+#ifdef CONFIG_SYSCTL
+	static struct ctl_table empty[1];
+	register_sysctl_paths(nf_net_netfilter_sysctl_path, empty);
+#endif
+
 	for (i = 0; i < NPROTO; i++) {
 		for (h = 0; h < NF_MAX_HOOKS; h++)
 			INIT_LIST_HEAD(&nf_hooks[i][h]);
net/netfilter/nf_conntrack_standalone.c +15 -11
index 869ef93..deddf21 100644
@@ -324,6 +324,7 @@ static int log_invalid_proto_min = 0;
 static int log_invalid_proto_max = 255;
 
 static struct ctl_table_header *nf_ct_sysctl_header;
+static struct ctl_table_header *nf_ct_sysctl_netfilter_header;
 
 static ctl_table nf_ct_sysctl_table[] = {
 	{
@@ -384,12 +385,6 @@ static ctl_table nf_ct_sysctl_table[] = {
 
 static ctl_table nf_ct_netfilter_table[] = {
 	{
-		.ctl_name	= NET_NETFILTER,
-		.procname	= "netfilter",
-		.mode		= 0555,
-		.child		= nf_ct_sysctl_table,
-	},
-	{
 		.ctl_name	= NET_NF_CONNTRACK_MAX,
 		.procname	= "nf_conntrack_max",
 		.data		= &nf_conntrack_max,
@@ -409,19 +404,28 @@ EXPORT_SYMBOL_GPL(nf_ct_log_invalid);
 
 static int nf_conntrack_standalone_init_sysctl(void)
 {
-	nf_ct_sysctl_header =
+	nf_ct_sysctl_netfilter_header =
 		register_sysctl_paths(nf_ct_path, nf_ct_netfilter_table);
-	if (nf_ct_sysctl_header == NULL) {
-		printk("nf_conntrack: can't register to sysctl.\n");
-		return -ENOMEM;
-	}
+	if (!nf_ct_sysctl_netfilter_header)
+		goto out;
+	nf_ct_sysctl_header =
+		register_sysctl_paths(nf_net_netfilter_sysctl_path,
+					nf_ct_sysctl_table);
+	if (!nf_ct_sysctl_header)
+		goto out1;
 	return 0;
 
+out1:
+	unregister_sysctl_table(nf_ct_sysctl_netfilter_header);
+out:
+	printk("nf_conntrack: can't register to sysctl.\n");
+	return -ENOMEM;
 }
 
 static void nf_conntrack_standalone_fini_sysctl(void)
 {
 	unregister_sysctl_table(nf_ct_sysctl_header);
+	unregister_sysctl_table(nf_ct_sysctl_netfilter_header);
 }
 #else
 static int nf_conntrack_standalone_init_sysctl(void)
#3 lore raw
Quoted 10 lines · Al Viro
Quoted 9 lines · David Miller

From: Ralf Baechle <[email protected]>
Date: Tue, 5 Aug 2008 23:37:36 +0100

Quoted 6 lines

Since 49ffcf8f99e8d33ec8afb450956804af518fd788
setting struct ctl_table.procname = NULL does no longer work as it used to the way the AX.25 code is expecting it to resulting in the AX.25 sysctl registration code to break if CONFIG_AX25_DAMA_SLAVE was not set as in some distribution kernels. Kernel releases from 2.6.24 are affected.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Applied, and I'll queue it up for -stable too.

BTW, here's netfilter sysctl one:

Please hold, still working on this.

Quoted 7 lines

---

net/netfilter/core.c +0 -0
index 292fa28..655d743 100644

net/netfilter/core.c EXPORT_SYMBOL(proc_net_netfilter); · line 271

Quoted 8 lines
net/netfilter/core.c +5 -0
@@ -264,6 +264,12 @@ EXPORT_SYMBOL(proc_net_netfilter);
 void __init netfilter_init(void)
 {
 	int i, h;
+
+#ifdef CONFIG_SYSCTL
+	static struct ctl_table empty[1];
+	register_sysctl_paths(nf_net_netfilter_sysctl_path, empty);
+#endif

I think that instead of adding an empty nf_net_netfilter_sysctl_path registration, it would be better to fix the order of register/unregister:

@@ -1032,10 +1032,10 @@

        nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc,
                             nf_conntrack_htable_size);
-       nf_conntrack_proto_fini();
-       nf_conntrack_helper_fini();
-       nf_conntrack_expect_fini();
        nf_conntrack_acct_fini();
+       nf_conntrack_expect_fini();
+       nf_conntrack_helper_fini();
+       nf_conntrack_proto_fini();

}

I have a patch ready, only need to make some more tests.

Best regards,

Krzysztof Olędzki