summaryrefslogtreecommitdiffstats
path: root/net/ipv4/raw.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-04 13:00:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-04 13:00:01 -0400
commitcf626b0da78df6669c6b5f51ddd9a70a0702e579 (patch)
tree45d29a4cb7574aed7f140814ed22088ded21c291 /net/ipv4/raw.c
parent9c50eafc32ddbd166c8a2bbaecd4ad201c452b14 (diff)
parent5ef03dbd91855544cd4c7c1910c3ef5226ee87e8 (diff)
Merge branch 'hch.procfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull procfs updates from Al Viro: "Christoph's proc_create_... cleanups series" * 'hch.procfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (44 commits) xfs, proc: hide unused xfs procfs helpers isdn/gigaset: add back gigaset_procinfo assignment proc: update SIZEOF_PDE_INLINE_NAME for the new pde fields tty: replace ->proc_fops with ->proc_show ide: replace ->proc_fops with ->proc_show ide: remove ide_driver_proc_write isdn: replace ->proc_fops with ->proc_show atm: switch to proc_create_seq_private atm: simplify procfs code bluetooth: switch to proc_create_seq_data netfilter/x_tables: switch to proc_create_seq_private netfilter/xt_hashlimit: switch to proc_create_{seq,single}_data neigh: switch to proc_create_seq_data hostap: switch to proc_create_{seq,single}_data bonding: switch to proc_create_seq_data rtc/proc: switch to proc_create_single_data drbd: switch to proc_create_single resource: switch to proc_create_seq_data staging/rtl8192u: simplify procfs code jfs: simplify procfs code ...
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r--net/ipv4/raw.c45
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 = {
1003static struct sock *raw_get_first(struct seq_file *seq) 1003static 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
1019static struct sock *raw_get_next(struct seq_file *seq, struct sock *sk) 1020static 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
1046void *raw_seq_start(struct seq_file *seq, loff_t *pos) 1048void *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}
1053EXPORT_SYMBOL_GPL(raw_seq_start); 1055EXPORT_SYMBOL_GPL(raw_seq_start);
@@ -1067,9 +1069,9 @@ EXPORT_SYMBOL_GPL(raw_seq_next);
1067 1069
1068void raw_seq_stop(struct seq_file *seq, void *v) 1070void 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}
1074EXPORT_SYMBOL_GPL(raw_seq_stop); 1076EXPORT_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
1113int 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}
1127EXPORT_SYMBOL_GPL(raw_seq_open);
1128
1129static 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
1134static 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
1141static __net_init int raw_init_net(struct net *net) 1115static __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;