[PATCH nf 7/7] netfilter: ipset: also report mem size for cidr storage to userspace
Florian Westphal <[email protected]>
| Newsgroups | gmane.comp.security.firewalls.netfilter.devel |
|---|---|
| Message-ID | <[email protected]> |
After the 'Fixes' commit, the storage is allocated dynamically.
Include this when reporting the mem usage.
Fixes: 8e5fd2a55e24 ("netfilter: ipset: rework cidr bookkeeping")
Signed-off-by: Florian Westphal <[email protected]>
---
Not part of RFC.
net/netfilter/ipset/ip_set_hash_gen.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 2bb3ec147ae3..506dae7cec82 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -643,6 +643,23 @@ mtype_rht_size(struct ip_set *set, u32 *elements, size_t *ext_size)
*elements = ipset_hash_nelems(h);
*ext_size = *elements *
(offsetof(struct mtype_rht_elem, elem) + set->dsize);
+
+#ifdef IP_SET_HASH_WITH_NETS
+ {
+ const struct net_prefixes *nets;
+ int i;
+
+ rcu_read_lock();
+
+ for (i = 0; i < IPSET_NET_COUNT; i++) {
+ nets = rcu_dereference(h->rnets[i]);
+ if (nets)
+ *ext_size += ksize(nets);
+ }
+
+ rcu_read_unlock();
+ }
+#endif
}
static u32 mtype_remove_key(const void *data, u32 len, u32 seed)
--
2.54.0