Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Denis V. Lunev | c0f3932 | 2008-04-02 00:10:28 -0700 | [diff] [blame] | 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 | |
Denis V. Lunev | c0f3932 | 2008-04-02 00:10:28 -0700 | [diff] [blame] | 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 | |
Christoph Hellwig | a2dcdee | 2018-04-11 12:32:45 +0200 | [diff] [blame] | 25 | /* |
Christoph Hellwig | 3617d94 | 2018-04-13 20:38:35 +0200 | [diff] [blame] | 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. |
Christoph Hellwig | a2dcdee | 2018-04-11 12:32:45 +0200 | [diff] [blame] | 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 | |
Denis V. Lunev | c0f3932 | 2008-04-02 00:10:28 -0700 | [diff] [blame] | 38 | #endif |