Article View: linux.kernel.netdev
Article #15848[PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback
From: Hangbin Liu
Date: Fri, 13 Nov 2026 14:04
Date: Fri, 13 Nov 2026 14:04
59 lines
10851 bytes
10851 bytes
`bond_enslave()` is over 500 lines long with complex logic and numerous
error rollback paths. It has XDP ordering isssue and missing some error
rollbacks for historical reasons (found by Sashiko when review bond
patches). The fixes are trivial, I plan to refactor the function to make
the logic clearer and resolved the issues. This patch set is the first
phase.
This series hardens bond_enslave() in two stages: first fix real
ordering and rollback bugs, then factor the function so the
infallible commit point and fail-fast validation stay obvious.
Problems fixed (patches 1-3):
1. XDP capability checks ran after the slave was opened, linked and
could already be visible to the datapath . A slave without
ndo_xdp_xmit could therefore be reached from bond_xdp_xmit().
Checks move to the top of bond_enslave(), before any mutation.
2. Fallible XDP setup (dev_xdp_propagate()) ran after publication.
On failure the undo ladder jumped to err_sysfs_del and leaked:
- promiscuity / allmulti / synced addresses
- ns maddrs added just before the failure
3. Error paths were incomplete versus release:
- bond_alb_init_slave() success + later failure skipped
bond_alb_deinit_slave() (TLB/RLB state, borrowed MAC)
- bond_3ad_bind_slave() + later failure skipped
bond_3ad_unbind_slave() (port left on its aggregator)
- automatic fail_over_mac = "active" was not restored on failure
Cleanup (patches 4-6), no intended behaviour change beyond patch 5's
extack string alignment:
4. bond_publish_slave() — explicit infallible commit point
5. bond_slave_xdp_check() — shared by bond_enslave() and bond_xdp_set()
6. bond_enslave_validate() — all read-only checks
Testing: build debug kernel and run all kernel selftests
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
Hangbin Liu (6):
bonding: check XDP support before enslaving changes state
bonding: finish XDP setup before publishing the slave
bonding: complete rollback of bond_enslave() error paths
bonding: factor out slave publication
bonding: factor out XDP slave check
bonding: factor out bond_enslave_validate
drivers/net/bonding/bond_main.c | 174 ++++++++++++++++++++++++++--------------
1 file changed, 116 insertions(+), 58 deletions(-)
---
base-commit: 573af801552999954caa8347e4490b04cf4763f0
change-id: 20261020-bond_enslave_restruct-30760e62def9
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID:
<20261113-bond_enslave_restruct-v1-0-364c549e78db@kylinos.cn>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362688-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362688-linux-kernel-netdev=dewy.ru From: hangbin.liu@linux.dev (Hangbin Liu) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 0/6] bonding: refactor bond_enslave() to fix XDP ordering and error rollback Date: Fri, 13 Nov 2026 22:04:15 +0800 Organization: Usenet Network Message-ID: <20261113-bond_enslave_restruct-v1-0-364c549e78db@kylinos.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1393678"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:/Tcvy3eW6Kc/48ICGCfUryHXigo= sha256:n9K4Ls5viPLWUyp5bxmE0bnZppKWDlMUA6PB/lKtfp0= sha1:3o/NqNBJZCDHKJQBw/xdITwTXnA= sha256:X8f3peSDCAjiFXHmMUkD1T2keZyn9mpTRNqi3iyWt+w= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 66CC51145C2; Fri, 13 Nov 2026 20:17:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pVTrM2gZx8RR; Fri, 13 Nov 2026 20:17:36 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-362688-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 7985F1140A3; Fri, 13 Nov 2026 20:17:21 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 0BE5E223837; Fri, 13 Nov 2026 14:04:41 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794578677; b=qErZpPMHjxUNRoDVmvmXeeeRx9jRJ2FPhSgl0FcA9WSjww3tmyEt9l+ktspSDN/Zoumg Y6F7DA6kqHSS2iDeI+0QmS0WOwTZtF1/m7OOTRdt6M3vglcnX60Aq0YFcWjxgGZrDwVGD iYvESdIS5aJymhD50ALphZDQRRF6dEpMpem7FfJVxUbtLrHx/gw1TTYmUzdShj/q/K/+J oqWip9BUsS8StGGkjh812SFvWECHXJmc+eHUcd1vOmEyYudq4SFS8a7188h2UWVX8jqZy 4Vrh3IOf26FszkBxEIAe2AWCMiubN3RYAjZtm1zLaQ/BlIZpWfupU40mNo9Zn8ZR5hg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794578677; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:Subject: Date:Message-Id:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer; bh=Iild291BQt1rZVunkiVGj1yEjCJ3Qroi6/j+amR3uKY=; b=PV8gag/tYrZ0RUxW30nnVR6GscvcGLtozRwNFjRGp9l3hl7GgM85ZaV/6fB3v9O0oskm jGAZco0bz+EaL4vKyqix47/qO2RlfVEMONt+glWx9vlFbSWUcNsZGqvj13b0WNaq26BPk 3lLZm7SzkRM6XfjcMa974CkZfW6lnwJliidiu6riNXCt+ozq1Ays1/Dq0lZP5IHL8lmFe DUedS5YDzjWEn9b7PC1cBPLYHXbEGJVuGEL1qWb2/cxmBB49/lzzx6Ohbu2ZPR9AePOrw sDkHysBxbasas6JvSJ9aNsjN0O0Kr68ALZBDKAFhNnjPv2xaqKoZFYQVyWebcVzuQlg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ClgqgiCC; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4E0B606A33D; Fri, 13 Nov 2026 14:04:37 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ClgqgiCC X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.74 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794578677; b=GTN2VMZ5prravLM+GURmoISu6Kg8PZhUrW1kXcw2QhKBzZcCv+7Kl5ZQyy6oIraY0F1Q RUksKOYTjyp1PvQoIiymw0KrFS+WmFv4dON8D0lB8BOaYbAJWqRdQ+/CsGgEe/DUpDb4L VKmhUo1gpFmHebzxIHfGalX3xhCOn7rfnAjv2B/7kGOzOk4mFWIhdLuzx/cD763myyD6S +HIKbV22Ioq/qSRBwkHe3+Tt+AHpmF3xr7Vj87lstkidicXgIfDdlJpYIokSXE0NNEfJJ e/z/iSbLpR+5i3dykwkjk/dkoiDm2qyYEg/0CPjSnlJy5VaZkMXLuZRxiMwsa6IvzmQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794578677; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer; bh=Iild291BQt1rZVunkiVGj1yEjCJ3Qroi6/j+amR3uKY=; b=m5D7wx8RO4PFGW/Tcuse9t17tUYHMeJwXQnOD5EDk1JQv0U8MVFvHeddoC6INWCKdQ1c ZER9S+QcbiAykQOqEZWxmYMYsqx74WpsYsVy0oEg6j2/jzgDSuT2ZjhXWngPZC0/kr4XA 5cVBplmN/BHPUr6pNVOekQuoKC/ImjkTdN7tywE5vaqbS44TcTPAotiIx41kpofVuaM2z aPgY8/II3E19QTeApWxfBOxA83KGjDVfe65yAd3sGpO5T8VDnGwPIzZW9lsCY3JXt7fPB 9Ciht/GyOdY1+DMxBuySm7QSMmrDO25MWl9xdnO2PPDmX354vChgvkH4tk35TNFqPEg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ClgqgiCC; arc=none smtp.remote-ip=95.215.58.74 X-Received: from mta1.migadu.com (out-74.mta1.migadu.com [95.215.58.74]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD74D606A330 for <netdev@vger.kernel.org>; Fri, 13 Nov 2026 14:04:35 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AD74D606A330 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=xC4G0Cwhp7kj5bOO1KBaJmJUIF0RxwnSoVCIDB5s2WI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794578673; v=1; x=1795183473; b=ClgqgiCCzP13A/TYbH2Pfche+WTNU/pcWwKg4EiN63b9do3K/w0Xbtv2WllaHNvpctJpaz1y Hh6e4HCBLyLWowEXdndnH8ZoyNnap24oK4dXV6DEAMM5eMxwT8La+tgYsAdgKFeyuKiF3/mXlKi RfcW76bIdLFP9894KALKZLVY= X-Envelope-To: netdev@vger.kernel.org X-Received: by mta10.migadu.com with ESMTPS id 6508aef634fb337d; Fri, 13 Nov 2026 14:04:33 +0000 X-Mizu-Trace-ID: 6508aef634fb337d X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-B4-Tracking: v=1; b=H4sIAAAAAAAC/yWMUQrCMBAFr1L220AaIaJXESlt8qorspXsthRK7 27Uz2GY2UhRGEqXZqOChZUnqdAeGkqPXu5wnCtT8CG2Png3TJI7iL76BV2BWpmTuaM/RY8YMsY z1fZdMPL6+15JYE6wGt3+RufhiWTfLe37BzkzkyWDAAAA X-Change-ID: 20261020-bond_enslave_restruct-30760e62def9 X-Cc: Hangbin Liu <hangbin.liu@linux.dev>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Hangbin Liu <hangbin.liu@linux.dev> X-Mailer: b4 0.16.0