From nobody Wed Jun 21 20:52:42 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 4QmbL30t8lz4g335; Wed, 21 Jun 2023 20:52:43 +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 4QmbL30SRSz40hy; Wed, 21 Jun 2023 20:52:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687380763; 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=dXUEYF4gwhrsTeGdVZXi71hcJVLNJEeWyBZOZjci3AA=; b=iXzPu0xrIXbwjrRfJRBoHhbb3hldnxD8if+9yplgmX2cxPX+qghlJoqJClaLiUsjGB8jgu FcXvm0IrODXXX/cmg294NWRpZVwT9w7glMGeUJItp7pUMruPcsjEuE1OCixHamf3PslRWZ hQfj/uJbouY+bnrC4ChrVWQ2UI6n/v+lK98aAnSXqM8WD0SlEJjlirlpCb4qvJfpQE+VBS FpsdEEAKvUXZ1Z3jOdnjEM3yBsW8ABlLzE+t6vVve3KG3/q2rOG3t9Of1qbx317MY6EVDh K9GkBnvK3IGry/pUqFKELuT2JcuQlGemlgGsnbm/x7iiuk4AcnwpCfyoV1MpTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687380763; 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=dXUEYF4gwhrsTeGdVZXi71hcJVLNJEeWyBZOZjci3AA=; b=TQ6gJahXR8/1dDM2O246G4OxtqoxIzUclEiuX3u6DdflbPm9/4/6tUD5K+CMzt99GLdZQz TaraWeF8v1+sXs0ZKlFZBDtJ7Vqh6dgiFp+DMiSNKCyKqpZnvj7ea9P/NTVn7cmY80W1C+ d7iiOQP6LSUU/e5OKtJltrk+4owlySH7YNZzs+s47l+/GiakfSEAOC4wSvS7d9enQCMSWM ILOuYlVE7mFwmZgaeESJXmUGzPSDi5OR94Kp/ormn2d6+6a/ndAg0YwQiUPy3go9V7TKjT 6ZTIG5YVjwoBUWKPhGdcaPz8zhnhvBHdE15DYrs38vaJQc1h1X2ltf3NRLOmBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687380763; a=rsa-sha256; cv=none; b=ADiigNXVyBIHogCrgRaZGxYRAsvuRlRMCQmdkYrGdtMfBIAvJGsGDeIweYte4DNo2RqEgH lOr4iPPx4/vi3S6PVMJK8A6zEUVsHeHDNvBB/s6+rzsyhFCfoz7z5XKAO71xWBG0LoRbcb o+H9QXKEMj8l/YpFnqAOzb9FTyX4akBYNnMPA5aHDy1bJFwWsq+sTcBASkyqcoG0Jo2x/6 KUBdxVmHtJ6cIpnAs3TWkP1eeIg2wHPhICU/LgRxP5Zrp6D46YZDC2lCqoZFYOSuy4z2fh AVC6w3FDfDNnSU5rPorbD5G9GksI2JXK7zmGBKJUzDV33RzzkV7QFqerw0re0g== 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 4QmbL26fyRzwjZ; Wed, 21 Jun 2023 20:52:42 +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 35LKqg5U066379; Wed, 21 Jun 2023 20:52:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35LKqgeF066378; Wed, 21 Jun 2023 20:52:42 GMT (envelope-from git) Date: Wed, 21 Jun 2023 20:52:42 GMT Message-Id: <202306212052.35LKqgeF066378@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 0fb0711dba76 - main - tcp: fix TCP MD5 digest computation for TCP over UDP 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: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0fb0711dba76a32a2202d2f41d64aa1247b5e51d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=0fb0711dba76a32a2202d2f41d64aa1247b5e51d commit 0fb0711dba76a32a2202d2f41d64aa1247b5e51d Author: Michael Tuexen AuthorDate: 2023-06-21 20:48:12 +0000 Commit: Michael Tuexen CommitDate: 2023-06-21 20:48:12 +0000 tcp: fix TCP MD5 digest computation for TCP over UDP Skip the UDP header for the computation. This is similar to skipping IPv6 extension headers. Reviewed by: cc, rscheff MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D40596 --- sys/netipsec/xform_tcp.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sys/netipsec/xform_tcp.c b/sys/netipsec/xform_tcp.c index 42c63813e63c..28e547637450 100644 --- a/sys/netipsec/xform_tcp.c +++ b/sys/netipsec/xform_tcp.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -136,15 +137,20 @@ ip_pseudo_compute(struct mbuf *m, MD5_CTX *ctx) { struct ippseudo ipp; struct ip *ip; + int hdr_len; ip = mtod(m, struct ip *); ipp.ippseudo_src.s_addr = ip->ip_src.s_addr; ipp.ippseudo_dst.s_addr = ip->ip_dst.s_addr; ipp.ippseudo_p = IPPROTO_TCP; ipp.ippseudo_pad = 0; - ipp.ippseudo_len = htons(m->m_pkthdr.len - (ip->ip_hl << 2)); + hdr_len = ip->ip_hl << 2; + if (ip->ip_p == IPPROTO_UDP) + /* TCP over UDP */ + hdr_len += sizeof(struct udphdr); + ipp.ippseudo_len = htons(m->m_pkthdr.len - hdr_len); MD5Update(ctx, (char *)&ipp, sizeof(ipp)); - return (ip->ip_hl << 2); + return (hdr_len); } #endif @@ -158,14 +164,20 @@ ip6_pseudo_compute(struct mbuf *m, MD5_CTX *ctx) uint32_t nxt; } ip6p __aligned(4); struct ip6_hdr *ip6; + int hdr_len; ip6 = mtod(m, struct ip6_hdr *); ip6p.src = ip6->ip6_src; ip6p.dst = ip6->ip6_dst; - ip6p.len = htonl(m->m_pkthdr.len - sizeof(*ip6)); /* XXX: ext headers */ + hdr_len = sizeof(struct ip6_hdr); + if (ip6->ip6_nxt == IPPROTO_UDP) + /* TCP over UDP */ + hdr_len += sizeof(struct udphdr); + /* XXX: ext headers */ + ip6p.len = htonl(m->m_pkthdr.len - hdr_len); ip6p.nxt = htonl(IPPROTO_TCP); MD5Update(ctx, (char *)&ip6p, sizeof(ip6p)); - return (sizeof(*ip6)); + return (hdr_len); } #endif