diff options
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r-- | net/ipv4/raw.c | 45 |
1 files changed, 10 insertions, 35 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 1b4d3355624a..abb3c9490c55 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
@@ -1003,11 +1003,12 @@ struct proto raw_prot = { | |||
1003 | static struct sock *raw_get_first(struct seq_file *seq) | 1003 | static struct sock *raw_get_first(struct seq_file *seq) |
1004 | { | 1004 | { |
1005 | struct sock *sk; | 1005 | struct sock *sk; |
1006 | struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file)); | ||
1006 | struct raw_iter_state *state = raw_seq_private(seq); | 1007 | struct raw_iter_state *state = raw_seq_private(seq); |
1007 | 1008 | ||
1008 | for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE; | 1009 | for (state->bucket = 0; state->bucket < RAW_HTABLE_SIZE; |
1009 | ++state->bucket) { | 1010 | ++state->bucket) { |
1010 | sk_for_each(sk, &state->h->ht[state->bucket]) | 1011 | sk_for_each(sk, &h->ht[state->bucket]) |
1011 | if (sock_net(sk) == seq_file_net(seq)) | 1012 | if (sock_net(sk) == seq_file_net(seq)) |
1012 | goto found; | 1013 | goto found; |
1013 | } | 1014 | } |
@@ -1018,6 +1019,7 @@ found: | |||
1018 | 1019 | ||
1019 | static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk) | 1020 | static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk) |
1020 | { | 1021 | { |
1022 | struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file)); | ||
1021 | struct raw_iter_state *state = raw_seq_private(seq); | 1023 | struct raw_iter_state *state = raw_seq_private(seq); |
1022 | 1024 | ||
1023 | do { | 1025 | do { |
@@ -1027,7 +1029,7 @@ try_again: | |||
1027 | } while (sk && sock_net(sk) != seq_file_net(seq)); | 1029 | } while (sk && sock_net(sk) != seq_file_net(seq)); |
1028 | 1030 | ||
1029 | if (!sk && ++state->bucket < RAW_HTABLE_SIZE) { | 1031 | if (!sk && ++state->bucket < RAW_HTABLE_SIZE) { |
1030 | sk = sk_head(&state->h->ht[state->bucket]); | 1032 | sk = sk_head(&h->ht[state->bucket]); |
1031 | goto try_again; | 1033 | goto try_again; |
1032 | } | 1034 | } |
1033 | return sk; | 1035 | return sk; |
@@ -1045,9 +1047,9 @@ static struct sock *raw_get_idx(struct seq_file *seq, loff_t pos) | |||
1045 | 1047 | ||
1046 | void *raw_seq_start(struct seq_file *seq, loff_t *pos) | 1048 | void *raw_seq_start(struct seq_file *seq, loff_t *pos) |
1047 | { | 1049 | { |
1048 | struct raw_iter_state *state = raw_seq_private(seq); | 1050 | struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file)); |
1049 | 1051 | ||
1050 | read_lock(&state->h->lock); | 1052 | read_lock(&h->lock); |
1051 | return *pos ? raw_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; | 1053 | return *pos ? raw_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; |
1052 | } | 1054 | } |
1053 | EXPORT_SYMBOL_GPL(raw_seq_start); | 1055 | EXPORT_SYMBOL_GPL(raw_seq_start); |
@@ -1067,9 +1069,9 @@ EXPORT_SYMBOL_GPL(raw_seq_next); | |||
1067 | 1069 | ||
1068 | void raw_seq_stop(struct seq_file *seq, void *v) | 1070 | void raw_seq_stop(struct seq_file *seq, void *v) |
1069 | { | 1071 | { |
1070 | struct raw_iter_state *state = raw_seq_private(seq); | 1072 | struct raw_hashinfo *h = PDE_DATA(file_inode(seq->file)); |
1071 | 1073 | ||
1072 | read_unlock(&state->h->lock); | 1074 | read_unlock(&h->lock); |
1073 | } | 1075 | } |
1074 | EXPORT_SYMBOL_GPL(raw_seq_stop); | 1076 | EXPORT_SYMBOL_GPL(raw_seq_stop); |
1075 | 1077 | ||
@@ -1110,37 +1112,10 @@ static const struct seq_operations raw_seq_ops = { | |||
1110 | .show = raw_seq_show, | 1112 | .show = raw_seq_show, |
1111 | }; | 1113 | }; |
1112 | 1114 | ||
1113 | int raw_seq_open(struct inode *ino, struct file *file, | ||
1114 | struct raw_hashinfo *h, const struct seq_operations *ops) | ||
1115 | { | ||
1116 | int err; | ||
1117 | struct raw_iter_state *i; | ||
1118 | |||
1119 | err = seq_open_net(ino, file, ops, sizeof(struct raw_iter_state)); | ||
1120 | if (err < 0) | ||
1121 | return err; | ||
1122 | |||
1123 | i = raw_seq_private((struct seq_file *)file->private_data); | ||
1124 | i->h = h; | ||
1125 | return 0; | ||
1126 | } | ||
1127 | EXPORT_SYMBOL_GPL(raw_seq_open); | ||
1128 | |||
1129 | static int raw_v4_seq_open(struct inode *inode, struct file *file) | ||
1130 | { | ||
1131 | return raw_seq_open(inode, file, &raw_v4_hashinfo, &raw_seq_ops); | ||
1132 | } | ||
1133 | |||
1134 | static const struct file_operations raw_seq_fops = { | ||
1135 | .open = raw_v4_seq_open, | ||
1136 | .read = seq_read, | ||
1137 | .llseek = seq_lseek, | ||
1138 | .release = seq_release_net, | ||
1139 | }; | ||
1140 | |||
1141 | static __net_init int raw_init_net(struct net *net) | 1115 | static __net_init int raw_init_net(struct net *net) |
1142 | { | 1116 | { |
1143 | if (!proc_create("raw", 0444, net->proc_net, &raw_seq_fops)) | 1117 | if (!proc_create_net_data("raw", 0444, net->proc_net, &raw_seq_ops, |
1118 | sizeof(struct raw_iter_state), &raw_v4_hashinfo)) | ||
1144 | return -ENOMEM; | 1119 | return -ENOMEM; |
1145 | 1120 | ||
1146 | return 0; | 1121 | return 0; |