Skip to content

Commit bed187b

Browse files
lxindavem330
authored andcommitted
sctp: fix double EPs display in sctp_diag
We have this situation: that EP hash table, contains only the EPs that are listening, while the transports one, has the opposite. We have to traverse both to dump all. But when we traverse the transports one we will also get EPs that are in the EP hash if they are listening. In this case, the EP is dumped twice. We will fix it by checking if the endpoint that is in the endpoint hash table contains any ep->asoc in there, as it means we will also find it via transport hash, and thus we can/should skip it, depending on the filters used, like 'ss -l'. Still, we should NOT skip it if the user is listing only listening endpoints, because then we are not traversing the transport hash. so we have to check idiag_states there also. Signed-off-by: Xin Long <[email protected]> Acked-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3424d9b commit bed187b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/sctp/sctp_diag.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ static int sctp_ep_dump(struct sctp_endpoint *ep, void *p)
356356
if (cb->args[4] < cb->args[1])
357357
goto next;
358358

359+
if ((r->idiag_states & ~TCPF_LISTEN) && !list_empty(&ep->asocs))
360+
goto next;
361+
359362
if (r->sdiag_family != AF_UNSPEC &&
360363
sk->sk_family != r->sdiag_family)
361364
goto next;

0 commit comments

Comments
 (0)