seq_file_net.h (757B)
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 7struct net; 8extern struct net init_net; 9 10struct seq_net_private { 11#ifdef CONFIG_NET_NS 12 struct net *net; 13 netns_tracker ns_tracker; 14#endif 15}; 16 17static inline struct net *seq_file_net(struct seq_file *seq) 18{ 19#ifdef CONFIG_NET_NS 20 return ((struct seq_net_private *)seq->private)->net; 21#else 22 return &init_net; 23#endif 24} 25 26/* 27 * This one is needed for proc_create_net_single since net is stored directly 28 * in private not as a struct i.e. seq_file_net can't be used. 29 */ 30static inline struct net *seq_file_single_net(struct seq_file *seq) 31{ 32#ifdef CONFIG_NET_NS 33 return (struct net *)seq->private; 34#else 35 return &init_net; 36#endif 37} 38 39#endif