aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ping.c
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-05-31 11:05:50 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-04 15:56:14 -0400
commitd862e546142328d18377a4704be97f2ae301847a (patch)
tree4e451fb85634796e095e39ef5598a104314dcf19 /net/ipv4/ping.c
parent8cc785f6f429c2a3fb81745dc142cbd72a462c4a (diff)
net: ipv6: Implement /proc/net/icmp6.
The format is based on /proc/net/icmp and /proc/net/{udp,raw}6. Compiles and displays reasonable results with CONFIG_IPV6={n,m,y} Couldn't figure out how to test without CONFIG_PROC_FS enabled. Signed-off-by: Lorenzo Colitti <lorenzo@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ping.c')
-rw-r--r--net/ipv4/ping.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 8c2da9b8cd86..3552a45a6f86 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -1035,8 +1035,7 @@ static struct sock *ping_get_idx(struct seq_file *seq, loff_t pos)
1035 return pos ? NULL : sk; 1035 return pos ? NULL : sk;
1036} 1036}
1037 1037
1038static void *ping_seq_start(struct seq_file *seq, loff_t *pos, 1038void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family)
1039 sa_family_t family)
1040{ 1039{
1041 struct ping_iter_state *state = seq->private; 1040 struct ping_iter_state *state = seq->private;
1042 state->bucket = 0; 1041 state->bucket = 0;
@@ -1046,13 +1045,14 @@ static void *ping_seq_start(struct seq_file *seq, loff_t *pos,
1046 1045
1047 return *pos ? ping_get_idx(seq, *pos-1) : SEQ_START_TOKEN; 1046 return *pos ? ping_get_idx(seq, *pos-1) : SEQ_START_TOKEN;
1048} 1047}
1048EXPORT_SYMBOL_GPL(ping_seq_start);
1049 1049
1050static void *ping_v4_seq_start(struct seq_file *seq, loff_t *pos) 1050static void *ping_v4_seq_start(struct seq_file *seq, loff_t *pos)
1051{ 1051{
1052 return ping_seq_start(seq, pos, AF_INET); 1052 return ping_seq_start(seq, pos, AF_INET);
1053} 1053}
1054 1054
1055static void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1055void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1056{ 1056{
1057 struct sock *sk; 1057 struct sock *sk;
1058 1058
@@ -1064,11 +1064,13 @@ static void *ping_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1064 ++*pos; 1064 ++*pos;
1065 return sk; 1065 return sk;
1066} 1066}
1067EXPORT_SYMBOL_GPL(ping_seq_next);
1067 1068
1068static void ping_seq_stop(struct seq_file *seq, void *v) 1069void ping_seq_stop(struct seq_file *seq, void *v)
1069{ 1070{
1070 read_unlock_bh(&ping_table.lock); 1071 read_unlock_bh(&ping_table.lock);
1071} 1072}
1073EXPORT_SYMBOL_GPL(ping_seq_stop);
1072 1074
1073static void ping_v4_format_sock(struct sock *sp, struct seq_file *f, 1075static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
1074 int bucket, int *len) 1076 int bucket, int *len)
@@ -1122,12 +1124,13 @@ static int ping_seq_open(struct inode *inode, struct file *file)
1122 sizeof(struct ping_iter_state)); 1124 sizeof(struct ping_iter_state));
1123} 1125}
1124 1126
1125static const struct file_operations ping_seq_fops = { 1127const struct file_operations ping_seq_fops = {
1126 .open = ping_seq_open, 1128 .open = ping_seq_open,
1127 .read = seq_read, 1129 .read = seq_read,
1128 .llseek = seq_lseek, 1130 .llseek = seq_lseek,
1129 .release = seq_release_net, 1131 .release = seq_release_net,
1130}; 1132};
1133EXPORT_SYMBOL_GPL(ping_seq_fops);
1131 1134
1132static struct ping_seq_afinfo ping_v4_seq_afinfo = { 1135static struct ping_seq_afinfo ping_v4_seq_afinfo = {
1133 .name = "icmp", 1136 .name = "icmp",
@@ -1141,7 +1144,7 @@ static struct ping_seq_afinfo ping_v4_seq_afinfo = {
1141 }, 1144 },
1142}; 1145};
1143 1146
1144static int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo) 1147int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo)
1145{ 1148{
1146 struct proc_dir_entry *p; 1149 struct proc_dir_entry *p;
1147 p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net, 1150 p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,
@@ -1150,13 +1153,13 @@ static int ping_proc_register(struct net *net, struct ping_seq_afinfo *afinfo)
1150 return -ENOMEM; 1153 return -ENOMEM;
1151 return 0; 1154 return 0;
1152} 1155}
1156EXPORT_SYMBOL_GPL(ping_proc_register);
1153 1157
1154static void ping_proc_unregister(struct net *net, 1158void ping_proc_unregister(struct net *net, struct ping_seq_afinfo *afinfo)
1155 struct ping_seq_afinfo *afinfo)
1156{ 1159{
1157 remove_proc_entry(afinfo->name, net->proc_net); 1160 remove_proc_entry(afinfo->name, net->proc_net);
1158} 1161}
1159 1162EXPORT_SYMBOL_GPL(ping_proc_unregister);
1160 1163
1161static int __net_init ping_v4_proc_init_net(struct net *net) 1164static int __net_init ping_v4_proc_init_net(struct net *net)
1162{ 1165{