netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Amery Hung <ameryhung@gmail.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
	alexei.starovoitov@gmail.com, andrii@kernel.org,
	daniel@iogearbox.net, martin.lau@kernel.org,
	xiyou.wangcong@gmail.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next/net v1 3/5] bpf: net_sched: Make some Qdisc_ops ops mandatory
Date: Thu, 1 May 2025 17:13:50 -0700	[thread overview]
Message-ID: <507f8523-74ac-4250-a9d2-3942e11b6f74@linux.dev> (raw)
In-Reply-To: <20250501223025.569020-4-ameryhung@gmail.com>

On 5/1/25 3:30 PM, Amery Hung wrote:
> The patch makes all currently supported Qdisc_ops (i.e., .enqueue,
> .dequeue, .init, .reser, and .destroy) mandatory.

s/reser/reset/.

> 
> Make .init, .reset and .destroy mandatory as bpf qdisc relies on prologue
> and epilogue to check attach points and correctly initialize/cleanup
> resources. The prologue/epilogue will only be generated for an struct_ops
> operator only if users implement the operator.
> 
> Make .enqueue and .dequeue mandatory as bpf qdisc infra does not provide
> a default data path.
> 
> Fixes: Fixes: c8240344956e ("bpf: net_sched: Support implementation of Qdisc_ops in bpf")
> Signed-off-by: Amery Hung <ameryhung@gmail.com>
> ---
>   net/sched/bpf_qdisc.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/net/sched/bpf_qdisc.c b/net/sched/bpf_qdisc.c
> index a8efc3ff2b7e..7ea8b54b2ab1 100644
> --- a/net/sched/bpf_qdisc.c
> +++ b/net/sched/bpf_qdisc.c
> @@ -395,6 +395,17 @@ static void bpf_qdisc_unreg(void *kdata, struct bpf_link *link)
>   	return unregister_qdisc(kdata);
>   }
>   
> +static int bpf_qdisc_validate(void *kdata)
> +{
> +	struct Qdisc_ops *ops = (struct Qdisc_ops *)kdata;
> +
> +	if (!ops->enqueue || !ops->dequeue || !ops->init ||
> +	    !ops->reset || !ops->destroy)
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
>   static int Qdisc_ops__enqueue(struct sk_buff *skb__ref, struct Qdisc *sch,
>   			      struct sk_buff **to_free)
>   {
> @@ -432,6 +443,7 @@ static struct bpf_struct_ops bpf_Qdisc_ops = {
>   	.verifier_ops = &bpf_qdisc_verifier_ops,
>   	.reg = bpf_qdisc_reg,
>   	.unreg = bpf_qdisc_unreg,
> +	.validate = bpf_qdisc_validate,
>   	.init_member = bpf_qdisc_init_member,
>   	.init = bpf_qdisc_init,
>   	.name = "Qdisc_ops",


  reply	other threads:[~2025-05-02  0:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01 22:30 [PATCH bpf-next/net v1 0/5] Fix bpf qdisc bugs and cleanup Amery Hung
2025-05-01 22:30 ` [PATCH bpf-next/net v1 1/5] bpf: net_sched: Fix bpf qdisc init prologue when set as default qdisc Amery Hung
2025-05-02  9:32   ` Simon Horman
2025-05-01 22:30 ` [PATCH bpf-next/net v1 2/5] selftests/bpf: Test setting and creating bpf qdisc " Amery Hung
2025-05-01 23:58   ` Martin KaFai Lau
2025-05-02 17:52     ` Amery Hung
2025-05-02 19:27       ` Martin KaFai Lau
2025-05-02 19:33         ` Amery Hung
2025-05-01 22:30 ` [PATCH bpf-next/net v1 3/5] bpf: net_sched: Make some Qdisc_ops ops mandatory Amery Hung
2025-05-02  0:13   ` Martin KaFai Lau [this message]
2025-05-01 22:30 ` [PATCH bpf-next/net v1 4/5] selftests/bpf: selftests/bpf: Test attaching a bpf qdisc with incomplete operators Amery Hung
2025-05-01 22:30 ` [PATCH bpf-next/net v1 5/5] selftests/bpf: Cleanup bpf qdisc selftests Amery Hung
2025-05-02  0:22   ` Martin KaFai Lau
2025-05-02 17:53     ` Amery Hung

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=507f8523-74ac-4250-a9d2-3942e11b6f74@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.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).