From: Martin KaFai Lau <martin.lau@linux.dev>
To: bpf@vger.kernel.org
Cc: 'Alexei Starovoitov ' <ast@kernel.org>,
'Andrii Nakryiko ' <andrii@kernel.org>,
'Daniel Borkmann ' <daniel@iogearbox.net>,
netdev@vger.kernel.org, kernel-team@meta.com,
'Amery Hung ' <ameryhung@gmail.com>
Subject: [RFC PATCH bpf-next 11/12] bpf: net: Add a qdisc kfunc to set sk_pacing_status.
Date: Fri, 18 Apr 2025 15:46:49 -0700 [thread overview]
Message-ID: <20250418224652.105998-12-martin.lau@linux.dev> (raw)
In-Reply-To: <20250418224652.105998-1-martin.lau@linux.dev>
From: Martin KaFai Lau <martin.lau@kernel.org>
bpf_qdisc_set_sk_pacing() is added to set the sk_pacing_status. This
can tell the tcp stack that the qdisc can do pacing and the tcp
stack does not need to do its own internal pacing.
It is only allowed in the enqueue ops.
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
---
net/sched/bpf_qdisc.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/net/sched/bpf_qdisc.c b/net/sched/bpf_qdisc.c
index 9f32b305636f..45776918efcf 100644
--- a/net/sched/bpf_qdisc.c
+++ b/net/sched/bpf_qdisc.c
@@ -7,6 +7,7 @@
#include <linux/filter.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
+#include <net/sock.h>
#define QDISC_OP_IDX(op) (offsetof(struct Qdisc_ops, op) / sizeof(void (*)(void)))
#define QDISC_MOFF_IDX(moff) (moff / sizeof(void (*)(void)))
@@ -214,6 +215,17 @@ __bpf_kfunc void bpf_qdisc_skb_drop(struct sk_buff *skb,
__qdisc_drop(skb, (struct sk_buff **)to_free_list);
}
+__bpf_kfunc int bpf_qdisc_set_sk_pacing(struct sk_buff *skb, enum sk_pacing pacing)
+{
+ struct sock *sk = skb->sk;
+
+ if (!sk || sk_listener_or_tw(sk) || pacing != SK_PACING_FQ)
+ return -EINVAL;
+
+ smp_store_release(&sk->sk_pacing_status, pacing);
+ return 0;
+}
+
/* bpf_qdisc_watchdog_schedule - Schedule a qdisc to a later time using a timer.
* @sch: The qdisc to be scheduled.
* @expire: The expiry time of the timer.
@@ -274,6 +286,7 @@ BTF_KFUNCS_START(qdisc_kfunc_ids)
BTF_ID_FLAGS(func, bpf_skb_get_hash, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_kfree_skb, KF_RELEASE)
BTF_ID_FLAGS(func, bpf_qdisc_skb_drop, KF_RELEASE)
+BTF_ID_FLAGS(func, bpf_qdisc_set_sk_pacing, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_dynptr_from_skb, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_qdisc_watchdog_schedule, KF_TRUSTED_ARGS)
BTF_ID_FLAGS(func, bpf_qdisc_init_prologue, KF_TRUSTED_ARGS)
@@ -290,6 +303,7 @@ BTF_SET_END(qdisc_common_kfunc_set)
BTF_SET_START(qdisc_enqueue_kfunc_set)
BTF_ID(func, bpf_qdisc_skb_drop)
BTF_ID(func, bpf_qdisc_watchdog_schedule)
+BTF_ID(func, bpf_qdisc_set_sk_pacing)
BTF_SET_END(qdisc_enqueue_kfunc_set)
BTF_SET_START(qdisc_dequeue_kfunc_set)
--
2.47.1
next prev parent reply other threads:[~2025-04-18 22:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 22:46 [RFC PATCH bpf-next 00/12] bpf: A fq example similar to the kernel sch_fq.c implementation Martin KaFai Lau
2025-04-18 22:46 ` [RFC PATCH bpf-next 01/12] bpf: Check KF_bpf_rbtree_add_impl for the "case KF_ARG_PTR_TO_RB_NODE" Martin KaFai Lau
2025-04-22 1:05 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 02/12] bpf: Simplify reg0 marking for the rbtree kfuncs that return a bpf_rb_node pointer Martin KaFai Lau
2025-04-22 1:14 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 03/12] bpf: Add bpf_rbtree_{root,left,right} kfunc Martin KaFai Lau
2025-04-22 1:43 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 04/12] selftests/bpf: Adjust failure message in the rbtree_fail test Martin KaFai Lau
2025-04-22 1:44 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 05/12] bpf: Allow refcounted bpf_rb_node used in bpf_rbtree_{remove,left,right} Martin KaFai Lau
2025-04-22 2:32 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 06/12] selftests/bpf: Adjust test that does not allow refcounted node in rbtree_remove Martin KaFai Lau
2025-04-22 2:36 ` Kumar Kartikeya Dwivedi
2025-04-22 2:48 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 07/12] selftests/bpf: Add rbtree_search test Martin KaFai Lau
2025-04-22 3:03 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 08/12] bpf: Simplify reg0 marking for the list kfuncs that return a bpf_list_node pointer Martin KaFai Lau
2025-04-22 3:05 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 09/12] bpf: Add bpf_list_{front,back} kfunc Martin KaFai Lau
2025-04-22 3:07 ` Kumar Kartikeya Dwivedi
2025-04-18 22:46 ` [RFC PATCH bpf-next 10/12] selftests/bpf: Add test for bpf_list_{front,back} Martin KaFai Lau
2025-04-22 3:08 ` Kumar Kartikeya Dwivedi
2025-04-25 23:28 ` Martin KaFai Lau
2025-04-18 22:46 ` Martin KaFai Lau [this message]
2025-04-18 22:46 ` [RFC PATCH bpf-next 12/12] selftests/bpf: A bpf fq implementation similar to the kernel sch_fq Martin KaFai Lau
2025-04-25 0:13 ` Alexei Starovoitov
2025-04-25 23:50 ` Martin KaFai Lau
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=20250418224652.105998-12-martin.lau@linux.dev \
--to=martin.lau@linux.dev \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=netdev@vger.kernel.org \
/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).