diff options
author | Christoph Hellwig <hch@lst.de> | 2018-04-10 13:42:55 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 01:24:30 -0400 |
commit | c3506372277779fccbffee2475400fcd689d5738 (patch) | |
tree | d45d820f96a84a1223fa84c6ad4b7d84a81399aa /net/core/net-procfs.c | |
parent | a2dcdee3748b664bf011b4b12de64e945dd4c8c2 (diff) |
proc: introduce proc_create_net{,_data}
Variants of proc_create{,_data} that directly take a struct seq_operations
and deal with network namespaces in ->open and ->release. All callers of
proc_create + seq_open_net converted over, and seq_{open,release}_net are
removed entirely.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'net/core/net-procfs.c')
-rw-r--r-- | net/core/net-procfs.c | 49 |
1 files changed, 6 insertions, 43 deletions
diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c index c4e8ebe55e26..63881f72ef71 100644 --- a/net/core/net-procfs.c +++ b/net/core/net-procfs.c | |||
@@ -175,19 +175,6 @@ static const struct seq_operations dev_seq_ops = { | |||
175 | .show = dev_seq_show, | 175 | .show = dev_seq_show, |
176 | }; | 176 | }; |
177 | 177 | ||
178 | static int dev_seq_open(struct inode *inode, struct file *file) | ||
179 | { | ||
180 | return seq_open_net(inode, file, &dev_seq_ops, | ||
181 | sizeof(struct seq_net_private)); | ||
182 | } | ||
183 | |||
184 | static const struct file_operations dev_seq_fops = { | ||
185 | .open = dev_seq_open, | ||
186 | .read = seq_read, | ||
187 | .llseek = seq_lseek, | ||
188 | .release = seq_release_net, | ||
189 | }; | ||
190 | |||
191 | static const struct seq_operations softnet_seq_ops = { | 178 | static const struct seq_operations softnet_seq_ops = { |
192 | .start = softnet_seq_start, | 179 | .start = softnet_seq_start, |
193 | .next = softnet_seq_next, | 180 | .next = softnet_seq_next, |
@@ -285,30 +272,18 @@ static const struct seq_operations ptype_seq_ops = { | |||
285 | .show = ptype_seq_show, | 272 | .show = ptype_seq_show, |
286 | }; | 273 | }; |
287 | 274 | ||
288 | static int ptype_seq_open(struct inode *inode, struct file *file) | ||
289 | { | ||
290 | return seq_open_net(inode, file, &ptype_seq_ops, | ||
291 | sizeof(struct seq_net_private)); | ||
292 | } | ||
293 | |||
294 | static const struct file_operations ptype_seq_fops = { | ||
295 | .open = ptype_seq_open, | ||
296 | .read = seq_read, | ||
297 | .llseek = seq_lseek, | ||
298 | .release = seq_release_net, | ||
299 | }; | ||
300 | |||
301 | |||
302 | static int __net_init dev_proc_net_init(struct net *net) | 275 | static int __net_init dev_proc_net_init(struct net *net) |
303 | { | 276 | { |
304 | int rc = -ENOMEM; | 277 | int rc = -ENOMEM; |
305 | 278 | ||
306 | if (!proc_create("dev", 0444, net->proc_net, &dev_seq_fops)) | 279 | if (!proc_create_net("dev", 0444, net->proc_net, &dev_seq_ops, |
280 | sizeof(struct seq_net_private))) | ||
307 | goto out; | 281 | goto out; |
308 | if (!proc_create_seq("softnet_stat", 0444, net->proc_net, | 282 | if (!proc_create_seq("softnet_stat", 0444, net->proc_net, |
309 | &softnet_seq_ops)) | 283 | &softnet_seq_ops)) |
310 | goto out_dev; | 284 | goto out_dev; |
311 | if (!proc_create("ptype", 0444, net->proc_net, &ptype_seq_fops)) | 285 | if (!proc_create_net("ptype", 0444, net->proc_net, &ptype_seq_ops, |
286 | sizeof(struct seq_net_private))) | ||
312 | goto out_softnet; | 287 | goto out_softnet; |
313 | 288 | ||
314 | if (wext_proc_init(net)) | 289 | if (wext_proc_init(net)) |
@@ -365,22 +340,10 @@ static const struct seq_operations dev_mc_seq_ops = { | |||
365 | .show = dev_mc_seq_show, | 340 | .show = dev_mc_seq_show, |
366 | }; | 341 | }; |
367 | 342 | ||
368 | static int dev_mc_seq_open(struct inode *inode, struct file *file) | ||
369 | { | ||
370 | return seq_open_net(inode, file, &dev_mc_seq_ops, | ||
371 | sizeof(struct seq_net_private)); | ||
372 | } | ||
373 | |||
374 | static const struct file_operations dev_mc_seq_fops = { | ||
375 | .open = dev_mc_seq_open, | ||
376 | .read = seq_read, | ||
377 | .llseek = seq_lseek, | ||
378 | .release = seq_release_net, | ||
379 | }; | ||
380 | |||
381 | static int __net_init dev_mc_net_init(struct net *net) | 343 | static int __net_init dev_mc_net_init(struct net *net) |
382 | { | 344 | { |
383 | if (!proc_create("dev_mcast", 0, net->proc_net, &dev_mc_seq_fops)) | 345 | if (!proc_create_net("dev_mcast", 0, net->proc_net, &dev_mc_seq_ops, |
346 | sizeof(struct seq_net_private))) | ||
384 | return -ENOMEM; | 347 | return -ENOMEM; |
385 | return 0; | 348 | return 0; |
386 | } | 349 | } |