BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Paul Moses" <p@1g4.org>, <bpf@vger.kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: "Martin KaFai Lau" <martin.lau@linux.dev>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"Kui-Feng Lee" <kuifeng@meta.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH bpf] bpf: Skip same map struct_ops link updates
Date: Thu, 03 Dec 2026 03:44:12 +0000	[thread overview]
Message-ID: <DNASDMQJJZTS.3JOB8WIUNZKRX@gmail.com> (raw)
In-Reply-To: <20261202053703.938201-1-p@1g4.org>

On Tue, Dec 01, 2026 at 09:38 PM Paul Moses <p@1g4.org> wrote:
> Skip the callback when the maps are identical.

> @@ -1409,7 +1409,7 @@ static int bpf_struct_ops_map_link_update(struct bpf_link *link, struct bpf_map
>  	mutex_lock(&update_mutex);
>  	old_map = st_link->map;
>  	err = bpf_struct_ops_link_update_check(new_map, old_map, expected_old_map);
> -	if (err)
> +	if (err || new_map == old_map)
>  		goto err_out;

This changes sched_ext too.
bpf_scx_update() always returns -EOPNOTSUPP. The patch skips it.
BPF_LINK_UPDATE with the map that the link already has:

  struct_ops              bpf/master      with the patch
  ----------------------  --------------  --------------
  tcp_congestion_ops      0, broken list  0
  sched_ext_ops           -EOPNOTSUPP     0
  Qdisc_ops, hid_bpf_ops  -EOPNOTSUPP     -EOPNOTSUPP

sysrq-S disables the scheduler, but the link keeps the map.
User space gets 0 for a scheduler that doesn't run.

The bug is in tcp_update_congestion_control(). Fix it there.

diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index e3f462f..5658f24 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -148,6 +148,9 @@ int tcp_update_congestion_control(struct tcp_congestion_ops *ca, struct tcp_cong
 	struct tcp_congestion_ops *existing;
 	int ret = 0;
 
+	if (ca == old_ca)
+		return 0;
+
 	ca->key = jhash(ca->name, sizeof(ca->name), strlen(ca->name));
 
 	spin_lock(&tcp_cong_list_lock);

pw-bot: cr

      reply	other threads:[~2026-12-03  3:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  5:38 [PATCH bpf] bpf: Skip same map struct_ops link updates Paul Moses
2026-12-03  3:44 ` Alexei Starovoitov [this message]

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=DNASDMQJJZTS.3JOB8WIUNZKRX@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=kuifeng@meta.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=p@1g4.org \
    --cc=song@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yonghong.song@linux.dev \
    /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