From patchwork Fri Mar 7 03:34:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 14005783 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DC0218DB39 for ; Fri, 7 Mar 2025 03:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741318587; cv=none; b=u7yfqdrefEGu+OHaVeYMwJhBeFKkCUVg//hzmF352HC02cNJF+GiI6+hgyNLkF/AwOaoiWEj8DViisibzngZaelkH8hJxVr7X06muR/mBqzJbVsj5wEZ/kT0Gywvt+81BPRyi4MIb4ViFGmyVI2BXHsdg7UKB/0d3lKmosjPreI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741318587; c=relaxed/simple; bh=7qg14UC8Mt/nmxAUW63KzoL+dnojf835ikvCNq7EM/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=st5vEEsbEiSPx2sLKnzfdCkDwSDF6WTb2hB6ggI6ztPdRSNcJSjbX6yDKY/QjeSJE/hme4I6bVVtWfClRW37hByoRj75CFh3GN47AVCVQPnM06HQF8MWjOBqbWgoO95W3Q7KEpzgtnd8q7spUDx+LEE68bMzc/q3fYcfBZk6RX8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PVss5Ah+; arc=none smtp.client-ip=209.85.219.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PVss5Ah+" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-6e41e17645dso12790466d6.2 for ; Thu, 06 Mar 2025 19:36:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741318584; x=1741923384; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H1T3UEMiMEYHcRj/C9reo0C4GXNX+eNL685itXP04jM=; b=PVss5Ah+8mjNu7payzTkz3DqC0iEEwo9fgFFUxddVvKRlLrBKzEVkfBz8R/EczXqz6 xrmQ4NoSdSzM27Tp1plzufZEdETKowRs0gLLSUzxDwwylmpg/IDZ78hbJpgTQore4AO7 D5FleQdC3R8Upk7V145woMfTWIh7hP6cs0pL2Ig6wLkpGYSFYfGQOl3BXuKXCTV44Z4z NKSQdYH/sKcD0LajbHMMg1gZn5F+ld7OqJF00Q6wzeLgjF/4r2mFkgkU93ihr0gPQhG8 rivYKSQecURI763DbPT72+aFZLaSdrefVpRp4BQKJNxov5OKyItXUtu0/bo2cXKU4Du0 OadQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741318584; x=1741923384; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H1T3UEMiMEYHcRj/C9reo0C4GXNX+eNL685itXP04jM=; b=lQSUi0T/pInCIB9nx6vsWAoywvYkrxu7Ur/tAcHMJyT4Rocso1nPaoDBLAaXv/r+QH AKSasL/TePZXYYdUnL37eIdEMZyUSAZDjOKyBaZcONR6SLLY/YKezs7AYKbqoUH3seXU 0gV9kokryj4yKrJX8tOCijMp0VNNhLd4fh8qKjcP0oZnVPa4MX1s8OK+yUP5sHzwBNf5 a+ZGS7m90EKPuPkHHb0ssaQ2Qat7UdYLxfyQs9WQIsoKF22U3YtK4tVNpwJpll3OKRrU KmuOF7JCcCsiRue7k5GPOpIOHBHxE6lxjFOv1C37uD4LDhGdjMz6uEDg/VHO+6l1FWVs czSQ== X-Gm-Message-State: AOJu0YxSTY7ZEnBw4o4ORAy0/8vfJjTblUPswe+v+P6Upxur0LWV06aR d7jmQV+By5azXVv68UpLTK0cv6oV7rFxBX+fp7CqbGwW5bZn89KT+/5izg== X-Gm-Gg: ASbGnct5jTxabjmC3rFMF/G8mPsqTl8a2/7lCL0KBbCnA77X7JFftNWS4EQV+sDvTp0 KP9xqdD/T/AekB872XvZhzmriQ99V5zAcF/C73BTVe0CtZQxc+1+NY5EhszLpoTUJJT0sF9P7yO lwi0jUcqGV8sJ8uDbgOeYRECMOgJmVot172yQ2DgnHRCmIqbFcipoGjpwkP1DtI19fU2V/i5HqO PNqy2inzh+eCizQaqjXcI5TryXg5PoLELzxSoRwJQ1JILjPPsY4dJ3M/fjj18W328v9pCfXHuGt b+9DA6O+iu4qgj17SOeUd19NKSgwme0JkYbgmKSRUEANkQi6eDCxTL5kLOhYulsDnxHO3rRo1VR d4q/Kr2CEg14iZTMk9kCAWc0Aru2Mwwz8dXAOWI+WVCp0 X-Google-Smtp-Source: AGHT+IEAUeg1M1tyyKWtl7+YckDBhxJTt3ugiwKuXnWqieYOhZDn787vmjHRN3EdHo4aHJon84Ld0Q== X-Received: by 2002:a05:6214:202b:b0:6e8:fee2:aadb with SMTP id 6a1803df08f44-6e900642dacmr26048976d6.27.1741318584524; Thu, 06 Mar 2025 19:36:24 -0800 (PST) Received: from willemb.c.googlers.com.com (234.207.85.34.bc.googleusercontent.com. [34.85.207.234]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e8f71727d1sm14528946d6.117.2025.03.06.19.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Mar 2025 19:36:23 -0800 (PST) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, horms@kernel.org, Willem de Bruijn Subject: [PATCH net-next 1/3] ipv6: remove leftover ip6 cookie initializer Date: Thu, 6 Mar 2025 22:34:08 -0500 Message-ID: <20250307033620.411611-2-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog In-Reply-To: <20250307033620.411611-1-willemdebruijn.kernel@gmail.com> References: <20250307033620.411611-1-willemdebruijn.kernel@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Willem de Bruijn As of the blamed commit ipc6.dontfrag is always initialized at the start of udpv6_sendmsg, by ipcm6_init_sk, to either 0 or 1. Later checks against -1 are no longer needed and the branches are now dead code. The blamed commit had removed those branches. But I had overlooked this one case. UDP has both a lockless fast path and a slower path for corked requests. This branch remained in the fast path. Fixes: 096208592b09 ("ipv6: replace ipcm6_init calls with ipcm6_init_sk") Signed-off-by: Willem de Bruijn Reviewed-by: Eric Dumazet --- net/ipv6/ip6_output.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index d577bf2f3053..d91da522c34e 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -2054,8 +2054,6 @@ struct sk_buff *ip6_make_skb(struct sock *sk, ip6_cork_release(cork, &v6_cork); return ERR_PTR(err); } - if (ipc6->dontfrag < 0) - ipc6->dontfrag = inet6_test_bit(DONTFRAG, sk); err = __ip6_append_data(sk, &queue, cork, &v6_cork, ¤t->task_frag, getfrag, from, From patchwork Fri Mar 7 03:34:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 14005784 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB804192B81 for ; Fri, 7 Mar 2025 03:36:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741318588; cv=none; b=LnauWIGSlcD57G7K3jwClWb3jhFAX7chxT/AWPlECC34e+PniKMdTaCkuFA/MgcbI1rZKjIq85V7vhdpdhJVatO+zEK8V6eUl8k3SXcCoGqBrY4T650gHC06WtFf8K7mRUtxSfJhr9FVyVD24wnn8QP2mD+KjNuJOWv1spO3AUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741318588; c=relaxed/simple; bh=4cr705Fz7tE6fPfVacy0geRhdmKGhlODOAipS07vVCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d6x7Qeq+Cif3F7coVHgLofPHkJPkExOLsGz2xe4cGPCZNmNZB+N5LM+FCtsDgqucCbPlClQrptHb+iTxbBTz1xWO/CFQrrFrn9NrbS1z3WLV/E2e6eP92IhuWDcl6r1sktZHVApc83iGAoF92vZ8UF6u8wq77dF839scX/TQ6TM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gSYzYKNi; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gSYzYKNi" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-4750bc8d102so13762281cf.1 for ; Thu, 06 Mar 2025 19:36:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741318585; x=1741923385; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SaP1lDZYkL3tJ7ndT8o1iYCUjUlsXXOPt5hOoDFAnnI=; b=gSYzYKNiSRZwfHhLK2b28GH08Kh3Aycu9VumKzTOa2dJdHYU/JGA1FE6UkuKAxZmGL unQM26J9id4lHUEk+IFJ7dzDvBgFsmL61hMpE8MFXYuDfNi3+bzFG3126VgHIqzJvCrc U62u8lfrbj2hLBKF74h0xuTtjONuDTWFt7IVdvRoWEmMKOGMCQugTnnnHLyR5rdy0ldo JfNjBtCocAZNkkLdq0+HPq2u4zo19IqZLUV9RRqC5UuG6avxZr1FKpgcgoabPAnWhCy6 8dVAsQ1ZHzACrIggJbIZp7hbujnXWMF/QO9kZ8I5sApYfA+5eB1aPORZdK6L4DPfFkWP /Feg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741318585; x=1741923385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SaP1lDZYkL3tJ7ndT8o1iYCUjUlsXXOPt5hOoDFAnnI=; b=Q+VQM0Rpxyg0I2HC8Zrn9Kt5+zU89TxNB3bJn8rBV6ZMlSyX64ZEEZnMgclv7r8K1+ 4VntjtaYWmpQD3sJqKzArhr7A05B9I0+7Uhf4rL/D6CicaJP5y8it+5wILud4rdact5/ MHrIWHYrN+AfyBRCa2gnfJ9gvPngSCWxa/RV136fukIN0qJMzbXaYxhCNJWxPx9NpIsA aJiq8O7QMBT6ADAhSBnJWG7xtefOfl4K9150zlcz4n/DC0d/kW9aoKrBtr7joqJia4Gj pnR9xPnSiUGotiAEQH9lAxM2JiE5mDiCUuDfjZaYS5hkRuc+y7Kl/E35LHUtNxCrr00F 8lIA== X-Gm-Message-State: AOJu0YxhstReOPu256yTngWQCHFdQ6pum+GDbv0wLBZs3KEN7Pctwiy4 t5K5C0SRBLW0DXZGD7uzJ/FRXkC+cEgLiMIx9zoTGvKALEMr/GBtLrDqvQ== X-Gm-Gg: ASbGncuxDU8sX0IG34kTT7SwxiH64IUJMpUu2GT8DvxVLyaIVLQERgbC3rO+QBQLj+f oaXnvpfxg/Ri+sT031tqx8SDLZ5u2W4aHHAd6pedby6xYKjzFra1Wp3CuagUunyNfbQQnWcXVRQ SWLY9zlpS3rAw6KGi7iapCv5nyNnn7xYa78HftXV8OX3A6zfcCZW4LvmZuI5vGTPFP5W5oLkHwO aLHMjDa84mJ02hmZ3/G8PSXbRicX2zpFKcUNzZtLBLk+D3VqS4H5BG36AGylT9EAqqWcB/abP+9 XOkP4O/LO5L549rxo6DShnB5i5D4nWaw17p7kpGvT+3xvegqhtyHwPNp4l6nP9h9BiJdsIflf0+ BiO1vePeXmlnvsqlN9Hiy5RhHKwcuyVU6xwSyrdMvTG6Y X-Google-Smtp-Source: AGHT+IEWJoy42BTscloNA4+3qorLdbglh3CoQMmFHiF4id97ekDFXeo2KRYYWZ4kqV/aqlksHXsKVQ== X-Received: by 2002:ad4:5f46:0:b0:6e8:fb7e:d33b with SMTP id 6a1803df08f44-6e900677496mr22037746d6.33.1741318585492; Thu, 06 Mar 2025 19:36:25 -0800 (PST) Received: from willemb.c.googlers.com.com (234.207.85.34.bc.googleusercontent.com. [34.85.207.234]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e8f71727d1sm14528946d6.117.2025.03.06.19.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Mar 2025 19:36:24 -0800 (PST) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, horms@kernel.org, Willem de Bruijn Subject: [PATCH net-next 2/3] ipv6: save dontfrag in cork Date: Thu, 6 Mar 2025 22:34:09 -0500 Message-ID: <20250307033620.411611-3-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog In-Reply-To: <20250307033620.411611-1-willemdebruijn.kernel@gmail.com> References: <20250307033620.411611-1-willemdebruijn.kernel@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Willem de Bruijn When spanning datagram construction over multiple send calls using MSG_MORE, per datagram settings are configured on the first send. That is when ip(6)_setup_cork stores these settings for subsequent use in __ip(6)_append_data and others. The only flag that escaped this was dontfrag. As a result, a datagram could be constructed with df=0 on the first sendmsg, but df=1 on a next. Which is what cmsg_ip.sh does in an upcoming MSG_MORE test in the "diff" scenario. Changing datagram conditions in the middle of constructing an skb makes this already complex code path even more convoluted. It is here unintentional. Bring this flag in line with expected sockopt/cmsg behavior. And stop passing ipc6 to __ip6_append_data, to avoid such issues in the future. This is already the case for __ip_append_data. inet6_cork had a 6 byte hole, so the 1B flag has no impact. Signed-off-by: Willem de Bruijn Reviewed-by: Eric Dumazet --- include/linux/ipv6.h | 1 + net/ipv6/ip6_output.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index a6e2aadbb91b..5aeeed22f35b 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -207,6 +207,7 @@ struct inet6_cork { struct ipv6_txoptions *opt; u8 hop_limit; u8 tclass; + u8 dontfrag:1; }; /* struct ipv6_pinfo - ipv6 private area */ diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index d91da522c34e..581bc6289081 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1386,6 +1386,7 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork, } v6_cork->hop_limit = ipc6->hlimit; v6_cork->tclass = ipc6->tclass; + v6_cork->dontfrag = ipc6->dontfrag; if (rt->dst.flags & DST_XFRM_TUNNEL) mtu = READ_ONCE(np->pmtudisc) >= IPV6_PMTUDISC_PROBE ? READ_ONCE(rt->dst.dev->mtu) : dst_mtu(&rt->dst); @@ -1421,7 +1422,7 @@ static int __ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), void *from, size_t length, int transhdrlen, - unsigned int flags, struct ipcm6_cookie *ipc6) + unsigned int flags) { struct sk_buff *skb, *skb_prev = NULL; struct inet_cork *cork = &cork_full->base; @@ -1475,7 +1476,7 @@ static int __ip6_append_data(struct sock *sk, if (headersize + transhdrlen > mtu) goto emsgsize; - if (cork->length + length > mtu - headersize && ipc6->dontfrag && + if (cork->length + length > mtu - headersize && v6_cork->dontfrag && (sk->sk_protocol == IPPROTO_UDP || sk->sk_protocol == IPPROTO_ICMPV6 || sk->sk_protocol == IPPROTO_RAW)) { @@ -1855,7 +1856,7 @@ int ip6_append_data(struct sock *sk, return __ip6_append_data(sk, &sk->sk_write_queue, &inet->cork, &np->cork, sk_page_frag(sk), getfrag, - from, length, transhdrlen, flags, ipc6); + from, length, transhdrlen, flags); } EXPORT_SYMBOL_GPL(ip6_append_data); @@ -2058,7 +2059,7 @@ struct sk_buff *ip6_make_skb(struct sock *sk, err = __ip6_append_data(sk, &queue, cork, &v6_cork, ¤t->task_frag, getfrag, from, length + exthdrlen, transhdrlen + exthdrlen, - flags, ipc6); + flags); if (err) { __ip6_flush_pending_frames(sk, &queue, cork, &v6_cork); return ERR_PTR(err); From patchwork Fri Mar 7 03:34:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 14005785 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7F9A194A66 for ; Fri, 7 Mar 2025 03:36:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741318589; cv=none; b=VHBlFDoAQk9Xz6Lw8ekR2g9PAMWxfZR4uhlcKEjaMcLAqnrj3Nqu7N5+aqi632yT+VJvyQwzEP3lcdyov1GrcsCeKRaTlCWMiRP1bPtENe/UJg0esm3hZIcnlfzyvQxBXy2QLgRpB0kF+y6tNGRcGFWetkvs3/x8O09QqNZBfKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741318589; c=relaxed/simple; bh=WbK6+6SUrxvSfG7PKZyJJbtLua8PwtOGKuwMIHIvRX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G0sqGwuZ8IzDC2ZA364Hg2EoiCvLtgLfJ+ZooXOfTUSsvYwTVAVOi1YiDUPJKW9yd4YhI6xNDo+SGo2Sq7J/VCyyI8bbfgPB/Yv0RKBwDLb/jLTof/5ubhmUh/nAPEw9Xq/S8F7G6mDGeroX4QimAKvH3Qoxyt+hp77fgycuWdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=W7+0oWVs; arc=none smtp.client-ip=209.85.219.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W7+0oWVs" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6e8fb83e137so8118586d6.0 for ; Thu, 06 Mar 2025 19:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741318586; x=1741923386; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1hvOlbfnK+oYf7GNQWvVi9A0q+hidiiMQXBwWziDpvo=; b=W7+0oWVso0tA8bJr30OtEXQ67zOLG+yms8bvZgpXEveIv3l9qwRN9GQrhxpxREigI2 DqigafVCKhem14gRNgBw0Omn1edwwtlwdeETfQiSoJv5eSfRItKm2Q9TYXGd3p9G/MQe hL7P+9G4hed1LRkVLN4oZPxANXNeOcB5HP/hTOsQ1/PW9q5nl2tZEGQK0K27ZY6ksSkb 3vDp2LnfxrsraDrztUSH1iqayxTrI6Pd3nLG9P0CaKQ8IlsnoQlP5CDSaCgoBrESAdgW YV3Z5JdDt2A02KCluyBo7pqv+G/gZiedUY7NRtyEPQN9NeRb52soPPBXeR5RC1/O7RXy DGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741318586; x=1741923386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1hvOlbfnK+oYf7GNQWvVi9A0q+hidiiMQXBwWziDpvo=; b=ao1WU0XS6GP0dShovPgACjx4i5HR0518mh6ktrq0CBIS9z1osn8ZVmxGN4QPd8fNfF LudJA4MFJ8Bba4vaPeWfa/txmnmq8yHmKNmTUHk/Xa/WLYj9ekj8w19eQ6JBAFMhtdns 1Dh6D4SdhA0NP9B3U1un96oqjbG6nwXU0aeN+JV4xKaCzTvFqLRFFaGFKXuWpI8ANLyQ 271dTmXhzodbQ8Acy1KjgbZoUSPdNXVlSjlhi0zKJUw1ePXzXojxQqkplho7Aw1BnaI6 yUSV5YtJ/s4pyVxDxUbOE6EikUN0GeBzPlBc4Zt5ka4wm/3a7ZzZ4ejbZ4Nrk2HJjER/ Fohg== X-Gm-Message-State: AOJu0YwiqSqHhvoRkEvTLF6AWdRZd1WcilW1rxIN8FFA+Z3umiU2Fwnc SXpQykJSZWsqF/lxyB2t/10b4w9OG4Ia9bxiSbZcKeAXu3ZCEXSPKlMotg== X-Gm-Gg: ASbGncspW8pUItA9OwvD8q191PuhrYqNpISYJlqOd2WTFoBFU5e/W6OE5HpVvYYvPIV DA7Ok/0SiNkj5xC6HfOWrpYfUWOT7J1Rx4X9pdPwNWAbEqWvI2ugfQWiU6+FWMz0iTUnLt9carc wV3ssbel5dS1XdiyKjzqaNjlr0J9BUPlQo55d+Ywyfq2Ijbb0hxKqE8sfbAXkBcEw6eNomr5vJG zzn18DMvndbQKEaVY/dSAQSVx6c0/ynKkBZIutYbInLgv/eqcTLUImAhisp2nHSedwpY9siKmtF /tCw3vSxc6FS3yquhISJDEvVQXxJTEQwvmYUJ3R0mWTrN8iJPkBoQx6u5N9aixzVbtuUxb8lPXf lZOxSyETSNfW88ZQMP4S+7CPKsvHNLqjI75KNfryH3uhN X-Google-Smtp-Source: AGHT+IEGlMyW+haW3YwOYBwPO7AzSRDSy17gBj1hlDoZwVYlg4+O1PCPcg67BwFj3dJVTZ6PmlV4rQ== X-Received: by 2002:a05:6214:2622:b0:6e6:6506:af59 with SMTP id 6a1803df08f44-6e9005ea3cemr23438696d6.15.1741318586410; Thu, 06 Mar 2025 19:36:26 -0800 (PST) Received: from willemb.c.googlers.com.com (234.207.85.34.bc.googleusercontent.com. [34.85.207.234]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e8f71727d1sm14528946d6.117.2025.03.06.19.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Mar 2025 19:36:25 -0800 (PST) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, horms@kernel.org, Willem de Bruijn Subject: [PATCH net-next 3/3] selftests/net: expand cmsg_ip with MSG_MORE Date: Thu, 6 Mar 2025 22:34:10 -0500 Message-ID: <20250307033620.411611-4-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog In-Reply-To: <20250307033620.411611-1-willemdebruijn.kernel@gmail.com> References: <20250307033620.411611-1-willemdebruijn.kernel@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Willem de Bruijn UDP send with MSG_MORE takes a slightly different path than the lockless fast path. For completeness, add coverage to this case too. Pass MSG_MORE on the initial sendmsg, then follow up with a zero byte write to unplug the cork. Unrelated: also add two missing endlines in usage(). Signed-off-by: Willem de Bruijn Reviewed-by: Eric Dumazet --- tools/testing/selftests/net/cmsg_ip.sh | 11 +++++++---- tools/testing/selftests/net/cmsg_sender.c | 24 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/cmsg_ip.sh b/tools/testing/selftests/net/cmsg_ip.sh index 2a52520aca32..b55680e081ad 100755 --- a/tools/testing/selftests/net/cmsg_ip.sh +++ b/tools/testing/selftests/net/cmsg_ip.sh @@ -50,8 +50,9 @@ check_result() { # IPV6_DONTFRAG for ovr in setsock cmsg both diff; do for df in 0 1; do - for p in u i r; do + for p in u U i r; do [ $p == "u" ] && prot=UDP + [ $p == "U" ] && prot=UDP [ $p == "i" ] && prot=ICMP [ $p == "r" ] && prot=RAW @@ -81,8 +82,9 @@ test_dscp() { ip $IPVER -netns $NS route add table 300 prohibit any for ovr in setsock cmsg both diff; do - for p in u i r; do + for p in u U i r; do [ $p == "u" ] && prot=UDP + [ $p == "U" ] && prot=UDP [ $p == "i" ] && prot=ICMP [ $p == "r" ] && prot=RAW @@ -134,8 +136,9 @@ test_ttl_hoplimit() { local -r LIM=4 for ovr in setsock cmsg both diff; do - for p in u i r; do + for p in u U i r; do [ $p == "u" ] && prot=UDP + [ $p == "U" ] && prot=UDP [ $p == "i" ] && prot=ICMP [ $p == "r" ] && prot=RAW @@ -166,7 +169,7 @@ test_ttl_hoplimit -4 $TGT4 ttl test_ttl_hoplimit -6 $TGT6 hlim # IPV6 exthdr -for p in u i r; do +for p in u U i r; do # Very basic "does it crash" test for h in h d r; do $NSEXE ./cmsg_sender -p $p -6 -H $h $TGT6 1234 diff --git a/tools/testing/selftests/net/cmsg_sender.c b/tools/testing/selftests/net/cmsg_sender.c index 19bd8499031b..a825e628aee7 100644 --- a/tools/testing/selftests/net/cmsg_sender.c +++ b/tools/testing/selftests/net/cmsg_sender.c @@ -33,6 +33,7 @@ enum { ERN_RECVERR, ERN_CMSG_RD, ERN_CMSG_RCV, + ERN_SEND_MORE, }; struct option_cmsg_u32 { @@ -46,6 +47,7 @@ struct options { const char *service; unsigned int size; unsigned int num_pkt; + bool msg_more; struct { unsigned int mark; unsigned int dontfrag; @@ -94,7 +96,8 @@ static void __attribute__((noreturn)) cs_usage(const char *bin) "\t\t-S send() size\n" "\t\t-4/-6 Force IPv4 / IPv6 only\n" "\t\t-p prot Socket protocol\n" - "\t\t (u = UDP (default); i = ICMP; r = RAW)\n" + "\t\t (u = UDP (default); i = ICMP; r = RAW;\n" + "\t\t U = UDP with MSG_MORE)\n" "\n" "\t\t-m val Set SO_MARK with given value\n" "\t\t-M val Set SO_MARK via setsockopt\n" @@ -109,8 +112,8 @@ static void __attribute__((noreturn)) cs_usage(const char *bin) "\t\t-l val Set TTL/HOPLIMIT via cmsg\n" "\t\t-L val Set TTL/HOPLIMIT via setsockopt\n" "\t\t-H type Add an IPv6 header option\n" - "\t\t (h = HOP; d = DST; r = RTDST)" - ""); + "\t\t (h = HOP; d = DST; r = RTDST)\n" + "\n"); exit(ERN_HELP); } @@ -133,8 +136,11 @@ static void cs_parse_args(int argc, char *argv[]) opt.sock.family = AF_INET6; break; case 'p': - if (*optarg == 'u' || *optarg == 'U') { + if (*optarg == 'u') { opt.sock.proto = IPPROTO_UDP; + } else if (*optarg == 'U') { + opt.sock.proto = IPPROTO_UDP; + opt.msg_more = true; } else if (*optarg == 'i' || *optarg == 'I') { opt.sock.proto = IPPROTO_ICMP; } else if (*optarg == 'r') { @@ -531,7 +537,7 @@ int main(int argc, char *argv[]) cs_write_cmsg(fd, &msg, cbuf, sizeof(cbuf)); for (i = 0; i < opt.num_pkt; i++) { - err = sendmsg(fd, &msg, 0); + err = sendmsg(fd, &msg, opt.msg_more ? MSG_MORE : 0); if (err < 0) { if (!opt.silent_send) fprintf(stderr, "send failed: %s\n", strerror(errno)); @@ -542,6 +548,14 @@ int main(int argc, char *argv[]) err = ERN_SEND_SHORT; goto err_out; } + if (opt.msg_more) { + err = write(fd, NULL, 0); + if (err < 0) { + fprintf(stderr, "send more: %s\n", strerror(errno)); + err = ERN_SEND_MORE; + goto err_out; + } + } } err = ERN_SUCCESS;