Commit 02ae675f authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[TCP]: Fix bug that hid sockets in tcp_diag

This patch squashes a bug in tcp_diag which was created when the
sk_* loops replaced the original for loops.  It's a pity that these
sk_*/hlist_*/list_* loops don't take an arbitrary expression as an
argument for continue.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a31f1aeb
......@@ -495,21 +495,22 @@ static int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb)
sk_for_each(sk, node, &tcp_listening_hash[i]) {
struct inet_opt *inet = inet_sk(sk);
if (num < s_num)
continue;
goto next_listen;
if (!(r->tcpdiag_states&TCPF_LISTEN) ||
r->id.tcpdiag_dport)
continue;
goto next_listen;
if (r->id.tcpdiag_sport != inet->sport &&
r->id.tcpdiag_sport)
continue;
goto next_listen;
if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk))
continue;
goto next_listen;
if (tcpdiag_fill(skb, sk, r->tcpdiag_ext,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq) <= 0) {
tcp_listen_unlock();
goto done;
}
next_listen:
++num;
}
}
......@@ -537,22 +538,23 @@ static int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct inet_opt *inet = inet_sk(sk);
if (num < s_num)
continue;
goto next_normal;
if (!(r->tcpdiag_states & (1 << sk->sk_state)))
continue;
goto next_normal;
if (r->id.tcpdiag_sport != inet->sport &&
r->id.tcpdiag_sport)
continue;
goto next_normal;
if (r->id.tcpdiag_dport != inet->dport && r->id.tcpdiag_dport)
continue;
goto next_normal;
if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk))
continue;
goto next_normal;
if (tcpdiag_fill(skb, sk, r->tcpdiag_ext,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq) <= 0) {
read_unlock_bh(&head->lock);
goto done;
}
next_normal:
++num;
}
......@@ -562,21 +564,22 @@ static int tcpdiag_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct inet_opt *inet = inet_sk(sk);
if (num < s_num)
continue;
goto next_dying;
if (r->id.tcpdiag_sport != inet->sport &&
r->id.tcpdiag_sport)
continue;
goto next_dying;
if (r->id.tcpdiag_dport != inet->dport &&
r->id.tcpdiag_dport)
continue;
goto next_dying;
if (bc && !tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), sk))
continue;
goto next_dying;
if (tcpdiag_fill(skb, sk, r->tcpdiag_ext,
NETLINK_CB(cb->skb).pid,
cb->nlh->nlmsg_seq) <= 0) {
read_unlock_bh(&head->lock);
goto done;
}
next_dying:
++num;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment