From owner-svn-src-head@freebsd.org Sat May 30 02:09:37 2020 Return-Path: Delivered-To: svn-src-head@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 188D52F704E; Sat, 30 May 2020 02:09:37 +0000 (UTC) (envelope-from karels@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49YlHh6z2Zz3cGx; Sat, 30 May 2020 02:09:36 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D0730211EB; Sat, 30 May 2020 02:09:36 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04U29apT048162; Sat, 30 May 2020 02:09:36 GMT (envelope-from karels@FreeBSD.org) Received: (from karels@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04U29aYu048161; Sat, 30 May 2020 02:09:36 GMT (envelope-from karels@FreeBSD.org) Message-Id: <202005300209.04U29aYu048161@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: karels set sender to karels@FreeBSD.org using -f From: Mike Karels Date: Sat, 30 May 2020 02:09:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361642 - head/sys/arm64/broadcom/genet X-SVN-Group: head X-SVN-Commit-Author: karels X-SVN-Commit-Paths: head/sys/arm64/broadcom/genet X-SVN-Commit-Revision: 361642 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2020 02:09:37 -0000 Author: karels Date: Sat May 30 02:09:36 2020 New Revision: 361642 URL: https://svnweb.freebsd.org/changeset/base/361642 Log: genet: workaround for problem with ICMPv6 echo replies The ICMPv6 echo reply is constructed with the IPv6 header too close to the beginning of a packet for an Ethernet header to be prepended, so we end up with an mbuf containing just the Ethernet header. The GENET controller doesn't seem to handle this, with or without transmit checksum offload. At least until we have chip documentation, do a pullup to satisfy the chip. Hopefully this can be fixed properly in the future. Modified: head/sys/arm64/broadcom/genet/if_genet.c Modified: head/sys/arm64/broadcom/genet/if_genet.c ============================================================================== --- head/sys/arm64/broadcom/genet/if_genet.c Sat May 30 02:02:34 2020 (r361641) +++ head/sys/arm64/broadcom/genet/if_genet.c Sat May 30 02:09:36 2020 (r361642) @@ -76,6 +76,10 @@ __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" @@ -968,6 +972,36 @@ 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. + */ +#define ICMP6_LEN (sizeof(struct ether_header) + sizeof(struct ip6_hdr) + \ + sizeof(struct icmp6_hdr)) + 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); + } + } + } + } +#undef ICMP6_LEN +#endif if ((if_getcapenable(sc->ifp) & (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6)) != 0) { csum_flags = m->m_pkthdr.csum_flags;