From nobody Wed Nov 01 09:30:35 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 4SL1vc0Df5z505gy; Wed, 1 Nov 2023 09:30:36 +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 4SL1vb5wMHz3RYS; Wed, 1 Nov 2023 09:30:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698831035; 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=v/EsQJjKiWOfv7EWzNgFr/s+LEen8ZBRXDHIMwKZ2Zs=; b=jdAv0KODopFSFLp18iKcvikNLuu0HosGOZAPWuRn+pW/5VcrRebedFD0382w2jwKC3U6+t uam7+IAZPdEVuvvJDbuu6EIAhxsuw/Xk/dssDK+Vsa8NKs9iH79LWdDsuix8fJGNTCSNNc UitlAHggwNBkQsO9GlDfrAn2O/y5o4DMfh71Rdy9DgWmlPOuYDDjdnZfnTIe1IEB/JX1wb qzXtNGKcnutOJwZWsCjcq2lNP98EqciSKtC4agUGzYrnrAvnTRZifdPU5F6WaMVXA0412P jU/W/LfQsUhubggyFoYN+j7C14F13powj4PZyNbSRTFjBWwx77ldHApOV0dDgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698831035; 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=v/EsQJjKiWOfv7EWzNgFr/s+LEen8ZBRXDHIMwKZ2Zs=; b=drHrs49Kpj0nIQjMfdTkAx7k5QRfy4ewfmuwFkv6kHk03BSoF3T583bASfRxZZ6v+JOkBP 37mBJNovc1wdLGE4rBo9Is5tML+7N0swcX5l7lUDFIdHVX/V2bNZPDsrWbRmzoSG172M5Z qSwJpf6PYgeVrBISPV6PLsnFIDwXSGKmDMajkb/DJxQiQm/jlaMZTLdhsP4tNfiPxz4Jvz 21RxVHdYV/B0qqtr5lUmzzUhe3dhHva6bztV6EDXGIwM35ZokFNMtTzxJEr/KJmSic9qxV 8lg7fYWV7rGnWk8SgULwawMeArEt9a4V1SPaC07gSODMkrQRrt2Kg57n2BFclQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698831035; a=rsa-sha256; cv=none; b=CTBiy+FYZ/fS6rmwovsD0FZyGByRwWPCx/6RaJEjU0l5vZhAfqYe4541GMrw0no+x+ohNG 3BSvAAa37EGg+Kx7f2E5BJBTKzKwd0aBah8SF5LvwagEQvoYa765V2eO+9WxfWjMparp3J qjKHZf9dcqB+k0zF2zi7D8cPtSwFAZsjEZPnkVr8heuVxftjIzEpa4wpN/p3cWcvMloLqs BrMJMLAe+4v/GftUnbZb+E92BL8XbrtdSoK6CNKISMgj1QrOedn801wPhOa4eyrtNLxuOs wJwZ8ha+FhEZVmuU22qst2do2LhoULWgWnwfXOuX9quKOX17pF/03UUdd4+4dw== 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 4SL1vb4khczgkq; Wed, 1 Nov 2023 09:30:35 +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 3A19UZXi008309; Wed, 1 Nov 2023 09:30:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A19UZFg008306; Wed, 1 Nov 2023 09:30:35 GMT (envelope-from git) Date: Wed, 1 Nov 2023 09:30:35 GMT Message-Id: <202311010930.3A19UZFg008306@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: aa64a8f5c35c - main - udplite: fix checksum computation on the sender side 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: aa64a8f5c35c13b1c325f1a4597c987a37bec5da Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=aa64a8f5c35c13b1c325f1a4597c987a37bec5da commit aa64a8f5c35c13b1c325f1a4597c987a37bec5da Author: Michael Tuexen AuthorDate: 2023-11-01 09:24:56 +0000 Commit: Michael Tuexen CommitDate: 2023-11-01 09:24:56 +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 --- 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 cbda7f536262..a96ec22c5992 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); /*