From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com ([209.85.192.195]:44221 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965382AbeCAC2F (ORCPT ); Wed, 28 Feb 2018 21:28:05 -0500 Received: by mail-pf0-f195.google.com with SMTP id 17so1839443pfw.11 for ; Wed, 28 Feb 2018 18:28:04 -0800 (PST) Message-ID: <1519871282.11536.2.camel@gmail.com> Subject: Re: [PATCH] inet: add bound ports statistic From: Eric Dumazet To: Stephen Hemminger , davem@davemloft.net Cc: netdev@vger.kernel.org, Stephen Hemminger Date: Wed, 28 Feb 2018 18:28:02 -0800 In-Reply-To: <20180301020101.3975-1-sthemmin@microsoft.com> References: <20180301020101.3975-1-sthemmin@microsoft.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 2018-02-28 at 18:01 -0800, Stephen Hemminger wrote: > This adds a number of bound ports in a network namespace which is > a useful for socket summary (ss) command. It adds one additional > field onto /proc/net/sockstat. > > Since collecting these kind of counters can be sensitive for large > machines, the impact is placed on the reading side which will be > much rarer. > > Signed-off-by: Stephen Hemminger > --- > include/net/inet_connection_sock.h | 2 +- > net/ipv4/inet_connection_sock.c | 22 ++++++++++++++++++++++ > net/ipv4/proc.c | 5 +++-- > 3 files changed, 26 insertions(+), 3 deletions(-) > > diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h > index c1a93ce35e62..3044deec73ce 100644 > --- a/include/net/inet_connection_sock.h > +++ b/include/net/inet_connection_sock.h > @@ -265,7 +265,7 @@ inet_csk_rto_backoff(const struct inet_connection_sock *icsk, > } > > struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern); > - > +unsigned int inet_csk_count_ports(struct net *net, struct proto *prot); > int inet_csk_get_port(struct sock *sk, unsigned short snum); > > struct dst_entry *inet_csk_route_req(const struct sock *sk, struct flowi4 *fl4, > diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c > index 881ac6d046f2..2418abce4d50 100644 > --- a/net/ipv4/inet_connection_sock.c > +++ b/net/ipv4/inet_connection_sock.c > @@ -424,6 +424,28 @@ static int inet_csk_wait_for_connect(struct sock *sk, long timeo) > return err; > } > > +/* Count how many any entries are in the bind hash table */ How useful it is to report this information ? Given REUSEADDR and REUSEPORT, I really wonder what can be derived from this counter. It seems its semantic is weak.