netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3]: netfilter fixes
@ 2012-08-19 20:16 Patrick McHardy
  2012-08-19 20:16 ` [PATCH 1/3] netfilter: nfnetlink_log: fix NLA_PUT macro removal bug Patrick McHardy
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Patrick McHardy @ 2012-08-19 20:16 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

Hi Pablo.

the following three patches contain some minor fixes and cleanups:

- fix for a NLA_PUT conversion bug
- endian annotation fixes
- removal of unnecessary RTNL locking

Please apply, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] netfilter: nfnetlink_log: fix NLA_PUT macro removal bug
  2012-08-19 20:16 [PATCH 0/3]: netfilter fixes Patrick McHardy
@ 2012-08-19 20:16 ` Patrick McHardy
  2012-08-20 14:52   ` Pablo Neira Ayuso
  2012-08-19 20:16 ` [PATCH 2/3] netfilter: sparse endian fixes Patrick McHardy
  2012-08-19 20:16 ` [PATCH 3/3] netfilter: nf_conntrack: remove unnecessary RTNL locking Patrick McHardy
  2 siblings, 1 reply; 7+ messages in thread
From: Patrick McHardy @ 2012-08-19 20:16 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

Commit 1db20a52 (nfnetlink_log: Stop using NLA_PUT*().) incorrectly
converted a NLA_PUT_BE16 macro to nla_put_be32() in nfnetlink_log:

-               NLA_PUT_BE16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type));
+               if (nla_put_be32(inst->skb, NFULA_HWTYPE, htons(skb->dev->type))

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/nfnetlink_log.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 169ab59..592091c 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -480,7 +480,7 @@ __build_packet_message(struct nfulnl_instance *inst,
 	}
 
 	if (indev && skb_mac_header_was_set(skb)) {
-		if (nla_put_be32(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) ||
+		if (nla_put_be16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type)) ||
 		    nla_put_be16(inst->skb, NFULA_HWLEN,
 				 htons(skb->dev->hard_header_len)) ||
 		    nla_put(inst->skb, NFULA_HWHEADER, skb->dev->hard_header_len,
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] netfilter: sparse endian fixes
  2012-08-19 20:16 [PATCH 0/3]: netfilter fixes Patrick McHardy
  2012-08-19 20:16 ` [PATCH 1/3] netfilter: nfnetlink_log: fix NLA_PUT macro removal bug Patrick McHardy
@ 2012-08-19 20:16 ` Patrick McHardy
  2012-08-20 14:53   ` Pablo Neira Ayuso
  2012-08-19 20:16 ` [PATCH 3/3] netfilter: nf_conntrack: remove unnecessary RTNL locking Patrick McHardy
  2 siblings, 1 reply; 7+ messages in thread
From: Patrick McHardy @ 2012-08-19 20:16 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

Fix a couple of endian annotation in net/netfilter:

net/netfilter/nfnetlink_acct.c:82:30: warning: cast to restricted __be64
net/netfilter/nfnetlink_acct.c:86:30: warning: cast to restricted __be64
net/netfilter/nfnetlink_cthelper.c:77:28: warning: cast to restricted __be16
net/netfilter/xt_NFQUEUE.c:46:16: warning: restricted __be32 degrades to integer
net/netfilter/xt_NFQUEUE.c:60:34: warning: restricted __be32 degrades to integer
net/netfilter/xt_NFQUEUE.c:68:34: warning: restricted __be32 degrades to integer
net/netfilter/xt_osf.c:272:55: warning: cast to restricted __be16

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/nfnetlink_acct.c     |    4 ++--
 net/netfilter/nfnetlink_cthelper.c |    2 +-
 net/netfilter/xt_NFQUEUE.c         |    8 +++++---
 net/netfilter/xt_osf.c             |    2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
index b2e7310..d7ec928 100644
--- a/net/netfilter/nfnetlink_acct.c
+++ b/net/netfilter/nfnetlink_acct.c
@@ -79,11 +79,11 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
 
 	if (tb[NFACCT_BYTES]) {
 		atomic64_set(&nfacct->bytes,
-			     be64_to_cpu(nla_get_u64(tb[NFACCT_BYTES])));
+			     be64_to_cpu(nla_get_be64(tb[NFACCT_BYTES])));
 	}
 	if (tb[NFACCT_PKTS]) {
 		atomic64_set(&nfacct->pkts,
-			     be64_to_cpu(nla_get_u64(tb[NFACCT_PKTS])));
+			     be64_to_cpu(nla_get_be64(tb[NFACCT_PKTS])));
 	}
 	atomic_set(&nfacct->refcnt, 1);
 	list_add_tail_rcu(&nfacct->head, &nfnl_acct_list);
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index d683619..32a1ba3 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -74,7 +74,7 @@ nfnl_cthelper_parse_tuple(struct nf_conntrack_tuple *tuple,
 	if (!tb[NFCTH_TUPLE_L3PROTONUM] || !tb[NFCTH_TUPLE_L4PROTONUM])
 		return -EINVAL;
 
-	tuple->src.l3num = ntohs(nla_get_u16(tb[NFCTH_TUPLE_L3PROTONUM]));
+	tuple->src.l3num = ntohs(nla_get_be16(tb[NFCTH_TUPLE_L3PROTONUM]));
 	tuple->dst.protonum = nla_get_u8(tb[NFCTH_TUPLE_L4PROTONUM]);
 
 	return 0;
diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c
index 7babe7d..817f9e9 100644
--- a/net/netfilter/xt_NFQUEUE.c
+++ b/net/netfilter/xt_NFQUEUE.c
@@ -43,7 +43,7 @@ static u32 hash_v4(const struct sk_buff *skb)
 	const struct iphdr *iph = ip_hdr(skb);
 
 	/* packets in either direction go into same queue */
-	if (iph->saddr < iph->daddr)
+	if ((__force u32)iph->saddr < (__force u32)iph->daddr)
 		return jhash_3words((__force u32)iph->saddr,
 			(__force u32)iph->daddr, iph->protocol, jhash_initval);
 
@@ -57,7 +57,8 @@ static u32 hash_v6(const struct sk_buff *skb)
 	const struct ipv6hdr *ip6h = ipv6_hdr(skb);
 	u32 a, b, c;
 
-	if (ip6h->saddr.s6_addr32[3] < ip6h->daddr.s6_addr32[3]) {
+	if ((__force u32)ip6h->saddr.s6_addr32[3] <
+	    (__force u32)ip6h->daddr.s6_addr32[3]) {
 		a = (__force u32) ip6h->saddr.s6_addr32[3];
 		b = (__force u32) ip6h->daddr.s6_addr32[3];
 	} else {
@@ -65,7 +66,8 @@ static u32 hash_v6(const struct sk_buff *skb)
 		a = (__force u32) ip6h->daddr.s6_addr32[3];
 	}
 
-	if (ip6h->saddr.s6_addr32[1] < ip6h->daddr.s6_addr32[1])
+	if ((__force u32)ip6h->saddr.s6_addr32[1] <
+	    (__force u32)ip6h->daddr.s6_addr32[1])
 		c = (__force u32) ip6h->saddr.s6_addr32[1];
 	else
 		c = (__force u32) ip6h->daddr.s6_addr32[1];
diff --git a/net/netfilter/xt_osf.c b/net/netfilter/xt_osf.c
index 846f895..a5e673d 100644
--- a/net/netfilter/xt_osf.c
+++ b/net/netfilter/xt_osf.c
@@ -269,7 +269,7 @@ xt_osf_match_packet(const struct sk_buff *skb, struct xt_action_param *p)
 						mss <<= 8;
 						mss |= optp[2];
 
-						mss = ntohs(mss);
+						mss = ntohs((__force __be16)mss);
 						break;
 					case OSFOPT_TS:
 						loop_cont = 1;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] netfilter: nf_conntrack: remove unnecessary RTNL locking
  2012-08-19 20:16 [PATCH 0/3]: netfilter fixes Patrick McHardy
  2012-08-19 20:16 ` [PATCH 1/3] netfilter: nfnetlink_log: fix NLA_PUT macro removal bug Patrick McHardy
  2012-08-19 20:16 ` [PATCH 2/3] netfilter: sparse endian fixes Patrick McHardy
@ 2012-08-19 20:16 ` Patrick McHardy
  2012-08-20 14:53   ` Pablo Neira Ayuso
  2 siblings, 1 reply; 7+ messages in thread
From: Patrick McHardy @ 2012-08-19 20:16 UTC (permalink / raw)
  To: netfilter-devel; +Cc: pablo

Locking the rtnl was added to nf_conntrack_l{3,4}_proto_unregister()
for walking the network namespace list. This is not done anymore since
we have proper namespace support in the protocols now, so we don't
need to take the RTNL anymore.

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/nf_conntrack_proto.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 0dc6385..51e928d 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -21,7 +21,6 @@
 #include <linux/notifier.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
-#include <linux/rtnetlink.h>
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_l3proto.h>
@@ -294,9 +293,7 @@ void nf_conntrack_l3proto_unregister(struct net *net,
 	nf_ct_l3proto_unregister_sysctl(net, proto);
 
 	/* Remove all contrack entries for this protocol */
-	rtnl_lock();
 	nf_ct_iterate_cleanup(net, kill_l3proto, proto);
-	rtnl_unlock();
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_unregister);
 
@@ -502,9 +499,7 @@ void nf_conntrack_l4proto_unregister(struct net *net,
 	nf_ct_l4proto_unregister_sysctl(net, pn, l4proto);
 
 	/* Remove all contrack entries for this protocol */
-	rtnl_lock();
 	nf_ct_iterate_cleanup(net, kill_l4proto, l4proto);
-	rtnl_unlock();
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_unregister);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] netfilter: nfnetlink_log: fix NLA_PUT macro removal bug
  2012-08-19 20:16 ` [PATCH 1/3] netfilter: nfnetlink_log: fix NLA_PUT macro removal bug Patrick McHardy
@ 2012-08-20 14:52   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 7+ messages in thread
From: Pablo Neira Ayuso @ 2012-08-20 14:52 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

On Sun, Aug 19, 2012 at 10:16:08PM +0200, Patrick McHardy wrote:
> Commit 1db20a52 (nfnetlink_log: Stop using NLA_PUT*().) incorrectly
> converted a NLA_PUT_BE16 macro to nla_put_be32() in nfnetlink_log:
> 
> -               NLA_PUT_BE16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type));
> +               if (nla_put_be32(inst->skb, NFULA_HWTYPE, htons(skb->dev->type))

queued for net tree. Thanks Patrick.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] netfilter: sparse endian fixes
  2012-08-19 20:16 ` [PATCH 2/3] netfilter: sparse endian fixes Patrick McHardy
@ 2012-08-20 14:53   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 7+ messages in thread
From: Pablo Neira Ayuso @ 2012-08-20 14:53 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

On Sun, Aug 19, 2012 at 10:16:09PM +0200, Patrick McHardy wrote:
> Fix a couple of endian annotation in net/netfilter:
> 
> net/netfilter/nfnetlink_acct.c:82:30: warning: cast to restricted __be64
> net/netfilter/nfnetlink_acct.c:86:30: warning: cast to restricted __be64
> net/netfilter/nfnetlink_cthelper.c:77:28: warning: cast to restricted __be16
> net/netfilter/xt_NFQUEUE.c:46:16: warning: restricted __be32 degrades to integer
> net/netfilter/xt_NFQUEUE.c:60:34: warning: restricted __be32 degrades to integer
> net/netfilter/xt_NFQUEUE.c:68:34: warning: restricted __be32 degrades to integer
> net/netfilter/xt_osf.c:272:55: warning: cast to restricted __be16

Applied, thanks Patrick. I'll pass schedule this for net-next.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] netfilter: nf_conntrack: remove unnecessary RTNL locking
  2012-08-19 20:16 ` [PATCH 3/3] netfilter: nf_conntrack: remove unnecessary RTNL locking Patrick McHardy
@ 2012-08-20 14:53   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 7+ messages in thread
From: Pablo Neira Ayuso @ 2012-08-20 14:53 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: netfilter-devel

On Sun, Aug 19, 2012 at 10:16:10PM +0200, Patrick McHardy wrote:
> Locking the rtnl was added to nf_conntrack_l{3,4}_proto_unregister()
> for walking the network namespace list. This is not done anymore since
> we have proper namespace support in the protocols now, so we don't
> need to take the RTNL anymore.

Applied, thanks. Also enqueued to net-next.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-08-20 14:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-19 20:16 [PATCH 0/3]: netfilter fixes Patrick McHardy
2012-08-19 20:16 ` [PATCH 1/3] netfilter: nfnetlink_log: fix NLA_PUT macro removal bug Patrick McHardy
2012-08-20 14:52   ` Pablo Neira Ayuso
2012-08-19 20:16 ` [PATCH 2/3] netfilter: sparse endian fixes Patrick McHardy
2012-08-20 14:53   ` Pablo Neira Ayuso
2012-08-19 20:16 ` [PATCH 3/3] netfilter: nf_conntrack: remove unnecessary RTNL locking Patrick McHardy
2012-08-20 14:53   ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).