Subject: [PATCH] nethost: Update proc so that we only print tcp sockets for our host. From: Eric W. Biederman Date: 1133874807 -0700 --- include/net/tcp.h | 1 + net/ipv4/tcp_ipv4.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) 99799c25022f37a3d19c3a2b1c17ee6e69e6edb9 diff --git a/include/net/tcp.h b/include/net/tcp.h index f8d3451..99d2609 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1174,6 +1174,7 @@ struct tcp_seq_afinfo { struct tcp_iter_state { sa_family_t family; + struct nethost *host; enum tcp_seq_states state; struct sock *syn_wait_sk; int bucket, sbucket, num, uid; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a66d58a..fc9dd2d 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1529,7 +1529,8 @@ static void *listening_get_next(struct s req = req->dl_next; while (1) { while (req) { - if (req->rsk_ops->family == st->family) { + if ((req->rsk_ops->family == st->family) && + (req->sk->sk_host == st->host)) { cur = req; goto out; } @@ -1553,7 +1554,7 @@ get_req: } get_sk: sk_for_each_from(sk, node) { - if (sk->sk_family == st->family) { + if ((sk->sk_family == st->family) && (sk->sk_host == st->host)) { cur = sk; goto out; } @@ -1604,7 +1605,7 @@ static void *established_get_first(struc read_lock(&tcp_hashinfo.ehash[st->bucket].lock); sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) { - if (sk->sk_family != st->family) { + if ((sk->sk_family != st->family) || (sk->sk_host != st->host)) { continue; } rc = sk; @@ -1663,7 +1664,7 @@ get_tw: sk = sk_next(sk); sk_for_each_from(sk, node) { - if (sk->sk_family == st->family) + if ((sk->sk_family == st->family) && (sk->sk_host == st->host)) goto found; } @@ -1784,6 +1785,7 @@ static int tcp_seq_open(struct inode *in return -ENOMEM; memset(s, 0, sizeof(*s)); s->family = afinfo->family; + s->host = current->host; s->seq_ops.start = tcp_seq_start; s->seq_ops.next = tcp_seq_next; s->seq_ops.show = afinfo->seq_show; -- 1.0.GIT