From nobody Sun Aug 06 20:36:24 2023 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 4RJrp11QY4z4mNZ1; Sun, 6 Aug 2023 20:36:25 +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 4RJrp10WKZz4bG1; Sun, 6 Aug 2023 20:36:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691354185; 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=fBGf2PfYUsDHryfVUPWaedUoBp+uL/gobSKWWwATVXY=; b=bncT6qkHB9cNWp7Q92EqcZxD06v46DmhTNTOrp6CbUDWeP2+fiv9eYiaoQS+sQrlbumE3z GxzU6DTqI2XFYapECbkR8jPNrwDrevepSLtY42vb7NUpZn4GXhX8PM4IlSjS553kdVFaCT DlV53xQEjq9w26BEarzYCqWprwS9IhrcOSl0Wh9jVJviBqNl5f8pjKaWQdlGfLzabrI6G9 E/DZi9rCnnyrjKACQisuiz/waWnQRro+fSYDSygm/BvBI29oVWBlQ2Y3YDY0AzmCPTSOMw SIKZ7KwF9nVta8rxQtanqsdXIQI4mVr6K1nrM423sU76z06j2C+G5rjU+9044Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691354185; 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=fBGf2PfYUsDHryfVUPWaedUoBp+uL/gobSKWWwATVXY=; b=D73QizM+IOS9kRVFeky2OIFSM+QrOoJCYNtIz+W3w5b8ACy5SHlF5fresdnybJn8tOgqUL XZgbG9bc92CN6RI1Pmvp1oI02W+jTlKOmQApFVQ0qqLJn04C79pW2CJRLWZYEky7kMIGXR Jf//SUojIbmrSb/jSGvG4/GERCyt2IOBV81XfWfsr114k4T5/f26B2Aa4mdkUczuBCIPIV nxW4jTB9YBodLsmKMFb4HF3iYvnAMxjYBLB3he8T7skObWzaeu6usYGmrW9rDJoZ40oeRO pfxwkrWjXhawvr9si+rlGL0iQ5wrWHKvFmmsR4kSSBQ9hjy1UNOmoFCDyZIBFg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691354185; a=rsa-sha256; cv=none; b=Uylf2TANE7+GeMTILjzgGE2SZTz8RSkshTbWdA62VKA1s+BakCwnD8nv2wJBeUkRU0rWmS XZvNgx3avxQJYHZh7sqYJ68gOJD5BHzRI567GhLidZtw0XZyqfI6QwjCJ4HDhPSpHBBj98 eNVO2ScpOAOtj/VSeNwMWTS5Cd3lJPo0UzGPAoUz0MPMC30zlV682HpRtJEoBFcgxrlVgy t25rcF9Ogli9/VpilxDIdjRAt1SC1oZIZkVkTMqRq4LsmpF0B+RhANASzkkv3EQqGyjHge Vzlp3w45WygWCbHW45vzO48K6RxPORv0fkToDhEYoLXi4hWvEXmvImpvhLei8w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4RJrp06jvXz8L1; Sun, 6 Aug 2023 20:36:24 +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 376KaO0C042632; Sun, 6 Aug 2023 20:36:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 376KaOof042631; Sun, 6 Aug 2023 20:36:24 GMT (envelope-from git) Date: Sun, 6 Aug 2023 20:36:24 GMT Message-Id: <202308062036.376KaOof042631@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marius Strobl Subject: git: 3b0d328a2def - stable/13 - gif(4): Revert in{,6}_gif_output() misalignment handling 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: marius X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3b0d328a2defb7a949f6ca5afd83281ceed1b6c8 Auto-Submitted: auto-generated The branch stable/13 has been updated by marius: URL: https://cgit.FreeBSD.org/src/commit/?id=3b0d328a2defb7a949f6ca5afd83281ceed1b6c8 commit 3b0d328a2defb7a949f6ca5afd83281ceed1b6c8 Author: Marius Strobl AuthorDate: 2023-07-19 17:17:43 +0000 Commit: Marius Strobl CommitDate: 2023-08-06 17:16:57 +0000 gif(4): Revert in{,6}_gif_output() misalignment handling The code added in c89c8a1029860182eece5d51ec09119b9500e5a1 in order to compensate possible misalignment caused by prepending the IP4/6 header with an EtherIP one got broken at some point by a rewrite of gif(4). For better or worse, 8018ac153f7671699ca008f31c0fad9caef2f531 relaxed the alignment of struct ip from 32 bit to 16 bit, though. As a result, a 16 bit offset of the IPv4 header induced by the addition of the 16 bit EtherIP one no longer is a problem in the first place. The alignment of struct ip6_hdr currently is even only 8 bit, making it even less problematic with regards to possible misalignment. Thus, remove the code for handling misalignment in in{,6}_gif_output() altogether again. While at it, replace the 3 bcopy(9) calls in gif(4) with memcpy(9) as there's no need to handle overlap here. (cherry picked from commit e82d7b2952afaf9625a3d7b05d03c43c1d3e7d9c) --- sys/net/if_gif.c | 2 +- sys/net/if_gif.h | 2 -- sys/netinet/in_gif.c | 19 ++----------------- sys/netinet6/in6_gif.c | 19 ++----------------- 4 files changed, 5 insertions(+), 37 deletions(-) diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index ea4b80690e50..4d2c1dcf091d 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -407,7 +407,7 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, uint32_t af; if (dst->sa_family == AF_UNSPEC) - bcopy(dst->sa_data, &af, sizeof(af)); + memcpy(&af, dst->sa_data, sizeof(af)); else af = RO_GET_FAMILY(ro, dst); /* diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h index 2e61fcc166e1..f8fda6ddf801 100644 --- a/sys/net/if_gif.h +++ b/sys/net/if_gif.h @@ -94,8 +94,6 @@ struct etherip_header { } __packed; #define ETHERIP_VERSION 0x3 -/* mbuf adjust factor to force 32-bit alignment of IP header */ -#define ETHERIP_ALIGN 2 #define GIF_WAIT() epoch_wait_preempt(net_epoch_preempt) diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index a9f3d384fb5a..2caa9fcc23e2 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -272,31 +272,16 @@ in_gif_output(struct ifnet *ifp, struct mbuf *m, int proto, uint8_t ecn) { struct gif_softc *sc = ifp->if_softc; struct ip *ip; - int len; /* prepend new IP header */ NET_EPOCH_ASSERT(); - len = sizeof(struct ip); -#ifndef __NO_STRICT_ALIGNMENT - if (proto == IPPROTO_ETHERIP) - len += ETHERIP_ALIGN; -#endif - M_PREPEND(m, len, M_NOWAIT); + M_PREPEND(m, sizeof(struct ip), M_NOWAIT); if (m == NULL) return (ENOBUFS); -#ifndef __NO_STRICT_ALIGNMENT - if (proto == IPPROTO_ETHERIP) { - len = mtod(m, vm_offset_t) & 3; - KASSERT(len == 0 || len == ETHERIP_ALIGN, - ("in_gif_output: unexpected misalignment")); - m->m_data += len; - m->m_len -= ETHERIP_ALIGN; - } -#endif ip = mtod(m, struct ip *); MPASS(sc->gif_family == AF_INET); - bcopy(sc->gif_iphdr, ip, sizeof(struct ip)); + memcpy(ip, sc->gif_iphdr, sizeof(struct ip)); ip->ip_p = proto; /* version will be set in ip_output() */ ip->ip_ttl = V_ip_gif_ttl; diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c index 54cb81c6130f..eed311b86ff2 100644 --- a/sys/netinet6/in6_gif.c +++ b/sys/netinet6/in6_gif.c @@ -290,31 +290,16 @@ in6_gif_output(struct ifnet *ifp, struct mbuf *m, int proto, uint8_t ecn) { struct gif_softc *sc = ifp->if_softc; struct ip6_hdr *ip6; - int len; /* prepend new IP header */ NET_EPOCH_ASSERT(); - len = sizeof(struct ip6_hdr); -#ifndef __NO_STRICT_ALIGNMENT - if (proto == IPPROTO_ETHERIP) - len += ETHERIP_ALIGN; -#endif - M_PREPEND(m, len, M_NOWAIT); + M_PREPEND(m, sizeof(struct ip6_hdr), M_NOWAIT); if (m == NULL) return (ENOBUFS); -#ifndef __NO_STRICT_ALIGNMENT - if (proto == IPPROTO_ETHERIP) { - len = mtod(m, vm_offset_t) & 3; - KASSERT(len == 0 || len == ETHERIP_ALIGN, - ("in6_gif_output: unexpected misalignment")); - m->m_data += len; - m->m_len -= ETHERIP_ALIGN; - } -#endif ip6 = mtod(m, struct ip6_hdr *); MPASS(sc->gif_family == AF_INET6); - bcopy(sc->gif_ip6hdr, ip6, sizeof(struct ip6_hdr)); + memcpy(ip6, sc->gif_ip6hdr, sizeof(struct ip6_hdr)); ip6->ip6_flow |= htonl((uint32_t)ecn << 20); ip6->ip6_nxt = proto;