aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/raw.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-01-14 08:35:57 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:02:06 -0500
commitf51d599fbecf4881a36466f0355da6b0b346ea70 (patch)
tree46cd843dd44f1b74bb69f1a2b207260e468ae1be /net/ipv4/raw.c
parentbe185884b31093555dc10aa32efe0b73c835312e (diff)
[NETNS][RAW]: Make /proc/net/raw(6) show per-namespace socket list.
Pull the struct net pointer up to the showing functions to filter the sockets depending on their namespaces. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r--net/ipv4/raw.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index a490a9d54712..4e95372a78e7 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -860,7 +860,8 @@ static struct sock *raw_get_first(struct seq_file *seq)
860 struct hlist_node *node; 860 struct hlist_node *node;
861 861
862 sk_for_each(sk, node, &state->h->ht[state->bucket]) 862 sk_for_each(sk, node, &state->h->ht[state->bucket])
863 if (sk->sk_family == state->family) 863 if (sk->sk_net == state->p.net &&
864 sk->sk_family == state->family)
864 goto found; 865 goto found;
865 } 866 }
866 sk = NULL; 867 sk = NULL;
@@ -876,7 +877,8 @@ static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk)
876 sk = sk_next(sk); 877 sk = sk_next(sk);
877try_again: 878try_again:
878 ; 879 ;
879 } while (sk && sk->sk_family != state->family); 880 } while (sk && sk->sk_net != state->p.net &&
881 sk->sk_family != state->family);
880 882
881 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) { 883 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
882 sk = sk_head(&state->h->ht[state->bucket]); 884 sk = sk_head(&state->h->ht[state->bucket]);
@@ -970,16 +972,18 @@ static const struct seq_operations raw_seq_ops = {
970 .show = raw_seq_show, 972 .show = raw_seq_show,
971}; 973};
972 974
973int raw_seq_open(struct file *file, struct raw_hashinfo *h, 975int raw_seq_open(struct inode *ino, struct file *file, struct raw_hashinfo *h,
974 unsigned short family) 976 unsigned short family)
975{ 977{
978 int err;
976 struct raw_iter_state *i; 979 struct raw_iter_state *i;
977 980
978 i = __seq_open_private(file, &raw_seq_ops, 981 err = seq_open_net(ino, file, &raw_seq_ops,
979 sizeof(struct raw_iter_state)); 982 sizeof(struct raw_iter_state));
980 if (i == NULL) 983 if (err < 0)
981 return -ENOMEM; 984 return err;
982 985
986 i = raw_seq_private((struct seq_file *)file->private_data);
983 i->h = h; 987 i->h = h;
984 i->family = family; 988 i->family = family;
985 return 0; 989 return 0;
@@ -988,7 +992,7 @@ EXPORT_SYMBOL_GPL(raw_seq_open);
988 992
989static int raw_v4_seq_open(struct inode *inode, struct file *file) 993static int raw_v4_seq_open(struct inode *inode, struct file *file)
990{ 994{
991 return raw_seq_open(file, &raw_v4_hashinfo, PF_INET); 995 return raw_seq_open(inode, file, &raw_v4_hashinfo, PF_INET);
992} 996}
993 997
994static const struct file_operations raw_seq_fops = { 998static const struct file_operations raw_seq_fops = {
@@ -996,7 +1000,7 @@ static const struct file_operations raw_seq_fops = {
996 .open = raw_v4_seq_open, 1000 .open = raw_v4_seq_open,
997 .read = seq_read, 1001 .read = seq_read,
998 .llseek = seq_lseek, 1002 .llseek = seq_lseek,
999 .release = seq_release_private, 1003 .release = seq_release_net,
1000}; 1004};
1001 1005
1002int __init raw_proc_init(void) 1006int __init raw_proc_init(void)