seq_file_net.h 787 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __SEQ_FILE_NET_H__
  3. #define __SEQ_FILE_NET_H__
  4. #include <linux/seq_file.h>
  5. #include <net/net_trackers.h>
  6. struct net;
  7. extern struct net init_net;
  8. struct seq_net_private {
  9. #ifdef CONFIG_NET_NS
  10. struct net *net;
  11. netns_tracker ns_tracker;
  12. #endif
  13. };
  14. static inline struct net *seq_file_net(struct seq_file *seq)
  15. {
  16. #ifdef CONFIG_NET_NS
  17. return ((struct seq_net_private *)seq->private)->net;
  18. #else
  19. return &init_net;
  20. #endif
  21. }
  22. /*
  23. * This one is needed for proc_create_net_single since net is stored directly
  24. * in private not as a struct i.e. seq_file_net can't be used.
  25. */
  26. static inline struct net *seq_file_single_net(struct seq_file *seq)
  27. {
  28. #ifdef CONFIG_NET_NS
  29. return (struct net *)seq->private;
  30. #else
  31. return &init_net;
  32. #endif
  33. }
  34. #endif