From nobody Wed Jul 26 11:28:58 2023 X-Original-To: dev-commits-src-main@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 4R9s9Q320yz4pKWD; Wed, 26 Jul 2023 11:28:58 +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 4R9s9Q2XZ2z4LG0; Wed, 26 Jul 2023 11:28:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690370938; 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=Pa0Kz8GgpR0oepT2v3xc9x7shvWIwP2GHZ3o2Kydt9w=; b=Gjjz8D/qn61eZYueUKO2BeybcvqZ88C39QLUSqLeXA7/bwF1nGsRoFEVeuBi8M8r6+CoVn JQUHet76CZvw0C+Nw8/SdmaUG/Qp1aO8oNEkhAmJhnBFR6ICHSrbCZGGCfhLqzkn+7gG5e IQawBeHbA9L/crfvoVWAuCFnkxm2wmrczKCe5owwpXzutq6b83bpZ3YHj/nScpS8s98Qs+ ncQU0HzUgvwt1A2fgmFfioNP5jm5mMIfbh3AUx2kmmBF2y36wvx4LWE2wcKllVH7viPptF V8H1Hsl1FkuI9TNgCMuEycu70XBHuoZYPtzEGafWhQF0ORhDQt1AIh0/J/ZRqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690370938; 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=Pa0Kz8GgpR0oepT2v3xc9x7shvWIwP2GHZ3o2Kydt9w=; b=rz0tAYnb6bVr//IPnY+tt+Uit3Iuhmvn1vmuWty3s8MnxpLT7niQHAnUCBES2NpsNtgzlt TemIu6tr3U8f9SkfZ0Mzqc5prhQ/H6tb74o/SH5nv6JRz2p+hrQaKPu4vHg1+rozUpGkqr e8U7QdeJCGh0zbgYtopLd8v01AI8Uu85teyjQ2+JwgshiHcL2fnAHYuUUYcwl8mtYjxGDG hayjQJYcm+bFMe9AXqaSDfBJxebeCF+p/JJZudlJnf1FrGs0P0WBRxEIvLq9ew314H0SGd JG7QJzjE2430FcTBpPW04XHnhwVSfOPZAcVD8n2CFzBlD9AZGRTkORSLtXLHeQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690370938; a=rsa-sha256; cv=none; b=hU/71vkH46uhno9GCpEhBs8WeFk4yTSjzir2+eR1YgLKQ9UcBJC5IYEaiiL3UW9Lz+nnl4 F1mN7QC5BRbzxeJwWm3Uos+ZusaImmqmQVR8O4fJnbbeEb4Gpba0nOPK0xlRdjWJz/WlsT VedMuXAwbDfvkDC/cjucYo2Ul9HFkxbzDf7Tjk6+2HzOKkfI8eNCpBJ/1Q1yCquhCOR2NG hfFPVcFq8faOlD+PxrezRE+kWZMrANhR5J5ND2SvaRMg2Q3+toRetjU4S72FYTq+xpFGMY kJpFwpgFJ3fJSN3Jp9dGutVfIKB+5gIDqrpgivzSejgVjHYN6OsRNdPkgF7N1w== 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 4R9s9Q1XFGzghF; Wed, 26 Jul 2023 11:28:58 +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 36QBSwvv024120; Wed, 26 Jul 2023 11:28:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36QBSw1V024119; Wed, 26 Jul 2023 11:28:58 GMT (envelope-from git) Date: Wed, 26 Jul 2023 11:28:58 GMT Message-Id: <202307261128.36QBSw1V024119@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Marius Strobl Subject: git: e82d7b2952af - main - gif(4): Revert in{,6}_gif_output() misalignment handling List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: e82d7b2952afaf9625a3d7b05d03c43c1d3e7d9c Auto-Submitted: auto-generated The branch main has been updated by marius: URL: https://cgit.FreeBSD.org/src/commit/?id=e82d7b2952afaf9625a3d7b05d03c43c1d3e7d9c commit e82d7b2952afaf9625a3d7b05d03c43c1d3e7d9c Author: Marius Strobl AuthorDate: 2023-07-19 17:17:43 +0000 Commit: Marius Strobl CommitDate: 2023-07-26 11:14:22 +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. --- 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 18160c21411e..5fa7664780c1 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -408,7 +408,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 e43b4c645372..f32b9a4e8d5e 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -276,31 +276,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 04f136b6bed5..e6d946c48e0b 100644 --- a/sys/netinet6/in6_gif.c +++ b/sys/netinet6/in6_gif.c @@ -291,31 +291,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;