From owner-dev-commits-src-branches@freebsd.org Sun Mar 21 18:48:32 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C8D357FDEB; Sun, 21 Mar 2021 18:48:32 +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 4F3RV82dVyz3mw4; Sun, 21 Mar 2021 18:48:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4D6E81FC91; Sun, 21 Mar 2021 18:48:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 12LImWtG002283; Sun, 21 Mar 2021 18:48:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 12LImWaA002282; Sun, 21 Mar 2021 18:48:32 GMT (envelope-from git) Date: Sun, 21 Mar 2021 18:48:32 GMT Message-Id: <202103211848.12LImWaA002282@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mike Karels Subject: git: 35e7b6bff0b3 - stable/13 - genet: Fix problem with forwarding some TCP/IPv6 packets MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: karels X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 35e7b6bff0b39aa7c536dfbe3dd783abc983ea97 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2021 18:48:32 -0000 The branch stable/13 has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=35e7b6bff0b39aa7c536dfbe3dd783abc983ea97 commit 35e7b6bff0b39aa7c536dfbe3dd783abc983ea97 Author: Mike Karels AuthorDate: 2021-03-18 00:19:24 +0000 Commit: Mike Karels CommitDate: 2021-03-21 18:46:32 +0000 genet: Fix problem with forwarding some TCP/IPv6 packets TCP/IPv6 packets to be forwarded can be laid out with only the Ethernet header in the first mbuf, and these packets are lost. There was a previous hack to pullup ICMPv6 packets with such a layout for the same reason. Generalize, and pullup any IPv6 packets with only the Ethernet header in the first mbuf. Possibly this should also include IPv4, but that situation has not been observed to fail. PR: 254060 Reported by: denis at h3q.com MFC after: 3 days (cherry picked from commit 2bdcf6237744b2d9d9707d623660d33931daeb52) --- sys/arm64/broadcom/genet/if_genet.c | 46 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/sys/arm64/broadcom/genet/if_genet.c b/sys/arm64/broadcom/genet/if_genet.c index 5f2dfcc40395..0fe9f80f4c21 100644 --- a/sys/arm64/broadcom/genet/if_genet.c +++ b/sys/arm64/broadcom/genet/if_genet.c @@ -76,10 +76,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#define ICMPV6_HACK /* workaround for chip issue */ -#ifdef ICMPV6_HACK -#include -#endif #include "syscon_if.h" #include "miibus_if.h" @@ -955,6 +951,8 @@ gen_start_locked(struct gen_softc *sc) if (err != 0) { if (err == ENOBUFS) if_setdrvflagbits(ifp, IFF_DRV_OACTIVE, 0); + else if (m == NULL) + if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (m != NULL) if_sendq_prepend(ifp, m); break; @@ -995,36 +993,34 @@ gen_encap(struct gen_softc *sc, struct mbuf **mp) q = &sc->tx_queue[DEF_TXQUEUE]; m = *mp; -#ifdef ICMPV6_HACK + /* * Reflected ICMPv6 packets, e.g. echo replies, tend to get laid * out with only the Ethernet header in the first mbuf, and this - * doesn't seem to work. + * doesn't seem to work. Forwarded TCP packets over IPv6 also + * fail if laid out with only the Ethernet header in the first mbuf. + * For now, pull up any IPv6 packet with that layout. Maybe IPv4 + * needs it but we haven't run into it. Pulling up the sizes of + * ether_header + ip6_header + icmp6_hdr seems to work for both + * ICMPv6 and TCP over IPv6. */ -#define ICMP6_LEN (sizeof(struct ether_header) + sizeof(struct ip6_hdr) + \ - sizeof(struct icmp6_hdr)) +#define IP6_PULLUP_LEN (sizeof(struct ether_header) + \ + sizeof(struct ip6_hdr) + 8) if (m->m_len == sizeof(struct ether_header)) { int ether_type = mtod(m, struct ether_header *)->ether_type; - if (ntohs(ether_type) == ETHERTYPE_IPV6 && - m->m_next->m_len >= sizeof(struct ip6_hdr)) { - struct ip6_hdr *ip6; - - ip6 = mtod(m->m_next, struct ip6_hdr *); - if (ip6->ip6_nxt == IPPROTO_ICMPV6) { - m = m_pullup(m, - MIN(m->m_pkthdr.len, ICMP6_LEN)); - if (m == NULL) { - if (sc->ifp->if_flags & IFF_DEBUG) - device_printf(sc->dev, - "ICMPV6 pullup fail\n"); - *mp = NULL; - return (ENOMEM); - } + if (ntohs(ether_type) == ETHERTYPE_IPV6) { + m = m_pullup(m, MIN(m->m_pkthdr.len, IP6_PULLUP_LEN)); + if (m == NULL) { + if (sc->ifp->if_flags & IFF_DEBUG) + device_printf(sc->dev, + "IPV6 pullup fail\n"); + *mp = NULL; + return (ENOMEM); } } } -#undef ICMP6_LEN -#endif +#undef IP6_PULLUP_LEN + if ((if_getcapenable(sc->ifp) & (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6)) != 0) { csum_flags = m->m_pkthdr.csum_flags;