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