netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kaber@trash.net
To: davem@davemloft.net
Cc: netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH 18/20] netfilter: ipset: use the stored first cidr value instead of '1'
Date: Thu, 16 Jun 2011 21:47:18 +0200	[thread overview]
Message-ID: <1308253640-29942-19-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1308253640-29942-1-git-send-email-kaber@trash.net>

From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>

Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/ipset/ip_set_hash_ipportnet.c |   10 ++++++----
 net/netfilter/ipset/ip_set_hash_net.c       |    8 ++++++--
 net/netfilter/ipset/ip_set_hash_netport.c   |    6 ++++--
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c
index dcd351b..d2d6ab8 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c
@@ -156,8 +156,9 @@ hash_ipportnet4_kadt(struct ip_set *set, const struct sk_buff *skb,
 {
 	const struct ip_set_hash *h = set->data;
 	ipset_adtfn adtfn = set->variant->adt[adt];
-	struct hash_ipportnet4_elem data =
-		{ .cidr = h->nets[0].cidr || HOST_MASK };
+	struct hash_ipportnet4_elem data = {
+		.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
+	};
 
 	if (data.cidr == 0)
 		return -EINVAL;
@@ -434,8 +435,9 @@ hash_ipportnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
 {
 	const struct ip_set_hash *h = set->data;
 	ipset_adtfn adtfn = set->variant->adt[adt];
-	struct hash_ipportnet6_elem data =
-		{ .cidr = h->nets[0].cidr || HOST_MASK };
+	struct hash_ipportnet6_elem data = {
+		.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
+	};
 
 	if (data.cidr == 0)
 		return -EINVAL;
diff --git a/net/netfilter/ipset/ip_set_hash_net.c b/net/netfilter/ipset/ip_set_hash_net.c
index dcbb5d4..050163f 100644
--- a/net/netfilter/ipset/ip_set_hash_net.c
+++ b/net/netfilter/ipset/ip_set_hash_net.c
@@ -139,7 +139,9 @@ hash_net4_kadt(struct ip_set *set, const struct sk_buff *skb,
 {
 	const struct ip_set_hash *h = set->data;
 	ipset_adtfn adtfn = set->variant->adt[adt];
-	struct hash_net4_elem data = { .cidr = h->nets[0].cidr || HOST_MASK };
+	struct hash_net4_elem data = {
+		.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
+	};
 
 	if (data.cidr == 0)
 		return -EINVAL;
@@ -336,7 +338,9 @@ hash_net6_kadt(struct ip_set *set, const struct sk_buff *skb,
 {
 	const struct ip_set_hash *h = set->data;
 	ipset_adtfn adtfn = set->variant->adt[adt];
-	struct hash_net6_elem data = { .cidr = h->nets[0].cidr || HOST_MASK };
+	struct hash_net6_elem data = {
+		.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
+	};
 
 	if (data.cidr == 0)
 		return -EINVAL;
diff --git a/net/netfilter/ipset/ip_set_hash_netport.c b/net/netfilter/ipset/ip_set_hash_netport.c
index 72961ba..d7710a9 100644
--- a/net/netfilter/ipset/ip_set_hash_netport.c
+++ b/net/netfilter/ipset/ip_set_hash_netport.c
@@ -153,7 +153,8 @@ hash_netport4_kadt(struct ip_set *set, const struct sk_buff *skb,
 	const struct ip_set_hash *h = set->data;
 	ipset_adtfn adtfn = set->variant->adt[adt];
 	struct hash_netport4_elem data = {
-		.cidr = h->nets[0].cidr || HOST_MASK };
+		.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
+	};
 
 	if (data.cidr == 0)
 		return -EINVAL;
@@ -397,7 +398,8 @@ hash_netport6_kadt(struct ip_set *set, const struct sk_buff *skb,
 	const struct ip_set_hash *h = set->data;
 	ipset_adtfn adtfn = set->variant->adt[adt];
 	struct hash_netport6_elem data = {
-		.cidr = h->nets[0].cidr || HOST_MASK };
+		.cidr = h->nets[0].cidr ? h->nets[0].cidr : HOST_MASK
+	};
 
 	if (data.cidr == 0)
 		return -EINVAL;
-- 
1.7.2.3


  parent reply	other threads:[~2011-06-16 19:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 19:47 [PATCH 00/20] netfilter: netfilter update kaber
2011-06-16 19:47 ` [PATCH 01/20] ipvs: support more FTP PASV responses kaber
2011-06-16 19:47 ` [PATCH 02/20] IPVS remove unused var from migration to netns kaber
2011-06-16 19:47 ` [PATCH 03/20] IPVS: rename of netns init and cleanup functions kaber
2011-06-16 19:47 ` [PATCH 04/20] IPVS: labels at pos 0 kaber
2011-06-16 19:47 ` [PATCH 05/20] IPVS: remove unused init and cleanup functions kaber
2011-06-16 19:47 ` [PATCH 06/20] netfilter: ipset: timeout can be modified for already added elements kaber
2011-06-16 19:47 ` [PATCH 07/20] netfilter: ipset: whitespace fixes: some space before tab slipped in kaber
2011-06-16 19:47 ` [PATCH 08/20] netfilter: ipset: options and flags support added to the kernel API kaber
2011-06-16 19:47 ` [PATCH 09/20] netfilter: ipset: support listing setnames and headers too kaber
2011-06-16 19:47 ` [PATCH 10/20] netfilter: ipset: fix adding ranges to hash types kaber
2011-06-16 19:47 ` [PATCH 11/20] netfilter: ipset: set type support with multiple revisions added kaber
2011-06-16 19:47 ` [PATCH 12/20] netfilter: ipset: support range for IPv4 at adding/deleting elements for hash:*net* types kaber
2011-06-16 19:47 ` [PATCH 13/20] netfilter: ipset: adding ranges to hash types with timeout could still fail, fixed kaber
2011-06-16 19:47 ` [PATCH 14/20] netfilter: ipset: take into account cidr value for the from address when creating the set kaber
2011-06-16 19:47 ` [PATCH 15/20] netfilter: ipset: use unified from/to address masking and check the usage kaber
2011-06-16 19:47 ` [PATCH 16/20] netfilter: ipset: add xt_action_param to the variant level kadt functions, ipset API change kaber
2011-06-16 19:47 ` [PATCH 17/20] netfilter: ipset: fix return code for destroy when sets are in use kaber
2011-06-16 19:47 ` kaber [this message]
2011-06-16 19:47 ` [PATCH 19/20] netfilter: ipset: hash:net,iface type introduced kaber
2011-06-16 19:47 ` [PATCH 20/20] netfilter: ipset: whitespace and coding fixes detected by checkpatch.pl kaber
2011-06-17  1:54 ` [PATCH 00/20] netfilter: netfilter update David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1308253640-29942-19-git-send-email-kaber@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).