diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2013-05-31 11:05:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-04 15:56:14 -0400 |
commit | d862e546142328d18377a4704be97f2ae301847a (patch) | |
tree | 4e451fb85634796e095e39ef5598a104314dcf19 /net/ipv6 | |
parent | 8cc785f6f429c2a3fb81745dc142cbd72a462c4a (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/ipv6')
-rw-r--r-- | net/ipv6/ping.c | 102 |
1 files changed, 79 insertions, 23 deletions
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c index a6462d657c15..62ac5f2e0aaf 100644 --- a/net/ipv6/ping.c +++ b/net/ipv6/ping.c | |||
@@ -78,29 +78,6 @@ int dummy_ipv6_chk_addr(struct net *net, const struct in6_addr *addr, | |||
78 | return 0; | 78 | return 0; |
79 | } | 79 | } |
80 | 80 | ||
81 | int __init pingv6_init(void) | ||
82 | { | ||
83 | pingv6_ops.ipv6_recv_error = ipv6_recv_error; | ||
84 | pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl; | ||
85 | pingv6_ops.icmpv6_err_convert = icmpv6_err_convert; | ||
86 | pingv6_ops.ipv6_icmp_error = ipv6_icmp_error; | ||
87 | pingv6_ops.ipv6_chk_addr = ipv6_chk_addr; | ||
88 | return inet6_register_protosw(&pingv6_protosw); | ||
89 | } | ||
90 | |||
91 | /* This never gets called because it's not possible to unload the ipv6 module, | ||
92 | * but just in case. | ||
93 | */ | ||
94 | void pingv6_exit(void) | ||
95 | { | ||
96 | pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error; | ||
97 | pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl; | ||
98 | pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert; | ||
99 | pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error; | ||
100 | pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr; | ||
101 | inet6_unregister_protosw(&pingv6_protosw); | ||
102 | } | ||
103 | |||
104 | int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | 81 | int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
105 | size_t len) | 82 | size_t len) |
106 | { | 83 | { |
@@ -214,3 +191,82 @@ int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
214 | 191 | ||
215 | return err; | 192 | return err; |
216 | } | 193 | } |
194 | |||
195 | #ifdef CONFIG_PROC_FS | ||
196 | static void *ping_v6_seq_start(struct seq_file *seq, loff_t *pos) | ||
197 | { | ||
198 | return ping_seq_start(seq, pos, AF_INET6); | ||
199 | } | ||
200 | |||
201 | int ping_v6_seq_show(struct seq_file *seq, void *v) | ||
202 | { | ||
203 | if (v == SEQ_START_TOKEN) { | ||
204 | seq_puts(seq, IPV6_SEQ_DGRAM_HEADER); | ||
205 | } else { | ||
206 | int bucket = ((struct ping_iter_state *) seq->private)->bucket; | ||
207 | struct inet_sock *inet = inet_sk(v); | ||
208 | __u16 srcp = ntohs(inet->inet_sport); | ||
209 | __u16 destp = ntohs(inet->inet_dport); | ||
210 | ip6_dgram_sock_seq_show(seq, v, srcp, destp, bucket); | ||
211 | } | ||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | static struct ping_seq_afinfo ping_v6_seq_afinfo = { | ||
216 | .name = "icmp6", | ||
217 | .family = AF_INET6, | ||
218 | .seq_fops = &ping_seq_fops, | ||
219 | .seq_ops = { | ||
220 | .start = ping_v6_seq_start, | ||
221 | .show = ping_v6_seq_show, | ||
222 | .next = ping_seq_next, | ||
223 | .stop = ping_seq_stop, | ||
224 | }, | ||
225 | }; | ||
226 | |||
227 | static int __net_init ping_v6_proc_init_net(struct net *net) | ||
228 | { | ||
229 | return ping_proc_register(net, &ping_v6_seq_afinfo); | ||
230 | } | ||
231 | |||
232 | static void __net_init ping_v6_proc_exit_net(struct net *net) | ||
233 | { | ||
234 | return ping_proc_unregister(net, &ping_v6_seq_afinfo); | ||
235 | } | ||
236 | |||
237 | static struct pernet_operations ping_v6_net_ops = { | ||
238 | .init = ping_v6_proc_init_net, | ||
239 | .exit = ping_v6_proc_exit_net, | ||
240 | }; | ||
241 | #endif | ||
242 | |||
243 | int __init pingv6_init(void) | ||
244 | { | ||
245 | #ifdef CONFIG_PROC_FS | ||
246 | int ret = register_pernet_subsys(&ping_v6_net_ops); | ||
247 | if (ret) | ||
248 | return ret; | ||
249 | #endif | ||
250 | pingv6_ops.ipv6_recv_error = ipv6_recv_error; | ||
251 | pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl; | ||
252 | pingv6_ops.icmpv6_err_convert = icmpv6_err_convert; | ||
253 | pingv6_ops.ipv6_icmp_error = ipv6_icmp_error; | ||
254 | pingv6_ops.ipv6_chk_addr = ipv6_chk_addr; | ||
255 | return inet6_register_protosw(&pingv6_protosw); | ||
256 | } | ||
257 | |||
258 | /* This never gets called because it's not possible to unload the ipv6 module, | ||
259 | * but just in case. | ||
260 | */ | ||
261 | void pingv6_exit(void) | ||
262 | { | ||
263 | pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error; | ||
264 | pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl; | ||
265 | pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert; | ||
266 | pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error; | ||
267 | pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr; | ||
268 | #ifdef CONFIG_PROC_FS | ||
269 | unregister_pernet_subsys(&ping_v6_net_ops); | ||
270 | #endif | ||
271 | inet6_unregister_protosw(&pingv6_protosw); | ||
272 | } | ||