seq_file_net.h 730 B

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