LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

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

To: Julian Anastasov <ja@xxxxxx>
Subject: Re: [PATCH nf-next 1/3] ipvs: show the current conn_tab size to users
Cc: Simon Horman <horms@xxxxxxxxxxxx>, Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>, lvs-devel@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx, Dust Li <dust.li@xxxxxxxxxxxxxxxxx>, Jiejian Wu <jiejian@xxxxxxxxxxxxxxxxx>
From: Florian Westphal <fw@xxxxxxxxx>
Date: Sat, 4 Apr 2026 12:30:40 +0200
Julian Anastasov <ja@xxxxxx> 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 <ja@xxxxxx>
> ---
>  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:

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;
}


<Prev in Thread] Current Thread [Next in Thread>