Merge tag 's390-5.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
[linux-2.6-microblaze.git] / include / linux / seq_file_net.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __SEQ_FILE_NET_H__
3 #define __SEQ_FILE_NET_H__
4
5 #include <linux/seq_file.h>
6
7 struct net;
8 extern struct net init_net;
9
10 struct seq_net_private {
11 #ifdef CONFIG_NET_NS
12         struct net      *net;
13         netns_tracker   ns_tracker;
14 #endif
15 };
16
17 static inline struct net *seq_file_net(struct seq_file *seq)
18 {
19 #ifdef CONFIG_NET_NS
20         return ((struct seq_net_private *)seq->private)->net;
21 #else
22         return &init_net;
23 #endif
24 }
25
26 /*
27  * This one is needed for proc_create_net_single since net is stored directly
28  * in private not as a struct i.e. seq_file_net can't be used.
29  */
30 static inline struct net *seq_file_single_net(struct seq_file *seq)
31 {
32 #ifdef CONFIG_NET_NS
33         return (struct net *)seq->private;
34 #else
35         return &init_net;
36 #endif
37 }
38
39 #endif