Message ID | 20220324135753.25182-5-fw@strlen.de (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | mptcp: listen dump support | expand |
Context | Check | Description |
---|---|---|
matttbe/build | success | Build and static analysis OK |
matttbe/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 28 lines checked |
On Thu, 2022-03-24 at 14:57 +0100, Florian Westphal wrote: > Before: > State Recv-Q Send-Q .. > LISTEN 0 0 > > After: > LISTEN 0 20 > > Signed-off-by: Florian Westphal <fw@strlen.de> > --- > net/mptcp/mptcp_diag.c | 10 ++++++++-- > net/mptcp/protocol.c | 5 ++++- > 2 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c > index 6a6dfc7eac33..e1babab45e86 100644 > --- a/net/mptcp/mptcp_diag.c > +++ b/net/mptcp/mptcp_diag.c > @@ -189,8 +189,14 @@ static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, > struct mptcp_sock *msk = mptcp_sk(sk); > struct mptcp_info *info = _info; > > - r->idiag_rqueue = sk_rmem_alloc_get(sk); > - r->idiag_wqueue = sk_wmem_alloc_get(sk); > + if (inet_sk_state_load(sk) == TCP_LISTEN) { > + r->idiag_rqueue = READ_ONCE(sk->sk_ack_backlog); > + r->idiag_wqueue = READ_ONCE(sk->sk_max_ack_backlog); What about accessing msk->first->sk*ack_backlog instead ? Are there any possible subtle races? Otherwise sk_ack_backlog will always be 0, right? Thanks! Paolo
Paolo Abeni <pabeni@redhat.com> wrote: > > - r->idiag_rqueue = sk_rmem_alloc_get(sk); > > - r->idiag_wqueue = sk_wmem_alloc_get(sk); > > + if (inet_sk_state_load(sk) == TCP_LISTEN) { > > + r->idiag_rqueue = READ_ONCE(sk->sk_ack_backlog); > > + r->idiag_wqueue = READ_ONCE(sk->sk_max_ack_backlog); > > What about accessing msk->first->sk*ack_backlog instead ? Are there any > possible subtle races? Otherwise sk_ack_backlog will always be 0, > right? Yes, msk->first would be better here, will drop this patch and merge the msk->first bit into preceeding one.
diff --git a/net/mptcp/mptcp_diag.c b/net/mptcp/mptcp_diag.c index 6a6dfc7eac33..e1babab45e86 100644 --- a/net/mptcp/mptcp_diag.c +++ b/net/mptcp/mptcp_diag.c @@ -189,8 +189,14 @@ static void mptcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r, struct mptcp_sock *msk = mptcp_sk(sk); struct mptcp_info *info = _info; - r->idiag_rqueue = sk_rmem_alloc_get(sk); - r->idiag_wqueue = sk_wmem_alloc_get(sk); + if (inet_sk_state_load(sk) == TCP_LISTEN) { + r->idiag_rqueue = READ_ONCE(sk->sk_ack_backlog); + r->idiag_wqueue = READ_ONCE(sk->sk_max_ack_backlog); + } else { + r->idiag_rqueue = sk_rmem_alloc_get(sk); + r->idiag_wqueue = sk_wmem_alloc_get(sk); + } + if (!info) return; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d3887f628b54..a29cfc4c44a1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3589,8 +3589,11 @@ static int mptcp_listen(struct socket *sock, int backlog) err = ssock->ops->listen(ssock, backlog); inet_sk_state_store(sock->sk, inet_sk_state_load(ssock->sk)); - if (!err) + if (!err) { mptcp_copy_inaddrs(sock->sk, ssock->sk); + WRITE_ONCE(sock->sk->sk_max_ack_backlog, + READ_ONCE(ssock->sk->sk_max_ack_backlog)); + } unlock: release_sock(sock->sk);
Before: State Recv-Q Send-Q .. LISTEN 0 0 After: LISTEN 0 20 Signed-off-by: Florian Westphal <fw@strlen.de> --- net/mptcp/mptcp_diag.c | 10 ++++++++-- net/mptcp/protocol.c | 5 ++++- 2 files changed, 12 insertions(+), 3 deletions(-)