blob: 0fdbe1ddd8d1bd53269c4ca49297544860f3d3e5 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Denis V. Lunevc0f39322008-04-02 00:10:28 -07002#ifndef __SEQ_FILE_NET_H__
3#define __SEQ_FILE_NET_H__
4
5#include <linux/seq_file.h>
6
7struct net;
8extern struct net init_net;
9
10struct seq_net_private {
11#ifdef CONFIG_NET_NS
12 struct net *net;
13#endif
14};
15
Denis V. Lunevc0f39322008-04-02 00:10:28 -070016static 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 Hellwiga2dcdee2018-04-11 12:32:45 +020025/*
Christoph Hellwig3617d942018-04-13 20:38:35 +020026 * 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 Hellwiga2dcdee2018-04-11 12:32:45 +020028 */
29static 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. Lunevc0f39322008-04-02 00:10:28 -070038#endif