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 <step...@networkplumber.org> > --- > 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.