diff mbox series

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

Message ID 20200427201235.2994615-1-yhs@fb.com
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series bpf: implement bpf iterator for kernel data | expand

Commit Message

Yonghong Song April 27, 2020, 8:12 p.m. UTC
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.

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(-)

Comments

Andrii Nakryiko April 29, 2020, 5:38 a.m. UTC | #1
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
>
diff mbox series

Patch

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