netfilter: ipset: let destroy callbacks adjust ext mem size
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: ipset: let destroy callbacks adjust ext mem size
For bitmap this change makes no difference, because destructors are called synchronously.
sashiko pointed out list type destruction is partially done via call_rcu:
mem accounting could be subtracting after list_set_flush() did reset the value to 0. set->elements assignment can be removed for the same reason, this already walks the entire set and does 'set->elements--' for each entry synchronously.
---
Won't apply, this assumes the pending nf PR is applied. In case that PR is rejected, this patch could be reworked to logically come before the atomic64 conversion, but it doesn't buy mutch.
net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +- net/netfilter/ipset/ip_set_list_set.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
net/netfilter/ipset/ip_set_bitmap_gen.h +1 -1
@@ -77,7 +77,7 @@ mtype_flush(struct ip_set *set)mtype_ext_cleanup (set);bitmap_zero (map->members, map->elements); set->elements =0 ; -atomic64_set (&set->ext_size,0 ); +DEBUG_NET_WARN_ON_ONCE (atomic64_read (&set->ext_size) >0 ); }/* Calculate the actual memory size of the set data */
net/netfilter/ipset/ip_set_list_set.c +1 -2
@@ -420,8 +420,7 @@ list_set_flush(struct ip_set *set)list_for_each_entry_safe (e, n, &map->members, list)list_set_del (set, e); - set->elements =0 ; -atomic64_set (&set->ext_size,0 ); +DEBUG_NET_WARN_ON_ONCE (set->elements >0 ); } static void
Signature · 1 line
2.54.0
Hi Florian,
Quoted 8 lines · Florian Westphal
For bitmap this change makes no difference, because destructors are called synchronously.
sashiko pointed out list type destruction is partially done via
call_rcu:
mem accounting could be subtracting afterlist_set_flush()did reset the value to 0.set->elementsassignment can be removed for the same reason, this already walks the entire set and does 'set->elements--' for each entry synchronously.
Yes, I agree, about set->elements too. And one DEBUG_NET_WARN_ON_ONCE() is enough and it should catch any problem in list_set_del() about element number or extension size.
Quoted 31 lines
Fixes 9e41f26a505c ("netfilter: ipset: Count non-static extension memory for userspace")Signed-off-by Florian Westphal <[email protected]>---
Won't apply, this assumes the pending nf PR is applied. In case that PR is rejected, this patch could be reworked to logically come before the atomic64 conversion, but it doesn't buy mutch.net/netfilter/ipset/ip_set_bitmap_gen.h | 2 +- net/netfilter/ipset/ip_set_list_set.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)net/netfilter/ipset/ip_set_bitmap_gen.h +1
-1@@ -77,7 +77,7 @@ mtype_flush(struct ip_set *set)mtype_ext_cleanup (set);bitmap_zero (map->members, map->elements); set->elements =0 ; -atomic64_set (&set->ext_size,0 ); +DEBUG_NET_WARN_ON_ONCE (atomic64_read (&set->ext_size) >0 ); }/* Calculate the actual memory size of the set data */ net/netfilter/ipset/ip_set_list_set.c +0
-0
net/netfilter/ipset/ip_set_list_set.c list_set_flush(struct ip_set *set) · line 426
Quoted 9 lines
net/netfilter/ipset/ip_set_list_set.c +1
-2@@ -420,8 +420,7 @@ list_set_flush(struct ip_set *set)list_for_each_entry_safe (e, n, &map->members, list)list_set_del (set, e); - set->elements =0 ; -atomic64_set (&set->ext_size,0 ); +DEBUG_NET_WARN_ON_ONCE (set->elements >0 ); } static void
Best regards,
Jozsef
Signature · 3 lines
E-mail : [email protected], [email protected], [email protected] Address: Wigner Research Centre for Physics H-1525 Budapest 114, POB. 49, Hungary