Re: [PATCH nf-next 1/3] ipvs: show the current conn_tab size to users

Julian Anastasov <[email protected]> Sat, 4 Apr 2026 17:58:26 +0300 (EEST)
Newsgroups org.kernel.vger.lvs-devel,org.kernel.vger.netfilter-devel
Message-ID <[email protected]>
	Hello,

On Sat, 4 Apr 2026, Florian Westphal wrote:

> Julian Anastasov <[email protected]> wrote:
> > As conn_tab is per-net, better to show the current hash table size
> > to users instead of the ip_vs_conn_tab_size (max).
> > 
> > Signed-off-by: Julian Anastasov <[email protected]>
> > ---
> >  net/netfilter/ipvs/ip_vs_ctl.c | 26 ++++++++++++++++++++++----
> >  1 file changed, 22 insertions(+), 4 deletions(-)
> > 
> > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> > index b472e564b769..3129b15dadc2 100644
> > --- a/net/netfilter/ipvs/ip_vs_ctl.c
> > +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> > @@ -281,6 +281,13 @@ static void est_reload_work_handler(struct work_struct *work)
> >  	mutex_unlock(&ipvs->est_mutex);
> >  }
> >  
> > +static int get_conn_tab_size(struct netns_ipvs *ipvs)
> > +{
> > +	struct ip_vs_rht *t = rcu_dereference(ipvs->conn_tab);
> > +
> > +	return t? t->size : 0;
> > +}
> 
> Pablo suggest to make this self-contained so callers don't have to
> handle rcu read lock:

	I created it this way because ip_vs_info_seq_show()
and IPVS_CMD_GET_INFO case are already under RCU lock.
I'll report v2 soon...

> static int get_conn_tab_size(struct netns_ipvs *ipvs)
> {
> 	const struct ip_vs_rht *t;
> 	int size = 0;
> 
> 	rcu_read_lock();
> 	t = rcu_dereference(ipvs->conn_tab);
> 	if (t)
> 		size = t->size;
> 	rcu_read_unlock();
> 
> 	return size;
> }

Regards

--
Julian Anastasov <[email protected]>