aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/core/sock.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 5a6fe4dfad46..a4e840e5a053 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2174,7 +2174,7 @@ static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
2174 "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n", 2174 "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n",
2175 proto->name, 2175 proto->name,
2176 proto->obj_size, 2176 proto->obj_size,
2177 proto->sockets_allocated != NULL ? atomic_read(proto->sockets_allocated) : -1, 2177 sock_prot_inuse_get(seq_file_net(seq), proto),
2178 proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1, 2178 proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1,
2179 proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI", 2179 proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI",
2180 proto->max_header, 2180 proto->max_header,
@@ -2228,7 +2228,8 @@ static const struct seq_operations proto_seq_ops = {
2228 2228
2229static int proto_seq_open(struct inode *inode, struct file *file) 2229static int proto_seq_open(struct inode *inode, struct file *file)
2230{ 2230{
2231 return seq_open(file, &proto_seq_ops); 2231 return seq_open_net(inode, file, &proto_seq_ops,
2232 sizeof(struct seq_net_private));
2232} 2233}
2233 2234
2234static const struct file_operations proto_seq_fops = { 2235static const struct file_operations proto_seq_fops = {
@@ -2236,13 +2237,31 @@ static const struct file_operations proto_seq_fops = {
2236 .open = proto_seq_open, 2237 .open = proto_seq_open,
2237 .read = seq_read, 2238 .read = seq_read,
2238 .llseek = seq_lseek, 2239 .llseek = seq_lseek,
2239 .release = seq_release, 2240 .release = seq_release_net,
2241};
2242
2243static __net_init int proto_init_net(struct net *net)
2244{
2245 if (!proc_net_fops_create(net, "protocols", S_IRUGO, &proto_seq_fops))
2246 return -ENOMEM;
2247
2248 return 0;
2249}
2250
2251static __net_exit void proto_exit_net(struct net *net)
2252{
2253 proc_net_remove(net, "protocols");
2254}
2255
2256
2257static __net_initdata struct pernet_operations proto_net_ops = {
2258 .init = proto_init_net,
2259 .exit = proto_exit_net,
2240}; 2260};
2241 2261
2242static int __init proto_init(void) 2262static int __init proto_init(void)
2243{ 2263{
2244 /* register /proc/net/protocols */ 2264 return register_pernet_subsys(&proto_net_ops);
2245 return proc_net_fops_create(&init_net, "protocols", S_IRUGO, &proto_seq_fops) == NULL ? -ENOBUFS : 0;
2246} 2265}
2247 2266
2248subsys_initcall(proto_init); 2267subsys_initcall(proto_init);