All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] Add element count to bitmap and hash headers
@ 2015-02-17 15:35 Eric B Munson
  2015-02-17 15:53 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 6+ messages in thread
From: Eric B Munson @ 2015-02-17 15:35 UTC (permalink / raw)
  To: netfilter-devel; +Cc: kadlec, johunt, Eric B Munson

It would be useful for userspace to query the size of an ipset.  This
data is held for both the bitmask and hash types, however, it is not
exposed to userspace.  This patch uses the otherwise unused attribute
IPSET_ATTR_ELEMENTS to indicate the size in the the header that is
exported to userspace.

Signed-off-by: Eric B Munson <emunson@akamai.com>
---
 net/netfilter/ipset/ip_set_bitmap_gen.h |    3 ++-
 net/netfilter/ipset/ip_set_hash_gen.h   |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h b/net/netfilter/ipset/ip_set_bitmap_gen.h
index 6f024a8..faa9f3e 100644
--- a/net/netfilter/ipset/ip_set_bitmap_gen.h
+++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
@@ -101,7 +101,8 @@ mtype_head(struct ip_set *set, struct sk_buff *skb)
 	    nla_put_net32(skb, IPSET_ATTR_MEMSIZE,
 			  htonl(sizeof(*map) +
 				map->memsize +
-				set->dsize * map->elements)))
+				set->dsize * map->elements)) ||
+	    nla_put_net32(skb, IPSET_ATTR_ELEMENTS, htonl(map->elements)))
 		goto nla_put_failure;
 	if (unlikely(ip_set_put_flags(skb, set)))
 		goto nla_put_failure;
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 974ff38..3734b2f 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -930,7 +930,8 @@ mtype_head(struct ip_set *set, struct sk_buff *skb)
 		goto nla_put_failure;
 #endif
 	if (nla_put_net32(skb, IPSET_ATTR_REFERENCES, htonl(set->ref - 1)) ||
-	    nla_put_net32(skb, IPSET_ATTR_MEMSIZE, htonl(memsize)))
+	    nla_put_net32(skb, IPSET_ATTR_MEMSIZE, htonl(memsize)) ||
+	    nla_put_net32(skb, IPSET_ATTR_ELEMENTS, htonl(h->elements)))
 		goto nla_put_failure;
 	if (unlikely(ip_set_put_flags(skb, set)))
 		goto nla_put_failure;
-- 
1.7.9.5


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

end of thread, other threads:[~2015-02-18 19:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-17 15:35 [PATCH RESEND] Add element count to bitmap and hash headers Eric B Munson
2015-02-17 15:53 ` Pablo Neira Ayuso
2015-02-17 21:35   ` Jozsef Kadlecsik
2015-02-18  3:54     ` Pablo Neira Ayuso
2015-02-18 14:59       ` Eric B Munson
2015-02-18 19:53       ` Eric B Munson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.