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#include <net/net_trackers.h> 7 8struct net; 9extern struct net init_net; 10 11struct seq_net_private { 12#ifdef CONFIG_NET_NS 13 struct net *net; 14 netns_tracker ns_tracker; 15#endif 16}; 17 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 27/* 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. 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 40#endif 41