From: Aditi Ghag <aditi.ghag@isovalent.com>
To: Aditi Ghag <aditi.ghag@isovalent.com>
Cc: bpf@vger.kernel.org, kafai@fb.com,
Stanislav Fomichev <sdf@google.com>,
Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH v7 bpf-next 04/10] udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state
Date: Wed, 3 May 2023 18:25:25 -0700 [thread overview]
Message-ID: <73779BBC-48BB-4FE9-A673-36EA3DD79068@isovalent.com> (raw)
In-Reply-To: <20230503225351.3700208-5-aditi.ghag@isovalent.com>
> On May 3, 2023, at 3:53 PM, Aditi Ghag <aditi.ghag@isovalent.com> wrote:
>
> This is a preparatory commit to remove the field. The field was
> previously shared between proc fs and BPF UDP socket iterators. As the
> follow-up commits will decouple the implementation for the iterators,
> remove the field. As for BPF socket iterator, filtering of sockets is
> exepected to be done in BPF programs.
>
> Suggested-by: Martin KaFai Lau <martin.lau@kernel.org>
> Signed-off-by: Aditi Ghag <aditi.ghag@isovalent.com>
> ---
> include/net/udp.h | 1 -
> net/ipv4/udp.c | 25 +++++--------------------
> 2 files changed, 5 insertions(+), 21 deletions(-)
>
> diff --git a/include/net/udp.h b/include/net/udp.h
> index de4b528522bb..5cad44318d71 100644
> --- a/include/net/udp.h
> +++ b/include/net/udp.h
> @@ -437,7 +437,6 @@ struct udp_seq_afinfo {
> struct udp_iter_state {
> struct seq_net_private p;
> int bucket;
> - struct udp_seq_afinfo *bpf_seq_afinfo;
> };
>
> void *udp_seq_start(struct seq_file *seq, loff_t *pos);
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index c426ebafeb13..9f8c1554a9e4 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
> @@ -2993,14 +2993,16 @@ static bool seq_sk_match(struct seq_file *seq, const struct sock *sk)
> net_eq(sock_net(sk), seq_file_net(seq)));
> }
>
> +static const struct seq_operations bpf_iter_udp_seq_ops;
>> net/ipv4/udp.c:3001:36: warning: 'bpf_iter_udp_seq_ops' defined but not used [-Wunused-const-variable=]
3001 | static const struct seq_operations bpf_iter_udp_seq_ops;
| ^~~~~~~~~~~~~~~~~~~~
This would have to be wrapped with ifdef too.
> static struct udp_table *udp_get_table_seq(struct seq_file *seq,
> struct net *net)
> {
> - const struct udp_iter_state *state = seq->private;
> const struct udp_seq_afinfo *afinfo;
>
> - if (state->bpf_seq_afinfo)
> +#ifdef CONFIG_BPF_SYSCALL
> + if (seq->op == &bpf_iter_udp_seq_ops)
> return net->ipv4.udp_table;
> +#endif
>
> afinfo = pde_data(file_inode(seq->file));
> return afinfo->udp_table ? : net->ipv4.udp_table;
> @@ -3424,28 +3426,11 @@ DEFINE_BPF_ITER_FUNC(udp, struct bpf_iter_meta *meta,
>
> static int bpf_iter_init_udp(void *priv_data, struct bpf_iter_aux_info *aux)
> {
> - struct udp_iter_state *st = priv_data;
> - struct udp_seq_afinfo *afinfo;
> - int ret;
> -
> - afinfo = kmalloc(sizeof(*afinfo), GFP_USER | __GFP_NOWARN);
> - if (!afinfo)
> - return -ENOMEM;
> -
> - afinfo->family = AF_UNSPEC;
> - afinfo->udp_table = NULL;
> - st->bpf_seq_afinfo = afinfo;
> - ret = bpf_iter_init_seq_net(priv_data, aux);
> - if (ret)
> - kfree(afinfo);
> - return ret;
> + return bpf_iter_init_seq_net(priv_data, aux);
> }
>
> static void bpf_iter_fini_udp(void *priv_data)
> {
> - struct udp_iter_state *st = priv_data;
> -
> - kfree(st->bpf_seq_afinfo);
> bpf_iter_fini_seq_net(priv_data);
> }
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2023-05-04 1:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 22:53 [PATCH v7 bpf-next 00/10] bpf: Add socket destroy capability Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 01/10] bpf: tcp: Avoid taking fast sock lock in iterator Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 02/10] udp: seq_file: Helper function to match socket attributes Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 03/10] bpf: udp: Encapsulate logic to get udp table Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 04/10] udp: seq_file: Remove bpf_seq_afinfo from udp_iter_state Aditi Ghag
2023-05-04 1:25 ` Aditi Ghag [this message]
2023-05-03 22:53 ` [PATCH v7 bpf-next 05/10] bpf: udp: Implement batching for sockets iterator Aditi Ghag
2023-05-03 22:53 ` [PATCH v7 bpf-next 06/10] bpf: Add bpf_sock_destroy kfunc Aditi Ghag
2023-05-05 0:13 ` Martin KaFai Lau
2023-05-05 18:49 ` Martin KaFai Lau
2023-05-05 20:05 ` Alexei Starovoitov
2023-05-03 22:53 ` [PATCH v7 bpf-next 07/10] selftests/bpf: Add helper to get port using getsockname Aditi Ghag
2023-05-04 17:33 ` Stanislav Fomichev
2023-05-03 22:53 ` [PATCH v7 bpf-next 08/10] selftests/bpf: Test bpf_sock_destroy Aditi Ghag
2023-05-05 0:24 ` Martin KaFai Lau
2023-05-03 22:53 ` [PATCH v7 bpf-next 09/10] bpf: Add a kfunc filter function to 'struct btf_kfunc_id_set' Aditi Ghag
2023-05-05 0:28 ` Martin KaFai Lau
2023-05-03 22:53 ` [PATCH v7 bpf-next 10/10] selftests/bpf: Extend bpf_sock_destroy tests Aditi Ghag
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73779BBC-48BB-4FE9-A673-36EA3DD79068@isovalent.com \
--to=aditi.ghag@isovalent.com \
--cc=bpf@vger.kernel.org \
--cc=kafai@fb.com \
--cc=martin.lau@kernel.org \
--cc=sdf@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).