From nobody Fri Feb 6 03:38:51 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4f6fvc646Fz6FY8R for ; Fri, 06 Feb 2026 03:38:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f6fvc1fddz3QZp for ; Fri, 06 Feb 2026 03:38:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770349132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1SsIRpTGhTXPfEQ6uLRfT9+oorJDYQJNN6loaTxPpvk=; b=LSCFTeF8FyvzAM9Bj0Pvc/OPK/Vb7iKkRcPP18vXeONqtJJQaNmQr9H/qzzKAznM5V5Z4r RaNaUH5ptTflWlJ2B2uV1jT/LEpmSEaGpvEELHi7ugg3tmKSdG1BdlxQSAScckBa+3aroF ZeH3Q1LAgy6ITRLbq1HSFpbecUYShnNeI67JXkoTmK/VUD+LrayId8MVb93RmChKyfhhiN eQCYuxjcQp96JfbLlKZqMpmFnw7qnWBB3fOQA9VeP1/zzlSSofd+lLx9lHkDOevgf2IZUv t21foezNaqhvZoEJVdvPDtGmvLUXdKG5yeELjVUWolzQ+3lhnx1sQHaRw/bOgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770349132; a=rsa-sha256; cv=none; b=nRFna+rrq5f2CwEGAQn6AtqLQ1QVs8gEhXOu1NYDUsRMkj2f1Lr3dv26OOna+wTJMdUpiX kviVwWIClTrSlwS4uAWTqAFNmgo7DKLGFzBHtNGzc0Ma+EuCGbLqRY8lKA0qWs8nlCZkkt pv1KUVWrhiNYSEV/cbAt7kqW20wd54cqEdj4isidcZRnaAxc/05SNOOvWdHnoRtzuItiuy AWJn+PJzeQtm4gnVc7izUYjuSRu2akxGZhRns4luoz3sCg1khHWfx+w6GS6MmXRY/2KZn8 HfM35sEcZ6GhZsuX5IEpbliCXzAWDip+P73BeIcb/FfDzqaPQlWI/NN/VpLXjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770349132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1SsIRpTGhTXPfEQ6uLRfT9+oorJDYQJNN6loaTxPpvk=; b=AmAcLWnrHcKn9JFtzrp6lS/4aHuXCoSA+7OEAGUMk99KmcZnwWZl+AL7SxFTGpfoYRKs7G cejYCaBn9NafH+l+8YCsFrYuTmfu0np0ZfkIvPYrDFEFh63HrqN6T9rkDhkKso/m7yI4RU zIjh64J9S3MJLQ2MDeGLtUZBTbqyOXjRn/QMrlhK8ET7SFXgdbtjIGoPeyGEjZwyzGAoLF UkbELcOKTHfUQrC6Np/etgakzOi+Rtl5WgmoBqMfGBDgdkdGenyEaYrub4Fg+uJsu3aRlH 4o0GRtVuBYcAE2991+5652iVj/IFxHVYbvE01fW8UjV0ren11ekD9lB1CYFd4w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f6fvc0Db0zylx for ; Fri, 06 Feb 2026 03:38:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 42e7d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 06 Feb 2026 03:38:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: a622030b4bae - main - lagg: Make the none protocol a first-class citizen List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a622030b4baec2136984cea7bd25c2985a2ae9b3 Auto-Submitted: auto-generated Date: Fri, 06 Feb 2026 03:38:51 +0000 Message-Id: <6985624b.42e7d.c91bd19@gitrepo.freebsd.org> The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=a622030b4baec2136984cea7bd25c2985a2ae9b3 commit a622030b4baec2136984cea7bd25c2985a2ae9b3 Author: Zhenlei Huang AuthorDate: 2026-02-06 03:37:43 +0000 Commit: Zhenlei Huang CommitDate: 2026-02-06 03:37:43 +0000 lagg: Make the none protocol a first-class citizen All the other protocols have corresponding start and input routines, which are used in the fast path. Currently the none protocol is treated specially. In the fast path it is checked to indicate whether a working protocol is configured. There are two issues raised by this design: 1. In production, other protocols are commonly used, but not the none protocol. It smells like an overkill to always check it in the fast path. It is unfair to other commonly used protocols. 2. PR 289017 reveals that there's a small window between checking the protocol and calling lagg_proto_start(). lagg_proto_start() is possible to see the none protocol and do NULL deferencing. Fix them by making the none protocol a first-class citizen so that it has start and input routines just the same as other protocols. Then we can stop checking it in the fast path, since lagg_proto_start() and lagg_proto_input() will never fail to work. The error ENETDOWN is chosen for the start routine. Obviously no active ports are available, and the packets will go nowhere. It is also a better error than ENXIO, since indeed the interface is configured and has a TX algorithm (the none protocol). PR: 289017 Diagnosed by: Qiu-ji Chen Tested by: Gui-Dong Han Reviewed by: glebius MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D55123 --- sys/net/if_lagg.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 5b52bfa80e3b..21ea2b30459b 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -169,6 +169,11 @@ static void lagg_media_status(struct ifnet *, struct ifmediareq *); static struct lagg_port *lagg_link_active(struct lagg_softc *, struct lagg_port *); +/* No proto */ +static int lagg_none_start(struct lagg_softc *, struct mbuf *); +static struct mbuf *lagg_none_input(struct lagg_softc *, struct lagg_port *, + struct mbuf *); + /* Simple round robin */ static void lagg_rr_attach(struct lagg_softc *); static int lagg_rr_start(struct lagg_softc *, struct mbuf *); @@ -219,7 +224,9 @@ static const struct lagg_proto { void (*pr_portreq)(struct lagg_port *, void *); } lagg_protos[] = { { - .pr_num = LAGG_PROTO_NONE + .pr_num = LAGG_PROTO_NONE, + .pr_start = lagg_none_start, + .pr_input = lagg_none_input, }, { .pr_num = LAGG_PROTO_ROUNDROBIN, @@ -2129,8 +2136,8 @@ lagg_transmit_ethernet(struct ifnet *ifp, struct mbuf *m) if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) MPASS(m->m_pkthdr.snd_tag->ifp == ifp); #endif - /* We need a Tx algorithm and at least one port */ - if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) { + /* We need at least one port */ + if (sc->sc_count == 0) { m_freem(m); if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENXIO); @@ -2151,8 +2158,8 @@ lagg_transmit_infiniband(struct ifnet *ifp, struct mbuf *m) if (m->m_pkthdr.csum_flags & CSUM_SND_TAG) MPASS(m->m_pkthdr.snd_tag->ifp == ifp); #endif - /* We need a Tx algorithm and at least one port */ - if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) { + /* We need at least one port */ + if (sc->sc_count == 0) { m_freem(m); if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); return (ENXIO); @@ -2180,8 +2187,7 @@ lagg_input_ethernet(struct ifnet *ifp, struct mbuf *m) NET_EPOCH_ASSERT(); if ((scifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || - lp->lp_detaching != 0 || - sc->sc_proto == LAGG_PROTO_NONE) { + lp->lp_detaching != 0) { m_freem(m); return (NULL); } @@ -2215,8 +2221,7 @@ lagg_input_infiniband(struct ifnet *ifp, struct mbuf *m) NET_EPOCH_ASSERT(); if ((scifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || - lp->lp_detaching != 0 || - sc->sc_proto == LAGG_PROTO_NONE) { + lp->lp_detaching != 0) { m_freem(m); return (NULL); } @@ -2390,6 +2395,25 @@ lagg_enqueue(struct ifnet *ifp, struct mbuf *m) return (ifp->if_transmit)(ifp, m); } +/* + * No proto + */ +static int +lagg_none_start(struct lagg_softc *sc, struct mbuf *m) +{ + m_freem(m); + if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1); + /* No active ports available */ + return (ENETDOWN); +} + +static struct mbuf * +lagg_none_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) +{ + m_freem(m); + return (NULL); +} + /* * Simple round robin aggregation */