Blame view

net/ipv6/proc.c 10.5 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
  /*
   * INET		An implementation of the TCP/IP protocol suite for the LINUX
   *		operating system.  INET is implemented using the  BSD Socket
   *		interface as the means of communication with the user level.
   *
   *		This file implements the various access functions for the
   *		PROC file system.  This is very similar to the IPv4 version,
   *		except it reports the sockets in the INET6 address family.
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
12
13
14
15
16
17
   * Authors:	David S. Miller (davem@caip.rutgers.edu)
   * 		YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
   *
   *		This program is free software; you can redistribute it and/or
   *		modify it under the terms of the GNU General Public License
   *		as published by the Free Software Foundation; either version
   *		2 of the License, or (at your option) any later version.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
19
20
21
22
23
  #include <linux/socket.h>
  #include <linux/net.h>
  #include <linux/ipv6.h>
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
  #include <linux/stddef.h>
bc3b2d7fb   Paul Gortmaker   net: Add export.h...
24
  #include <linux/export.h>
457c4cbc5   Eric W. Biederman   [NET]: Make /proc...
25
  #include <net/net_namespace.h>
7f7d9a6b9   Herbert Xu   [IPV6]: Consolida...
26
  #include <net/ip.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
28
  #include <net/sock.h>
  #include <net/tcp.h>
1781f7f58   Herbert Xu   [UDP]: Restore mi...
29
  #include <net/udp.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
31
  #include <net/transp_v6.h>
  #include <net/ipv6.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
33
  static int sockstat6_seq_show(struct seq_file *seq, void *v)
  {
dfb12eb70   Pavel Emelyanov   [IPV6][NETNS]: Di...
34
  	struct net *net = seq->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
36
  	seq_printf(seq, "TCP6: inuse %d
  ",
dfb12eb70   Pavel Emelyanov   [IPV6][NETNS]: Di...
37
  		       sock_prot_inuse_get(net, &tcpv6_prot));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38
39
  	seq_printf(seq, "UDP6: inuse %d
  ",
dfb12eb70   Pavel Emelyanov   [IPV6][NETNS]: Di...
40
  		       sock_prot_inuse_get(net, &udpv6_prot));
ba4e58eca   Gerrit Renker   [NET]: Supporting...
41
42
  	seq_printf(seq, "UDPLITE6: inuse %d
  ",
dfb12eb70   Pavel Emelyanov   [IPV6][NETNS]: Di...
43
  			sock_prot_inuse_get(net, &udplitev6_prot));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
45
  	seq_printf(seq, "RAW6: inuse %d
  ",
dfb12eb70   Pavel Emelyanov   [IPV6][NETNS]: Di...
46
  		       sock_prot_inuse_get(net, &rawv6_prot));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
47
48
  	seq_printf(seq, "FRAG6: inuse %d memory %d
  ",
dfb12eb70   Pavel Emelyanov   [IPV6][NETNS]: Di...
49
  		       ip6_frag_nqueues(net), ip6_frag_mem(net));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
51
  	return 0;
  }
35f0a5df6   Denis V. Lunev   ipv6: consolidate...
52
53
54
55
56
57
58
59
60
61
62
63
  static int sockstat6_seq_open(struct inode *inode, struct file *file)
  {
  	return single_open_net(inode, file, sockstat6_seq_show);
  }
  
  static const struct file_operations sockstat6_seq_fops = {
  	.owner	 = THIS_MODULE,
  	.open	 = sockstat6_seq_open,
  	.read	 = seq_read,
  	.llseek	 = seq_lseek,
  	.release = single_release_net,
  };
5833929cc   Alexey Dobriyan   net: constify MIB...
64
  static const struct snmp_mib snmp6_ipstats_list[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
65
  /* ipv6 mib according to RFC 2465 */
edf391ff1   Neil Horman   snmp: add missing...
66
  	SNMP_MIB_ITEM("Ip6InReceives", IPSTATS_MIB_INPKTS),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
67
68
69
70
71
72
73
74
75
  	SNMP_MIB_ITEM("Ip6InHdrErrors", IPSTATS_MIB_INHDRERRORS),
  	SNMP_MIB_ITEM("Ip6InTooBigErrors", IPSTATS_MIB_INTOOBIGERRORS),
  	SNMP_MIB_ITEM("Ip6InNoRoutes", IPSTATS_MIB_INNOROUTES),
  	SNMP_MIB_ITEM("Ip6InAddrErrors", IPSTATS_MIB_INADDRERRORS),
  	SNMP_MIB_ITEM("Ip6InUnknownProtos", IPSTATS_MIB_INUNKNOWNPROTOS),
  	SNMP_MIB_ITEM("Ip6InTruncatedPkts", IPSTATS_MIB_INTRUNCATEDPKTS),
  	SNMP_MIB_ITEM("Ip6InDiscards", IPSTATS_MIB_INDISCARDS),
  	SNMP_MIB_ITEM("Ip6InDelivers", IPSTATS_MIB_INDELIVERS),
  	SNMP_MIB_ITEM("Ip6OutForwDatagrams", IPSTATS_MIB_OUTFORWDATAGRAMS),
edf391ff1   Neil Horman   snmp: add missing...
76
  	SNMP_MIB_ITEM("Ip6OutRequests", IPSTATS_MIB_OUTPKTS),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
79
80
81
82
83
84
85
86
87
  	SNMP_MIB_ITEM("Ip6OutDiscards", IPSTATS_MIB_OUTDISCARDS),
  	SNMP_MIB_ITEM("Ip6OutNoRoutes", IPSTATS_MIB_OUTNOROUTES),
  	SNMP_MIB_ITEM("Ip6ReasmTimeout", IPSTATS_MIB_REASMTIMEOUT),
  	SNMP_MIB_ITEM("Ip6ReasmReqds", IPSTATS_MIB_REASMREQDS),
  	SNMP_MIB_ITEM("Ip6ReasmOKs", IPSTATS_MIB_REASMOKS),
  	SNMP_MIB_ITEM("Ip6ReasmFails", IPSTATS_MIB_REASMFAILS),
  	SNMP_MIB_ITEM("Ip6FragOKs", IPSTATS_MIB_FRAGOKS),
  	SNMP_MIB_ITEM("Ip6FragFails", IPSTATS_MIB_FRAGFAILS),
  	SNMP_MIB_ITEM("Ip6FragCreates", IPSTATS_MIB_FRAGCREATES),
  	SNMP_MIB_ITEM("Ip6InMcastPkts", IPSTATS_MIB_INMCASTPKTS),
  	SNMP_MIB_ITEM("Ip6OutMcastPkts", IPSTATS_MIB_OUTMCASTPKTS),
edf391ff1   Neil Horman   snmp: add missing...
88
89
90
91
92
93
  	SNMP_MIB_ITEM("Ip6InOctets", IPSTATS_MIB_INOCTETS),
  	SNMP_MIB_ITEM("Ip6OutOctets", IPSTATS_MIB_OUTOCTETS),
  	SNMP_MIB_ITEM("Ip6InMcastOctets", IPSTATS_MIB_INMCASTOCTETS),
  	SNMP_MIB_ITEM("Ip6OutMcastOctets", IPSTATS_MIB_OUTMCASTOCTETS),
  	SNMP_MIB_ITEM("Ip6InBcastOctets", IPSTATS_MIB_INBCASTOCTETS),
  	SNMP_MIB_ITEM("Ip6OutBcastOctets", IPSTATS_MIB_OUTBCASTOCTETS),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94
95
  	SNMP_MIB_SENTINEL
  };
5833929cc   Alexey Dobriyan   net: constify MIB...
96
  static const struct snmp_mib snmp6_icmp6_list[] = {
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
97
  /* icmpv6 mib according to RFC 2466 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
98
99
  	SNMP_MIB_ITEM("Icmp6InMsgs", ICMP6_MIB_INMSGS),
  	SNMP_MIB_ITEM("Icmp6InErrors", ICMP6_MIB_INERRORS),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
  	SNMP_MIB_ITEM("Icmp6OutMsgs", ICMP6_MIB_OUTMSGS),
1f8438a85   Eric Dumazet   icmp: Account for...
101
  	SNMP_MIB_ITEM("Icmp6OutErrors", ICMP6_MIB_OUTERRORS),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
103
  	SNMP_MIB_SENTINEL
  };
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
104
  /* RFC 4293 v6 ICMPMsgStatsTable; named items for RFC 2466 compatibility */
36cbd3dcc   Jan Engelhardt   net: mark read-on...
105
  static const char *const icmp6type2name[256] = {
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
106
107
108
109
  	[ICMPV6_DEST_UNREACH] = "DestUnreachs",
  	[ICMPV6_PKT_TOOBIG] = "PktTooBigs",
  	[ICMPV6_TIME_EXCEED] = "TimeExcds",
  	[ICMPV6_PARAMPROB] = "ParmProblems",
fa95c2832   Wang Chen   [IPV6]: RFC 2011 ...
110
  	[ICMPV6_ECHO_REQUEST] = "Echos",
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
111
112
113
114
115
116
117
118
119
  	[ICMPV6_ECHO_REPLY] = "EchoReplies",
  	[ICMPV6_MGM_QUERY] = "GroupMembQueries",
  	[ICMPV6_MGM_REPORT] = "GroupMembResponses",
  	[ICMPV6_MGM_REDUCTION] = "GroupMembReductions",
  	[ICMPV6_MLD2_REPORT] = "MLDv2Reports",
  	[NDISC_ROUTER_ADVERTISEMENT] = "RouterAdvertisements",
  	[NDISC_ROUTER_SOLICITATION] = "RouterSolicits",
  	[NDISC_NEIGHBOUR_ADVERTISEMENT] = "NeighborAdvertisements",
  	[NDISC_NEIGHBOUR_SOLICITATION] = "NeighborSolicits",
fa95c2832   Wang Chen   [IPV6]: RFC 2011 ...
120
  	[NDISC_REDIRECT] = "Redirects",
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
121
  };
5833929cc   Alexey Dobriyan   net: constify MIB...
122
  static const struct snmp_mib snmp6_udp6_list[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
123
124
125
126
  	SNMP_MIB_ITEM("Udp6InDatagrams", UDP_MIB_INDATAGRAMS),
  	SNMP_MIB_ITEM("Udp6NoPorts", UDP_MIB_NOPORTS),
  	SNMP_MIB_ITEM("Udp6InErrors", UDP_MIB_INERRORS),
  	SNMP_MIB_ITEM("Udp6OutDatagrams", UDP_MIB_OUTDATAGRAMS),
870be3925   Eric Dumazet   ipv6/udp: report ...
127
128
  	SNMP_MIB_ITEM("Udp6RcvbufErrors", UDP_MIB_RCVBUFERRORS),
  	SNMP_MIB_ITEM("Udp6SndbufErrors", UDP_MIB_SNDBUFERRORS),
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
129
130
  	SNMP_MIB_SENTINEL
  };
5833929cc   Alexey Dobriyan   net: constify MIB...
131
  static const struct snmp_mib snmp6_udplite6_list[] = {
ba4e58eca   Gerrit Renker   [NET]: Supporting...
132
133
134
135
  	SNMP_MIB_ITEM("UdpLite6InDatagrams", UDP_MIB_INDATAGRAMS),
  	SNMP_MIB_ITEM("UdpLite6NoPorts", UDP_MIB_NOPORTS),
  	SNMP_MIB_ITEM("UdpLite6InErrors", UDP_MIB_INERRORS),
  	SNMP_MIB_ITEM("UdpLite6OutDatagrams", UDP_MIB_OUTDATAGRAMS),
870be3925   Eric Dumazet   ipv6/udp: report ...
136
137
  	SNMP_MIB_ITEM("UdpLite6RcvbufErrors", UDP_MIB_RCVBUFERRORS),
  	SNMP_MIB_ITEM("UdpLite6SndbufErrors", UDP_MIB_SNDBUFERRORS),
ba4e58eca   Gerrit Renker   [NET]: Supporting...
138
139
  	SNMP_MIB_SENTINEL
  };
2a24444f8   Eric Dumazet   ipv6: reduce perc...
140
  static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, atomic_long_t *smib)
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
141
  {
5ece6c2dd   Alexey Dobriyan   net: fix tiny out...
142
  	char name[32];
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
143
144
145
146
147
  	int i;
  
  	/* print by name -- deprecated items */
  	for (i = 0; i < ICMP6MSG_MIB_MAX; i++) {
  		int icmptype;
36cbd3dcc   Jan Engelhardt   net: mark read-on...
148
  		const char *p;
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
149
150
151
152
153
  
  		icmptype = i & 0xff;
  		p = icmp6type2name[icmptype];
  		if (!p)	/* don't print un-named types here */
  			continue;
5ece6c2dd   Alexey Dobriyan   net: fix tiny out...
154
  		snprintf(name, sizeof(name), "Icmp6%s%s",
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
155
156
157
  			i & 0x100 ? "Out" : "In", p);
  		seq_printf(seq, "%-32s\t%lu
  ", name,
2a24444f8   Eric Dumazet   ipv6: reduce perc...
158
  			   atomic_long_read(smib + i));
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
159
160
161
162
163
  	}
  
  	/* print by number (nonzero only) - ICMPMsgStat format */
  	for (i = 0; i < ICMP6MSG_MIB_MAX; i++) {
  		unsigned long val;
2a24444f8   Eric Dumazet   ipv6: reduce perc...
164
  		val = atomic_long_read(smib + i);
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
165
166
  		if (!val)
  			continue;
5ece6c2dd   Alexey Dobriyan   net: fix tiny out...
167
  		snprintf(name, sizeof(name), "Icmp6%sType%u",
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
168
169
170
171
  			i & 0x100 ?  "Out" : "In", i & 0xff);
  		seq_printf(seq, "%-32s\t%lu
  ", name, val);
  	}
14878f75a   David L Stevens   [IPV6]: Add ICMPM...
172
  }
be281e554   Eric Dumazet   ipv6: reduce per ...
173
174
175
176
177
  /* can be called either with percpu mib (pcpumib != NULL),
   * or shared one (smib != NULL)
   */
  static void snmp6_seq_show_item(struct seq_file *seq, void __percpu **pcpumib,
  				atomic_long_t *smib,
5833929cc   Alexey Dobriyan   net: constify MIB...
178
  				const struct snmp_mib *itemlist)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
179
180
  {
  	int i;
be281e554   Eric Dumazet   ipv6: reduce per ...
181
  	unsigned long val;
4ce3c183f   Eric Dumazet   snmp: 64bit ipsta...
182

be281e554   Eric Dumazet   ipv6: reduce per ...
183
184
185
186
187
188
189
  	for (i = 0; itemlist[i].name; i++) {
  		val = pcpumib ?
  			snmp_fold_field(pcpumib, itemlist[i].entry) :
  			atomic_long_read(smib + itemlist[i].entry);
  		seq_printf(seq, "%-32s\t%lu
  ", itemlist[i].name, val);
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
190
  }
4ce3c183f   Eric Dumazet   snmp: 64bit ipsta...
191
192
193
194
195
196
197
198
199
200
  static void snmp6_seq_show_item64(struct seq_file *seq, void __percpu **mib,
  				  const struct snmp_mib *itemlist, size_t syncpoff)
  {
  	int i;
  
  	for (i = 0; itemlist[i].name; i++)
  		seq_printf(seq, "%-32s\t%llu
  ", itemlist[i].name,
  			   snmp_fold_field64(mib, itemlist[i].entry, syncpoff));
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
201
202
  static int snmp6_seq_show(struct seq_file *seq, void *v)
  {
2b4209e4b   Denis V. Lunev   netns: register g...
203
  	struct net *net = (struct net *)seq->private;
4ce3c183f   Eric Dumazet   snmp: 64bit ipsta...
204
205
  	snmp6_seq_show_item64(seq, (void __percpu **)net->mib.ipv6_statistics,
  			    snmp6_ipstats_list, offsetof(struct ipstats_mib, syncp));
7d720c3e4   Tejun Heo   percpu: add __per...
206
  	snmp6_seq_show_item(seq, (void __percpu **)net->mib.icmpv6_statistics,
be281e554   Eric Dumazet   ipv6: reduce per ...
207
  			    NULL, snmp6_icmp6_list);
2a24444f8   Eric Dumazet   ipv6: reduce perc...
208
  	snmp6_seq_show_icmpv6msg(seq, net->mib.icmpv6msg_statistics->mibs);
7d720c3e4   Tejun Heo   percpu: add __per...
209
  	snmp6_seq_show_item(seq, (void __percpu **)net->mib.udp_stats_in6,
be281e554   Eric Dumazet   ipv6: reduce per ...
210
  			    NULL, snmp6_udp6_list);
7d720c3e4   Tejun Heo   percpu: add __per...
211
  	snmp6_seq_show_item(seq, (void __percpu **)net->mib.udplite_stats_in6,
be281e554   Eric Dumazet   ipv6: reduce per ...
212
  			    NULL, snmp6_udplite6_list);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
213
214
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
215
216
  static int snmp6_seq_open(struct inode *inode, struct file *file)
  {
2b4209e4b   Denis V. Lunev   netns: register g...
217
  	return single_open_net(inode, file, snmp6_seq_show);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
218
  }
9a32144e9   Arjan van de Ven   [PATCH] mark stru...
219
  static const struct file_operations snmp6_seq_fops = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
220
221
222
223
  	.owner	 = THIS_MODULE,
  	.open	 = snmp6_seq_open,
  	.read	 = seq_read,
  	.llseek	 = seq_lseek,
2b4209e4b   Denis V. Lunev   netns: register g...
224
  	.release = single_release_net,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
225
  };
7b43ccecc   Denis V. Lunev   ipv6: separate se...
226
227
228
229
230
231
  static int snmp6_dev_seq_show(struct seq_file *seq, void *v)
  {
  	struct inet6_dev *idev = (struct inet6_dev *)seq->private;
  
  	seq_printf(seq, "%-32s\t%u
  ", "ifIndex", idev->dev->ifindex);
be281e554   Eric Dumazet   ipv6: reduce per ...
232
  	snmp6_seq_show_item(seq, (void __percpu **)idev->stats.ipv6, NULL,
7d720c3e4   Tejun Heo   percpu: add __per...
233
  			    snmp6_ipstats_list);
be281e554   Eric Dumazet   ipv6: reduce per ...
234
  	snmp6_seq_show_item(seq, NULL, idev->stats.icmpv6dev->mibs,
7d720c3e4   Tejun Heo   percpu: add __per...
235
  			    snmp6_icmp6_list);
2a24444f8   Eric Dumazet   ipv6: reduce perc...
236
  	snmp6_seq_show_icmpv6msg(seq, idev->stats.icmpv6msgdev->mibs);
7b43ccecc   Denis V. Lunev   ipv6: separate se...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
  	return 0;
  }
  
  static int snmp6_dev_seq_open(struct inode *inode, struct file *file)
  {
  	return single_open(file, snmp6_dev_seq_show, PDE(inode)->data);
  }
  
  static const struct file_operations snmp6_dev_seq_fops = {
  	.owner	 = THIS_MODULE,
  	.open	 = snmp6_dev_seq_open,
  	.read	 = seq_read,
  	.llseek	 = seq_lseek,
  	.release = single_release,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
252
253
254
  int snmp6_register_dev(struct inet6_dev *idev)
  {
  	struct proc_dir_entry *p;
835bcc049   Denis V. Lunev   netns: move /proc...
255
  	struct net *net;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
256
257
258
  
  	if (!idev || !idev->dev)
  		return -EINVAL;
835bcc049   Denis V. Lunev   netns: move /proc...
259
  	net = dev_net(idev->dev);
835bcc049   Denis V. Lunev   netns: move /proc...
260
  	if (!net->mib.proc_net_devsnmp6)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
261
  		return -ENOENT;
0bb53a66f   Denis V. Lunev   ipv6: assign PDE-...
262
  	p = proc_create_data(idev->dev->name, S_IRUGO,
7b43ccecc   Denis V. Lunev   ipv6: separate se...
263
264
  			     net->mib.proc_net_devsnmp6,
  			     &snmp6_dev_seq_fops, idev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
265
266
  	if (!p)
  		return -ENOMEM;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
267
268
269
270
271
272
  	idev->stats.proc_dir_entry = p;
  	return 0;
  }
  
  int snmp6_unregister_dev(struct inet6_dev *idev)
  {
835bcc049   Denis V. Lunev   netns: move /proc...
273
274
  	struct net *net = dev_net(idev->dev);
  	if (!net->mib.proc_net_devsnmp6)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
275
  		return -ENOENT;
c3f6c21d6   Jiri Slaby   NET: ipv6, remove...
276
  	if (!idev->stats.proc_dir_entry)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
277
278
  		return -EINVAL;
  	remove_proc_entry(idev->stats.proc_dir_entry->name,
835bcc049   Denis V. Lunev   netns: move /proc...
279
  			  net->mib.proc_net_devsnmp6);
5632c5152   Stephen Hemminger   [IPV6]: Track dev...
280
  	idev->stats.proc_dir_entry = NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
281
282
  	return 0;
  }
2c8c1e729   Alexey Dobriyan   net: spread __net...
283
  static int __net_init ipv6_proc_init_net(struct net *net)
d0538ca35   Pavel Emelyanov   [SOCK][NETNS]: Re...
284
285
286
287
  {
  	if (!proc_net_fops_create(net, "sockstat6", S_IRUGO,
  			&sockstat6_seq_fops))
  		return -ENOMEM;
06f38527d   Denis V. Lunev   netns: register /...
288
289
290
291
292
293
294
  
  	if (!proc_net_fops_create(net, "snmp6", S_IRUGO, &snmp6_seq_fops))
  		goto proc_snmp6_fail;
  
  	net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
  	if (!net->mib.proc_net_devsnmp6)
  		goto proc_dev_snmp6_fail;
d0538ca35   Pavel Emelyanov   [SOCK][NETNS]: Re...
295
  	return 0;
06f38527d   Denis V. Lunev   netns: register /...
296
297
298
299
300
301
  
  proc_snmp6_fail:
  	proc_net_remove(net, "sockstat6");
  proc_dev_snmp6_fail:
  	proc_net_remove(net, "dev_snmp6");
  	return -ENOMEM;
d0538ca35   Pavel Emelyanov   [SOCK][NETNS]: Re...
302
  }
2c8c1e729   Alexey Dobriyan   net: spread __net...
303
  static void __net_exit ipv6_proc_exit_net(struct net *net)
d0538ca35   Pavel Emelyanov   [SOCK][NETNS]: Re...
304
305
  {
  	proc_net_remove(net, "sockstat6");
06f38527d   Denis V. Lunev   netns: register /...
306
307
  	proc_net_remove(net, "dev_snmp6");
  	proc_net_remove(net, "snmp6");
d0538ca35   Pavel Emelyanov   [SOCK][NETNS]: Re...
308
309
310
311
312
313
  }
  
  static struct pernet_operations ipv6_proc_ops = {
  	.init = ipv6_proc_init_net,
  	.exit = ipv6_proc_exit_net,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
314
315
  int __init ipv6_misc_proc_init(void)
  {
06f38527d   Denis V. Lunev   netns: register /...
316
  	return register_pernet_subsys(&ipv6_proc_ops);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
317
318
319
320
  }
  
  void ipv6_misc_proc_exit(void)
  {
d0538ca35   Pavel Emelyanov   [SOCK][NETNS]: Re...
321
  	unregister_pernet_subsys(&ipv6_proc_ops);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
322
  }