From owner-svn-src-head@freebsd.org Fri Sep 18 02:21:16 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54C163F4F00; Fri, 18 Sep 2020 02:21:16 +0000 (UTC) (envelope-from np@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BsyHw1b0Lz3yd5; Fri, 18 Sep 2020 02:21:16 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 19D4114017; Fri, 18 Sep 2020 02:21:16 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08I2LFiK096311; Fri, 18 Sep 2020 02:21:15 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08I2LFop096309; Fri, 18 Sep 2020 02:21:15 GMT (envelope-from np@FreeBSD.org) Message-Id: <202009180221.08I2LFop096309@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Fri, 18 Sep 2020 02:21:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365869 - in head/sys: netinet netinet6 X-SVN-Group: head X-SVN-Commit-Author: np X-SVN-Commit-Paths: in head/sys: netinet netinet6 X-SVN-Commit-Revision: 365869 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2020 02:21:16 -0000 Author: np Date: Fri Sep 18 02:21:15 2020 New Revision: 365869 URL: https://svnweb.freebsd.org/changeset/base/365869 Log: Add a knob to allow zero UDP checksums for UDP/IPv6 traffic on the given UDP port. This will be used by some upcoming changes to if_vxlan(4). RFC 7348 (VXLAN) says that the UDP checksum "SHOULD be transmitted as zero. When a packet is received with a UDP checksum of zero, it MUST be accepted for decapsulation." But the original IPv6 RFCs did not allow zero UDP checksum. RFC 6935 attempts to resolve this. Reviewed by: kib@ Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25873 Modified: head/sys/netinet/udp_var.h head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet/udp_var.h ============================================================================== --- head/sys/netinet/udp_var.h Fri Sep 18 02:10:28 2020 (r365868) +++ head/sys/netinet/udp_var.h Fri Sep 18 02:21:15 2020 (r365869) @@ -154,6 +154,9 @@ VNET_DECLARE(int, udp_log_in_vain); #define V_udp_blackhole VNET(udp_blackhole) #define V_udp_log_in_vain VNET(udp_log_in_vain) +VNET_DECLARE(int, zero_checksum_port); +#define V_zero_checksum_port VNET(zero_checksum_port) + static __inline struct inpcbinfo * udp_get_inpcbinfo(int protocol) { Modified: head/sys/netinet6/udp6_usrreq.c ============================================================================== --- head/sys/netinet6/udp6_usrreq.c Fri Sep 18 02:10:28 2020 (r365868) +++ head/sys/netinet6/udp6_usrreq.c Fri Sep 18 02:21:15 2020 (r365869) @@ -124,6 +124,11 @@ __FBSDID("$FreeBSD$"); #include +VNET_DEFINE(int, zero_checksum_port) = 0; +#define V_zero_checksum_port VNET(zero_checksum_port) +SYSCTL_INT(_net_inet6_udp6, OID_AUTO, rfc6935_port, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(zero_checksum_port), 0, + "Zero UDP checksum allowed for traffic to/from this port."); /* * UDP protocol implementation. * Per RFC 768, August, 1980. @@ -267,7 +272,14 @@ udp6_input(struct mbuf **mp, int *offp, int proto) } if (uh->uh_sum == 0) { UDPSTAT_INC(udps_nosum); - goto badunlocked; + /* + * dport 0 was rejected earlier so this is OK even if + * zero_checksum_port is 0 (which is its default value). + */ + if (ntohs(uh->uh_dport) == V_zero_checksum_port) + goto skip_checksum; + else + goto badunlocked; } } @@ -287,6 +299,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto) goto badunlocked; } +skip_checksum: /* * Construct sockaddr format source address. */