Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
c0f39322 DL |
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 | #endif | |
14 | }; | |
15 | ||
c0f39322 DL |
16 | static inline struct net *seq_file_net(struct seq_file *seq) |
17 | { | |
18 | #ifdef CONFIG_NET_NS | |
19 | return ((struct seq_net_private *)seq->private)->net; | |
20 | #else | |
21 | return &init_net; | |
22 | #endif | |
23 | } | |
24 | ||
a2dcdee3 | 25 | /* |
3617d949 CH |
26 | * This one is needed for proc_create_net_single since net is stored directly |
27 | * in private not as a struct i.e. seq_file_net can't be used. | |
a2dcdee3 CH |
28 | */ |
29 | static inline struct net *seq_file_single_net(struct seq_file *seq) | |
30 | { | |
31 | #ifdef CONFIG_NET_NS | |
32 | return (struct net *)seq->private; | |
33 | #else | |
34 | return &init_net; | |
35 | #endif | |
36 | } | |
37 | ||
c0f39322 | 38 | #endif |