tcp: seq_file: Add listening_get_first()
authorMartin KaFai Lau <kafai@fb.com>
Thu, 1 Jul 2021 20:06:00 +0000 (13:06 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Fri, 23 Jul 2021 23:44:53 +0000 (16:44 -0700)
commitb72acf4501d7c31e96749f0f5052b3bcb25fc2cb
tree62d37a764adefd9125a16b2d6d046fb574d5ed19
parent62001372c2b6cdf2346afb2cf94ed3d950eee64c
tcp: seq_file: Add listening_get_first()

The current listening_get_next() is overloaded by passing
NULL to the 2nd arg, like listening_get_next(seq, NULL), to
mean get_first().

This patch moves some logic from the listening_get_next() into
a new function listening_get_first().  It will be equivalent
to the current established_get_first() and established_get_next()
setup.  get_first() is to find a non empty bucket and return
the first sk.  get_next() is to find the next sk of the current
bucket and then resorts to get_first() if the current bucket is
exhausted.

The next patch is to move the listener seq_file iteration from
listening_hash (port only) to lhash2 (port+addr).
Separating out listening_get_first() from listening_get_next()
here will make the following lhash2 changes cleaner and easier to
follow.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Acked-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210701200600.1035353-1-kafai@fb.com
net/ipv4/tcp_ipv4.c