From nobody Tue Apr 23 21:43:22 2024 X-Original-To: dev-commits-src-all@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 4VPFwp3Nlhz5J7TR; Tue, 23 Apr 2024 21:43:22 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VPFwp2Xhqz4vHh; Tue, 23 Apr 2024 21:43:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713908602; 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=KISc76H043viJckgZ94GsF5CN5cGWg9EgtNvzVRZnbo=; b=ps1txq/ptg5jfpiVwCesRXrOLkuSH0+D5BojvzTRTLdyxvrx/64Ts5GYk0J9agzDAKEnPz u08LJScQXJ/hxblfm0yLWTVncUrhk1XFnF1ewhLWyX80VzV1NR36HqzoOdv7/zmdcbhs3H lEJBZ3v+Zb0mw0HWah57X3IWQKHsFHoKxrdmqWfRjSIhk54HQ5XphuIU5lX8Bb7q+0XHBM xpchFXGrQNUHj0c67cJcGHPDmPQcCVQXKAuXPqSKT6i8hvgMHQLC+BnJ+i4zGF6NhLpHPK T8Uxwj9hWk037hQ3wvyeI1PGlEirZBNsakXvL9yqRuGtn9Z+vgK6lUtGKEGm1w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713908602; a=rsa-sha256; cv=none; b=m6Wt8JgSuP8UJ2cjAsY9SAewDTz3NELVkN9/vNq5D9fzThHLIRokMmqMH541b955Waqg/F 3+TBviI1Og+PWnVewd9DqRcvXhLBqR4U3oIPSJzVQM+nA3mzQZnt9l78jVdEE6uwdmCQyA 7BgVVmJI2XwCG66uM70Ob/YcEIklNYhpwzh/stPn4YlyObAztyHJKrqqsqwipiGLNuZXVF uFnrHt7NgQ5BSgp0AHbkAfE56cQvU6tlOJn38pKqutF77tqnA99amGpBtYai87DiQpQkD4 6AxQRfwgduwxUCcF109LwhqhBxSb4HB7EoyXrmrlL62d9AIRbW1ZKUOahcL/bg== 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=1713908602; 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=KISc76H043viJckgZ94GsF5CN5cGWg9EgtNvzVRZnbo=; b=fgwvPBifM3EsAairKnv2Np/+8BIGd7YTg0FC4abvSNlWSID1ySuT7EYFS5V+qrfeNxZsAX ipfSMW/vF5algliC5u8yyK62vMKh7dJFDShxTC7GdCK5JvBLDnMI8U3qzfsgSKev4Fp4ai VhP0OD72h2v4yMP6zFOn443DK1c4WU1mEOkOaWi7oCXslQ8gvY7RNXi3hgUt605Y/EzL7g k5wwhRN3Dv7UYiFJM2ARpOMk7MNMQ3ggVJS8b6RixR9MgmspPPOEHbNXQFerPsvkey0mlW q1D0y9AYHeVLghfKX+kEc6SfRSywRIy+8dL2O5lpWomFd/RUQ20rWN/OS1TcfQ== 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 4VPFwp2874zpY0; Tue, 23 Apr 2024 21:43:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43NLhMsc079921; Tue, 23 Apr 2024 21:43:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43NLhMxd079918; Tue, 23 Apr 2024 21:43:22 GMT (envelope-from git) Date: Tue, 23 Apr 2024 21:43:22 GMT Message-Id: <202404232143.43NLhMxd079918@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 65767e6126a7 - main - sys/net/if_bridge: support non-INET kernels List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 65767e6126a7e92bc76561b4ffd005cf85ba525e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=65767e6126a7e92bc76561b4ffd005cf85ba525e commit 65767e6126a7e92bc76561b4ffd005cf85ba525e Author: Lexi Winter AuthorDate: 2024-04-23 21:12:57 +0000 Commit: Warner Losh CommitDate: 2024-04-23 21:13:00 +0000 sys/net/if_bridge: support non-INET kernels Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1159 --- sys/net/if_bridge.c | 56 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 1b4ac92b62a3..7b44d85d1fe8 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -403,14 +403,19 @@ static int bridge_ioctl_sproto(struct bridge_softc *, void *); static int bridge_ioctl_stxhc(struct bridge_softc *, void *); static int bridge_pfil(struct mbuf **, struct ifnet *, struct ifnet *, int); +static void bridge_linkstate(struct ifnet *ifp); +static void bridge_linkcheck(struct bridge_softc *sc); + +#ifdef INET static int bridge_ip_checkbasic(struct mbuf **mp); +static int bridge_fragment(struct ifnet *, struct mbuf **mp, + struct ether_header *, int, struct llc *); +#endif /* INET */ + #ifdef INET6 static int bridge_ip6_checkbasic(struct mbuf **mp); #endif /* INET6 */ -static int bridge_fragment(struct ifnet *, struct mbuf **mp, - struct ether_header *, int, struct llc *); -static void bridge_linkstate(struct ifnet *ifp); -static void bridge_linkcheck(struct bridge_softc *sc); + /* * Use the "null" value from IEEE 802.1Q-2014 Table 9-2 @@ -3390,12 +3395,15 @@ bridge_state_change(struct ifnet *ifp, int state) static int bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir) { - int snap, error, i, hlen; + int snap, error, i; struct ether_header *eh1, eh2; - struct ip *ip; struct llc llc1; u_int16_t ether_type; pfil_return_t rv; +#ifdef INET + struct ip *ip = NULL; + int hlen = 0; +#endif snap = 0; error = -1; /* Default error if not error == 0 */ @@ -3436,31 +3444,36 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir) } /* - * If we're trying to filter bridge traffic, don't look at anything - * other than IP and ARP traffic. If the filter doesn't understand - * IPv6, don't allow IPv6 through the bridge either. This is lame - * since if we really wanted, say, an AppleTalk filter, we are hosed, - * but of course we don't have an AppleTalk filter to begin with. - * (Note that since pfil doesn't understand ARP it will pass *ALL* - * ARP traffic.) + * If we're trying to filter bridge traffic, only look at traffic for + * protocols available in the kernel (IPv4 and/or IPv6) to avoid + * passing traffic for an unsupported protocol to the filter. This is + * lame since if we really wanted, say, an AppleTalk filter, we are + * hosed, but of course we don't have an AppleTalk filter to begin + * with. (Note that since pfil doesn't understand ARP it will pass + * *ALL* ARP traffic.) */ switch (ether_type) { +#ifdef INET case ETHERTYPE_ARP: case ETHERTYPE_REVARP: if (V_pfil_ipfw_arp == 0) return (0); /* Automatically pass */ - break; + /*FALLTHROUGH*/ case ETHERTYPE_IP: +#endif #ifdef INET6 case ETHERTYPE_IPV6: #endif /* INET6 */ break; + default: /* - * Check to see if the user wants to pass non-ip - * packets, these will not be checked by pfil(9) and - * passed unconditionally so the default is to drop. + * We get here if the packet isn't from a supported + * protocol. Check to see if the user wants to pass + * non-IP packets, these will not be checked by pfil(9) + * and passed unconditionally so the default is to + * drop. */ if (V_pfil_onlyip) goto bad; @@ -3492,9 +3505,11 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir) */ if (dir == PFIL_IN) { switch (ether_type) { +#ifdef INET case ETHERTYPE_IP: error = bridge_ip_checkbasic(mp); break; +#endif #ifdef INET6 case ETHERTYPE_IPV6: error = bridge_ip6_checkbasic(mp); @@ -3514,6 +3529,7 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir) */ rv = PFIL_PASS; switch (ether_type) { +#ifdef INET case ETHERTYPE_IP: /* * Run pfil on the member interface and the bridge, both can @@ -3571,6 +3587,8 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir) ip->ip_sum = in_cksum(*mp, hlen); break; +#endif + #ifdef INET6 case ETHERTYPE_IPV6: if (V_pfil_bridge && dir == PFIL_OUT && bifp != NULL && (rv = @@ -3628,6 +3646,7 @@ bad: return (error); } +#ifdef INET /* * Perform basic checks on header size since * pfil assumes ip_input has already processed @@ -3728,6 +3747,7 @@ bad: *mp = m; return (-1); } +#endif #ifdef INET6 /* @@ -3783,6 +3803,7 @@ bad: } #endif /* INET6 */ +#ifdef INET /* * bridge_fragment: * @@ -3859,6 +3880,7 @@ dropit: } return (error); } +#endif static void bridge_linkstate(struct ifnet *ifp)