From nobody Fri Jan 12 17:22:44 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 4TBSz90lJWz57ChT; Fri, 12 Jan 2024 17:22:45 +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 4TBSz90GYqz4dcb; Fri, 12 Jan 2024 17:22:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705080165; 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=VSSF+EeR+PO9W9bNCxSGKV64HVk/f0R2UrirBcTAFJI=; b=nXK9CdSQ8TnY2dt1MS4Q71iAdtDu4zoC+KYR1aBIdYzfO8qCXeCDa6OuJlA/FLBxV6TAKd nVdMPHiQYguOdaFfA1KO5ZlQCK59DcYrJtGNwwndK20FX1q/DuoUotedm7Ou+R1VsEFHcV Pj1XzGWVHNJwPMrXsluwxGiQkIlv3Ss0vkY1DM4Y0oo7Po4fWO6yI63E1VATblEojlCZhh SvQTnl2o/k5T0pvNqsh9kgPMLYj7w86MoHLek9Y5D7pB4VijiKh6YS3a/Uju2IpvnGr6qg 6yyzRDVUCD09BGiHNdtBrmKzvk9dtBcTi2X3Ey7RC4U/XqjBkXud48+/mMOGxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705080165; 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=VSSF+EeR+PO9W9bNCxSGKV64HVk/f0R2UrirBcTAFJI=; b=Gv9vc561Wb9Ys0c3e4spgGxvBWyx6vHDM4WrG4LZFKS1qq1ROLtQ7b6cfO0Dm+GbHQn2Ji R8ub+t80rgwBhMHKpVI41861PuqA7YmLWZSYZS2yrC/bsR5ThqZntnTQ1ey+ifM8QAIwqT L8kZotuNa3GLMfFU9AQFS2QbBcbtQoJWJA+LrY1U7tpClWn6tCUMZFkBxg8FbSOa2AKrkP cB0WU7z22ZyDg7BEZkJOjZ9pmuizkNFRO8eM77JeDCJaYoVochoGI7jOqdZ8BoG35KfGsc txYIkF3pYX3w05a4fsjpYByP0LhoISdcD78IrOSRZFIkRYx0NA5OCM/ui9xYdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705080165; a=rsa-sha256; cv=none; b=ETBC7g4RQsygcgqYMXlL0M8mphFuOnZIe8dC1Bix1EC2O26dlJ4vShaPo22H4nXlrR5xQQ bR5sx6CErnQ1AYw9LTwypwCmzAdLuNIzRiX3nwN5TLJ0NW9InSpTpSgGMrfLd0MjRGfvRR xJqUdXn5PiZHTJWzJLJ5TEYuoeliF1bZzUtxTX76SqXdxQCchvXA47vmaFBL4YOwUy6SEU rpzKUb5kbx1KUP/paVgxc8PGpnGpqCRSgkVpfxTu/3z4bUH1an//IIICUoWuoLmHIPxzbA jRymlgX17CX1M3s6J3XofPKxnTlMp5MbTJ6ny+BDPonYEhq8wb1gEFS+WeVz3g== 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 4TBSz86R7Xz19dm; Fri, 12 Jan 2024 17:22:44 +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 40CHMiNG048930; Fri, 12 Jan 2024 17:22:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CHMiNo048927; Fri, 12 Jan 2024 17:22:44 GMT (envelope-from git) Date: Fri, 12 Jan 2024 17:22:44 GMT Message-Id: <202401121722.40CHMiNo048927@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: 15eda0e9027d - stable/13 - 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: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 15eda0e9027d39d4e38e23a31752b1e02e2d2d6c Auto-Submitted: auto-generated The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=15eda0e9027d39d4e38e23a31752b1e02e2d2d6c commit 15eda0e9027d39d4e38e23a31752b1e02e2d2d6c Author: Michael Tuexen AuthorDate: 2023-11-01 09:24:56 +0000 Commit: Michael Tuexen CommitDate: 2024-01-12 17:22:20 +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 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 a476b0d8251a..ea9ff161e429 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1408,8 +1408,12 @@ udp_output(struct inpcb *inp, 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; @@ -1434,16 +1438,6 @@ udp_output(struct inpcb *inp, 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) @@ -1477,9 +1471,16 @@ udp_output(struct inpcb *inp, 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); /*