[PATCH 2/3] netfilter: fix warning in ebt_ulog init function.

Previous thread: [PATCH] bridge: bad error handling when adding invalid ether address by Stephen Hemminger on Wednesday, March 25, 2009 - 8:57 pm. (2 messages)

Next thread: [PATCH] net: fix unaligned memory accesses in ASIX by Giuseppe CAVALLARO on Wednesday, March 25, 2009 - 11:52 pm. (6 messages)
From: Stephen Rothwell
Date: Wednesday, March 25, 2009 - 11:37 pm

Hi Dave,

Today's linux-next build (x86_64 allmodconfig) produced these warnings:

net/bridge/netfilter/ebt_log.c: In function 'ebt_log_init':
net/bridge/netfilter/ebt_log.c:230: warning: passing argument 2 of 'nf_log_=
register' discards qualifiers from pointer target type
net/bridge/netfilter/ebt_log.c: In function 'ebt_log_fini':
net/bridge/netfilter/ebt_log.c:236: warning: passing argument 1 of 'nf_log_=
unregister' discards qualifiers from pointer target type
net/bridge/netfilter/ebt_ulog.c: In function 'ebt_ulog_init':
net/bridge/netfilter/ebt_ulog.c:317: warning: passing argument 2 of 'nf_log=
_register' discards qualifiers from pointer target type
net/bridge/netfilter/ebt_ulog.c: In function 'ebt_ulog_fini':
net/bridge/netfilter/ebt_ulog.c:327: warning: passing argument 1 of 'nf_log=
_unregister' discards qualifiers from pointer target type

Caused by commit ca735b3aaa945626ba65a3e51145bfe4ecd9e222 ("netfilter:
use a linked list of loggers") which removed const from the "struct
nf_logger *" arguments.
--=20
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
From: Eric Leblond
Date: Thursday, March 26, 2009 - 12:50 am

Hi Stephen,

og_unregister' discards qualifiers from pointer target type

Thanks a lot for pointing this. I stupidely forgot to build this module
during my testing.

I've made the necessary modifications and a patch fixing this will
follow this mail.

Doing some testing of the ebt_ulog module, I've found some problems. One
of them was the following messages:

sys_init_module: 'ebt_ulog'->init suspiciously returned 1, it should
follow 0/-E convention
sys_init_module: loading module anyway...
Pid: 2334, comm: modprobe Not tainted 2.6.29-rc5edenwall0-00883-g199e57b
#146
Call Trace:
 [<c0441b81>] ? printk+0xf/0x16
 [<c02311af>] sys_init_module+0x107/0x186
 [<c0202cfa>] syscall_call+0x7/0xb

A patch fixing this will also follow.

BR,
--=20
Eric Leblond <eric@inl.fr>
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
From: Eric Leblond
Date: Thursday, March 26, 2009 - 12:59 am

The ebt_ulog module does not follow the fixed convention about function
return. Loading the module is triggering the following message:

sys_init_module: 'ebt_ulog'->init suspiciously returned 1, it should follow 0/-E convention
sys_init_module: loading module anyway...
Pid: 2334, comm: modprobe Not tainted 2.6.29-rc5edenwall0-00883-g199e57b #146
Call Trace:
 [<c0441b81>] ? printk+0xf/0x16
 [<c02311af>] sys_init_module+0x107/0x186
 [<c0202cfa>] syscall_call+0x7/0xb

The following patch fixes the return treatment in ebt_ulog_init()
function.

Signed-off-by: Eric Leblond <eric@inl.fr>
---
 net/bridge/netfilter/ebt_ulog.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index 80c78c5..ac6fa43 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -287,13 +287,13 @@ static struct nf_logger ebt_ulog_logger __read_mostly = {
 
 static int __init ebt_ulog_init(void)
 {
-	bool ret = true;
+	int ret;
 	int i;
 
 	if (nlbufsiz >= 128*1024) {
 		printk(KERN_NOTICE "ebt_ulog: Netlink buffer has to be <= 128kB,"
 		       " please try a smaller nlbufsiz parameter.\n");
-		return false;
+		return -EINVAL;
 	}
 
 	/* initialize ulog_buffers */
@@ -308,12 +308,12 @@ static int __init ebt_ulog_init(void)
 	if (!ebtulognl) {
 		printk(KERN_WARNING KBUILD_MODNAME ": out of memory trying to "
 		       "call netlink_kernel_create\n");
-		ret = false;
-	} else if (xt_register_target(&ebt_ulog_tg_reg) != 0) {
+		ret = -ENOMEM;
+	} else if ((ret = xt_register_target(&ebt_ulog_tg_reg)) != 0) {
 		netlink_kernel_release(ebtulognl);
 	}
 
-	if (ret)
+	if (ret == 0)
 		nf_log_register(NFPROTO_BRIDGE, &ebt_ulog_logger);
 
 	return ret;
-- 
1.5.6.3

--

From: David Miller
Date: Thursday, March 26, 2009 - 1:04 am

From: Eric Leblond <eric@inl.fr>

Applied.
--

From: Eric Leblond
Date: Thursday, March 26, 2009 - 12:59 am

This patch renames the ebt_ulog nf_logger from "ulog" to "ebt_ulog" to
be in sync with other modules naming. As this name was currently only
used for informational purpose, the renaming should be harmless.

Signed-off-by: Eric Leblond <eric@inl.fr>
---
 net/bridge/netfilter/ebt_ulog.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index ac6fa43..133eeae 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -280,7 +280,7 @@ static struct xt_target ebt_ulog_tg_reg __read_mostly = {
 };
 
 static struct nf_logger ebt_ulog_logger __read_mostly = {
-	.name		= "ulog",
+	.name		= "ebt_ulog",
 	.logfn		= &ebt_log_packet,
 	.me		= THIS_MODULE,
 };
-- 
1.5.6.3

--

From: Eric Leblond
Date: Thursday, March 26, 2009 - 12:59 am

This patch fixes the declaration of the logger structure in ebt_log
and ebt_ulog: I forgot to remove the const option from their declaration
in the commit ca735b3aaa945626ba65a3e51145bfe4ecd9e222 ("netfilter:
use a linked list of loggers").

Pointed-out-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Eric Leblond <eric@inl.fr>
---
 net/bridge/netfilter/ebt_log.c  |    2 +-
 net/bridge/netfilter/ebt_ulog.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index d44cbf8..a94f3cc 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -214,7 +214,7 @@ static struct xt_target ebt_log_tg_reg __read_mostly = {
 	.me		= THIS_MODULE,
 };
 
-static const struct nf_logger ebt_log_logger = {
+static struct nf_logger ebt_log_logger __read_mostly = {
 	.name 		= "ebt_log",
 	.logfn		= &ebt_log_packet,
 	.me		= THIS_MODULE,
diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index 2c6d682..80c78c5 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -279,7 +279,7 @@ static struct xt_target ebt_ulog_tg_reg __read_mostly = {
 	.me		= THIS_MODULE,
 };
 
-static const struct nf_logger ebt_ulog_logger = {
+static struct nf_logger ebt_ulog_logger __read_mostly = {
 	.name		= "ulog",
 	.logfn		= &ebt_log_packet,
 	.me		= THIS_MODULE,
-- 
1.5.6.3

--

From: Patrick McHardy
Date: Thursday, March 26, 2009 - 6:17 am

Same here, I seem to have accidentally disabled bridging in my test
builds, sorry.
--

From: Stephen Rothwell
Date: Thursday, March 26, 2009 - 3:01 pm

Hi Eric,


Thanks.

--=20
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
Previous thread: [PATCH] bridge: bad error handling when adding invalid ether address by Stephen Hemminger on Wednesday, March 25, 2009 - 8:57 pm. (2 messages)

Next thread: [PATCH] net: fix unaligned memory accesses in ASIX by Giuseppe CAVALLARO on Wednesday, March 25, 2009 - 11:52 pm. (6 messages)