Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __SEQ_FILE_NET_H__
0003 #define __SEQ_FILE_NET_H__
0004 
0005 #include <linux/seq_file.h>
0006 #include <net/net_trackers.h>
0007 
0008 struct net;
0009 extern struct net init_net;
0010 
0011 struct seq_net_private {
0012 #ifdef CONFIG_NET_NS
0013     struct net  *net;
0014     netns_tracker   ns_tracker;
0015 #endif
0016 };
0017 
0018 static inline struct net *seq_file_net(struct seq_file *seq)
0019 {
0020 #ifdef CONFIG_NET_NS
0021     return ((struct seq_net_private *)seq->private)->net;
0022 #else
0023     return &init_net;
0024 #endif
0025 }
0026 
0027 /*
0028  * This one is needed for proc_create_net_single since net is stored directly
0029  * in private not as a struct i.e. seq_file_net can't be used.
0030  */
0031 static inline struct net *seq_file_single_net(struct seq_file *seq)
0032 {
0033 #ifdef CONFIG_NET_NS
0034     return (struct net *)seq->private;
0035 #else
0036     return &init_net;
0037 #endif
0038 }
0039 
0040 #endif