From nobody Fri Sep 20 11:40:04 2024 X-Original-To: dev-commits-src-branches@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 4X99RS5SVYz5Wdwb; Fri, 20 Sep 2024 11:40:04 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X99RS3JQ4z4lhs; Fri, 20 Sep 2024 11:40:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1726832404; 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=8q+TOtGjGv8eQnm8wNbnfXBAl5kmAhCbi/SDDZwdw0k=; b=SLyqbIY/0xn5JeagFdn5aTGDroN7WCbv9N69U9025edTeeJAKviIXKtx9FBWKJBJat4Id+ PndT+8G2qZErFGb5cXj/l68luY3f+c/Y2UY8kA03kCjRj5gaBNhaAZCiNsIDHPU3Nm9DqY 0jpgtNbUwFIIuuMv3MfP6eWirGw628TZbultJGTqZNw2+O5c08fOP0URGPOgxnCn407Z96 qhsTPaZrZ8IRq1urLEAuCorLMHl/wjcf5ildhtnJLMJXswmrR3Vlpyd7kn5yRld41XzVTT gKFZxl6IMVXzepywQ5pfi0TGeDJMn/HCYUqNqi5C9ZxAYD67biuAdyJTsUK17w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1726832404; a=rsa-sha256; cv=none; b=RAXN0isL7dxXCzD2kLGmHpyMztpi6UC735KcTlz+4OllKXfvv/iCJf6jjMQ5rjDBWGxWJY F6iQyPC+zrtcjn+jTkrMhVfVpZfISIvxBuk392TdYn1mLA9Iyw9yeKEHzAQgeoRgGyBe7H BYBuT5R4QHdeh/bphufXpH3bcS0rB8AHdmg/tWhWfDv4JuQ9V5M80oebK70tl/sbk9iQGe hvLaP7KE9GAkGZB7TdDUspHi5jwXgOM40XO8ZsijCguS0VwtZFqnKt/x2gSxSzS9+xZ4OQ NGM1jjDP9z+XuYC4DV/PzIW5VNGg63HaZC9ypuYVR3gq2ZGSfXTbcO/nOpu3DQ== 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=1726832404; 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=8q+TOtGjGv8eQnm8wNbnfXBAl5kmAhCbi/SDDZwdw0k=; b=DnyOIqbhFG85mFjcYMMB6U6W2QJccv7Km3gf07aVA0qSYZBALqRakqffTPsnkTSQyXZ5la ykK4va9MR2g12Yh4Qg2bcObiZAT/28pXhNTmWYL0Pnp7j+n7UbuYbOEJ1I8CsEtwIBJABw E6TXCZkgUtcKn9GHYyH18td4eE6rrpQNGeTbZU8szmjkKm5bYYnQtkNahBWLsViUpa5+TA M6EZrMzlSmQWS+oAn401Px/SHZrZ4ZHrYDEGonAeWXLvZbHqEqJ+N1HkXb1ErYGEXGj4/K /EfUP203IMwZ0AxK26fPJLdCrmVLbKw2ZaIN4ETwtDU93Q4CphdP8/zQLxV6pw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X99RS2drJzp2N; Fri, 20 Sep 2024 11:40:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48KBe4fZ007193; Fri, 20 Sep 2024 11:40:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48KBe4nP007188; Fri, 20 Sep 2024 11:40:04 GMT (envelope-from git) Date: Fri, 20 Sep 2024 11:40:04 GMT Message-Id: <202409201140.48KBe4nP007188@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 772e980da4bd - stable/14 - ifnet: Add handling for toggling IFF_ALLMULTI in ifhwioctl() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 772e980da4bd5d47eceee95e91e8573ecb48be1c Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=772e980da4bd5d47eceee95e91e8573ecb48be1c commit 772e980da4bd5d47eceee95e91e8573ecb48be1c Author: Mark Johnston AuthorDate: 2024-09-06 16:55:42 +0000 Commit: Mark Johnston CommitDate: 2024-09-20 11:39:16 +0000 ifnet: Add handling for toggling IFF_ALLMULTI in ifhwioctl() IFF_ALLMULTI has an associated activation counter and so needs special treatment, like IFF_PROMISC. Introduce IFF_PALLMULTI, akin to IFF_PPROMISC, which indicates that userspace requested allmulti mode, and handle it specially in ifhwioctl(). Reviewed by: zlei, glebius MFC after: 2 weeks Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D46524 (cherry picked from commit 58f194223ab8578269772a6874a8444e5e03afaf) --- sys/net/if.c | 16 ++++++++++++++-- sys/net/if.h | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 9beac09d54c9..fe51ba5a0b60 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2614,7 +2614,12 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) (ifp->if_flags & IFF_UP) == 0) { do_ifup = 1; } - /* See if permanently promiscuous mode bit is about to flip */ + + /* + * See if the promiscuous mode or allmulti bits are about to + * flip. They require special handling because in-kernel + * consumers may indepdently toggle them. + */ if ((ifp->if_flags ^ new_flags) & IFF_PPROMISC) { if (new_flags & IFF_PPROMISC) ifp->if_flags |= IFF_PROMISC; @@ -2625,6 +2630,12 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) ((new_flags & IFF_PPROMISC) ? "enabled" : "disabled")); } + if ((ifp->if_flags ^ new_flags) & IFF_PALLMULTI) { + if (new_flags & IFF_PALLMULTI) + ifp->if_flags |= IFF_ALLMULTI; + else if (ifp->if_amcount == 0) + ifp->if_flags &= ~IFF_ALLMULTI; + } ifp->if_flags = (ifp->if_flags & IFF_CANTCHANGE) | (new_flags &~ IFF_CANTCHANGE); if (ifp->if_ioctl) { @@ -3386,7 +3397,8 @@ int if_allmulti(struct ifnet *ifp, int onswitch) { - return (if_setflag(ifp, IFF_ALLMULTI, 0, &ifp->if_amcount, onswitch)); + return (if_setflag(ifp, IFF_ALLMULTI, IFF_PALLMULTI, &ifp->if_amcount, + onswitch)); } struct ifmultiaddr * diff --git a/sys/net/if.h b/sys/net/if.h index 4c3cfd06ca03..2403b22c191f 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -162,7 +162,7 @@ struct if_data { #define IFF_STICKYARP 0x100000 /* (n) sticky ARP */ #define IFF_DYING 0x200000 /* (n) interface is winding down */ #define IFF_RENAMING 0x400000 /* (n) interface is being renamed */ -#define IFF_SPARE 0x800000 +#define IFF_PALLMULTI 0x800000 /* (n) user-requested allmulti mode */ #define IFF_NETLINK_1 0x1000000 /* (n) used by netlink */ /*