Re: [PATCH bpf-next v1 01/19] net: refactor net assignment for seq_net_private structure

Andrii Nakryiko
2020-04-29T05:38:57Z

On Mon, Apr 27, 2020 at 1:13 PM Yonghong Song <yhs@fb.com> wrote:
>
> Refactor assignment of "net" in seq_net_private structure
> in proc_net.c to a helper function. The helper later will
> be used by bpfdump.

typo: bpfdump -> bpf_iter ?

Otherwise:

Acked-by: Andrii Nakryiko <andriin@fb.com>

>
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
> fs/proc/proc_net.c | 5 ++---
> include/linux/seq_file_net.h | 8 ++++++++
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
> index 4888c5224442..aee07c19cf8b 100644
> --- a/fs/proc/proc_net.c
> +++ b/fs/proc/proc_net.c
> @@ -75,9 +75,8 @@ static int seq_open_net(struct inode *inode, struct file *file)
> put_net(net);
> return -ENOMEM;
> }
> -#ifdef CONFIG_NET_NS
> - p->net = net;
> -#endif
> +
> + set_seq_net_private(p, net);
> return 0;
> }
>
> diff --git a/include/linux/seq_file_net.h b/include/linux/seq_file_net.h
> index 0fdbe1ddd8d1..0ec4a18b9aca 100644
> --- a/include/linux/seq_file_net.h
> +++ b/include/linux/seq_file_net.h
> @@ -35,4 +35,12 @@ static inline struct net *seq_file_single_net(struct seq_file *seq)
> #endif
> }
>
> +static inline void set_seq_net_private(struct seq_net_private *p,
> + struct net *net)
> +{
> +#ifdef CONFIG_NET_NS
> + p->net = net;
> +#endif
> +}
> +
> #endif
> --
> 2.24.1
>