From nobody Thu Jan 11 01:23:11 2024 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 4T9RkR3K6lz56gLJ; Thu, 11 Jan 2024 01:23:11 +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 4T9RkR2jRSz4SkL; Thu, 11 Jan 2024 01:23:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704936191; 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=TGOuRl9fxyNWKJCX61gld5pg5WzgGw7MRp7alcnMKDI=; b=NPsJgkMW7XYuI+5T1KHoIk5fQY4+0qL2A/kzpXV8ToVzlsFwRsolkQVLTicOo62t0UdlCq 3zyofl3IPNSSrAumzj/T3B4QrQORt/TgV5wBUDhgA0L7HBKVaftK9P/3bVWg8A3PJl8AC5 bHC6TiiXYcgduzFX7TYksoktdIGWr2aGk/2Wsx2TpSsYokQprvBGvYc4JakvX01tNFEGuK W99KTM1v74Dv9Y1QsjdAR5okox3c2CEPrw55i4Do+SnexpxLvvvycz3da0KpnG/sX0wRyb Dr+DnAUPZ0fYRFvk81pgx9Gcdqd6sw9hCLPbBZICGCHKARcLpV4/4uTwIKxdbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704936191; 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=TGOuRl9fxyNWKJCX61gld5pg5WzgGw7MRp7alcnMKDI=; b=XZzK3cKjY7IfnRZtQr1m6xAr1RVk7Ne3zkgy2yjLFaev4e9WUaIZSqsTCzin0ZF52r14/l LqTu8cns8EVoMaL0TtUg5cTP+Y3qUXFZZ+Uhc+6O9SIxPe3zQ2zJh63YnZ9X90G1cFy2CL AKubhOhfYDVEK2u0mk5hm8HnmKDRhPAgldWMga7izRBGt3Ofnz2XNA8sS2uPzjcI4J9au5 MTHnSYPHrKrbwo3qibpOOM58ObGZnZRrE4gqrMJ78Q8wZX1lnqB/kxshT0yhgZbe037dsX HEdp0chMpGWLg9ahIeLTu9UylxX1VcT0Zt3bn0+b9AkhUaxZFXG3vlMXrjb8kg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704936191; a=rsa-sha256; cv=none; b=gE4mG8zpAaxaQcNM1NOIa7vFsNJqF+bQhGeL/94TRLsDhqiz9sXf4WgAdjbbX3tUiBm2Y3 XDhEkR9LYJ1BnX/ZUe+sES1r6hZEtfqp8h9ChSDdAYwVCuoQWSGPhy9wQhhMCct4AV3BWV A8jYtXelXs67zwvicqMujdTnu5yowUrAY2GPVYUKS2kdDHvMxovFB3WzpHacRXmXB8pOZY 7CciZFjqNcfYYuIb3x+A1bCwzk+gI14f4zhcZpboAvioGVhdInZrV+VFdn1dTW2FbYO2mJ a4j1EpZlU06uF+j4dgHoNLcSg3GqO1VDDqDFdHc5iOwIQkkmqSwzGfSr6AaY/A== 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 4T9RkR1lxBzywP; Thu, 11 Jan 2024 01:23:11 +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 40B1NB0x088857; Thu, 11 Jan 2024 01:23:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40B1NBlr088854; Thu, 11 Jan 2024 01:23:11 GMT (envelope-from git) Date: Thu, 11 Jan 2024 01:23:11 GMT Message-Id: <202401110123.40B1NBlr088854@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 3a89a5d54daa - stable/14 - udplite: fix checksum computation on the sender side 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: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3a89a5d54daa4d044b3f2b36c44f72c3333e3284 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=3a89a5d54daa4d044b3f2b36c44f72c3333e3284 commit 3a89a5d54daa4d044b3f2b36c44f72c3333e3284 Author: Michael Tuexen AuthorDate: 2023-11-01 09:24:56 +0000 Commit: Ed Maste CommitDate: 2024-01-11 01:22:52 +0000 udplite: fix checksum computation on the sender side Don't fill the fields of the UDP/IP header not used for the checksum computation before performing the checksum computation. Reviewed by: glebius MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D42275 (cherry picked from commit aa64a8f5c35c13b1c325f1a4597c987a37bec5da) --- sys/netinet/udp_usrreq.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 75dec9d5f5aa..4ea0efad3491 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1330,8 +1330,12 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, * into network format. */ ui = mtod(m, struct udpiphdr *); - bzero(ui->ui_x1, sizeof(ui->ui_x1)); /* XXX still needed? */ - ui->ui_v = IPVERSION << 4; + /* + * Filling only those fields of udpiphdr that participate in the + * checksum calculation. The rest must be zeroed and will be filled + * later. + */ + bzero(ui->ui_x1, sizeof(ui->ui_x1)); ui->ui_pr = pr; ui->ui_src = laddr; ui->ui_dst = faddr; @@ -1356,16 +1360,6 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, cscov_partial = (cscov == 0) ? 0 : 1; } - /* - * Set the Don't Fragment bit in the IP header. - */ - if (inp->inp_flags & INP_DONTFRAG) { - struct ip *ip; - - ip = (struct ip *)&ui->ui_i; - ip->ip_off |= htons(IP_DF); - } - if (inp->inp_socket->so_options & SO_DONTROUTE) ipflags |= IP_ROUTETOIF; if (inp->inp_socket->so_options & SO_BROADCAST) @@ -1399,9 +1393,16 @@ udp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, m->m_pkthdr.csum_flags = CSUM_UDP; m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); } + /* + * After finishing the checksum computation, fill the remaining fields + * of udpiphdr. + */ + ((struct ip *)ui)->ip_v = IPVERSION; + ((struct ip *)ui)->ip_tos = tos; ((struct ip *)ui)->ip_len = htons(sizeof(struct udpiphdr) + len); - ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */ - ((struct ip *)ui)->ip_tos = tos; /* XXX */ + if (inp->inp_flags & INP_DONTFRAG) + ((struct ip *)ui)->ip_off |= htons(IP_DF); + ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; UDPSTAT_INC(udps_opackets); /*