Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[linux-block.git] / include / linux / seq_file_net.h
CommitLineData
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>
5f10376b 6#include <net/net_trackers.h>
c0f39322
DL
7
8struct net;
9extern struct net init_net;
10
11struct seq_net_private {
12#ifdef CONFIG_NET_NS
04a931e5
ED
13 struct net *net;
14 netns_tracker ns_tracker;
c0f39322
DL
15#endif
16};
17
c0f39322
DL
18static inline struct net *seq_file_net(struct seq_file *seq)
19{
20#ifdef CONFIG_NET_NS
21 return ((struct seq_net_private *)seq->private)->net;
22#else
23 return &init_net;
24#endif
25}
26
a2dcdee3 27/*
3617d949
CH
28 * This one is needed for proc_create_net_single since net is stored directly
29 * in private not as a struct i.e. seq_file_net can't be used.
a2dcdee3
CH
30 */
31static inline struct net *seq_file_single_net(struct seq_file *seq)
32{
33#ifdef CONFIG_NET_NS
34 return (struct net *)seq->private;
35#else
36 return &init_net;
37#endif
38}
39
c0f39322 40#endif