Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp127425lqt; Thu, 18 Apr 2024 10:09:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4n37kqv4TeYggx9iTiBsYT9qT6P63fNn7RMPyAUnXex0b1j68zH11ATBV04VjygUlM9dQiXN8A8rSxojR82SO/C/d9kvrhvQXlLwIug== X-Google-Smtp-Source: AGHT+IHuz2lF/60fz44dd5gvxgeISVrbIkEvrM6ULQckKmHxOHTh+vsSUO9+rguezlsCbTZlqdjH X-Received: by 2002:a05:6871:80d:b0:22e:d092:28e with SMTP id q13-20020a056871080d00b0022ed092028emr4381054oap.33.1713460140535; Thu, 18 Apr 2024 10:09:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713460140; cv=pass; d=google.com; s=arc-20160816; b=NC036U3F1DrpZW3J/MyIBzEiQRniizZnulItwQfjwAs4KTBnLjWgQvaGbViGd0Fry8 ReUh3wSBAJKzkVquwNfmGEOFzJTBTS1zmupl9GYug0070VKuOiKZ0Ln+MmRtq/RPMMSu RZNt241tiJSRPwY36JQstS32k+ux1SCilmYWwlIYRTnuFKoy3VOeUv2N6Th4dcHZ4g2D c5LRkQnWPNDUrE7emudBiabWSJRQojPPsbxzjX1KV+hQRVj6qykXOdkGbXZWaMa+uu2G AHSZdjvz30ChHNwRqiTx6lkraA+ELnK+xxsw190n0hTzSAw4PiaUvtD2mZ+ldguLei7C 0SgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XW7920DVCiComrNM1OgXootScUMXHBonTRbYMTBe4yg=; fh=KsN2gJD+g4U06IMEA7WWo0idU4QgJsLCYNM4o8a+mw8=; b=KZfY2so82mZWv9NmavYnW9zMcgJ+SsBWDxIc+B+FDKyUsANrBHRNTuJ34Lz/K4YgBH l0UW0G3R2R9rigI5Th0mQ5zj4aF2RRTbdqnAmMvVM5q54SxHHel6gHWNnlYTJ2fkOOP1 whfBLIo7H0mfGtja3NvLBBoZVT03h+S8CVo6oNqo/wKR+XpfDCuA4X2oNzSCrGTzpsGa q7fO/wtJy4gn1Xuq78XqICgssiv1RI+jQU7Yt+5TQqIe3YSP+2QlcIAg67zlc+XXw/rw wP6Gaz6uauaRyek3XpmbP4S0Y0qZd1XFCFNcMD5++8OP1r1uscyXXW6QQVtJAxraWmKv R1ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YgKZmvCL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-150543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l27-20020a635b5b000000b005f0bc72594esi1768023pgm.468.2024.04.18.10.09.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 10:09:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YgKZmvCL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-150543-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150543-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DB2192834B3 for ; Thu, 18 Apr 2024 17:08:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7542172BCA; Thu, 18 Apr 2024 17:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YgKZmvCL" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 B2CD7171E77; Thu, 18 Apr 2024 17:08:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713460091; cv=none; b=tyE+BxEckIaW2Oz9qEHmTCwRefdDmzGoTFgOzcv19tsTwYahBAZe6o/Ttv8aNhoYjpqHnvGkrnaKCCiAkOR4Vjz+PJpRXdQi3CpGn6Rm+ZMHo+p0Dv+lyAX1uNc/Ojgf7dRpH6CD7taE2nNhqt1QSdzea2lJnzy1ZRa6EJohttg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713460091; c=relaxed/simple; bh=eCtKOdVAQNp2A4st0BhHo8jBLBWUqc2tUDSRWCS566Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YrB7EU8ymJ2ZVG31vjTHtMBiQPpHasP9BrJ+/GA5G0ajMwkJOKIa044Q2nXcIe5wCSlnpa0Uf2gP9TxqYZnb/yFVL5BtsmPsoBSxA5WLU/+jYicmeXXmt2F3gSfgv1XMyWnho5tW/VLtPlle5tf3SclRrDNzch49hFGMpBVob/E= 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=YgKZmvCL; arc=none smtp.client-ip=209.85.214.182 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 Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1e857e571f3so9499015ad.0; Thu, 18 Apr 2024 10:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713460089; x=1714064889; 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=XW7920DVCiComrNM1OgXootScUMXHBonTRbYMTBe4yg=; b=YgKZmvCLUpCYzVoJMGPf0sL2Y+S9VAvIK/O4yRWZN1BfRcbh+L6pf5Fd+iNzJN+BPC B2MOYPNnIzkOxVE8O6BQVR8qPVgr7FUV0t/29D4jtsTTLuw6jeEPWFU7Ey1jyFDYQ2pP wu/t3T8iQmsMXOcss1cjOWSvXMaGiWlnpycaIZsXYX5mNRTpBe2Hk+B5K9xs8qdchnrg 7gOWJFzlvUynSwOofYfRs1P7q2/aGZGslxm1q5ekPdhDjJ+w5qqEdOjQbC+3ajw5Ydcu zwf/pz1N1lqgXtQ1DeqG4S0Fi6TM88QC16dlOJO6IqREk5kRqU2k8YDrH9BofLAliLBc C+bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713460089; x=1714064889; 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=XW7920DVCiComrNM1OgXootScUMXHBonTRbYMTBe4yg=; b=D38BfC+U5+avOHGuzTyBNtWqtPl2HoPRJyhig5HpaR41165wop1DeNgUCMJFgL2QgZ wSitPL/vkWkDcGPsEdR6MRsd1GWej6P3/4WN58wQi/89GgaRWL63rBnZyepxgF5PQIOD bFr2TUj2iSHj+7nynrmCq4M6kKaIy980vu+NT5PbGyqmZIY1FJbSCsfJo/ti9HAN3Tbp ujys4DFY0atmhnYiHZ1sT65LHoqYItetleH86fFVtflKyU6cT5WeTHTof7sxZAzYy/HG LqSwDeFYrjPvX0w8jo2T917buM/PCztBv+WJACuktxUxKz4WxqEWJpHCe7tovEvKoA1Y crWg== X-Forwarded-Encrypted: i=1; AJvYcCVu88L9ff9nVZSI01FNuyJvNyCdl0rQfMwukD/DGiLAMLDzypuPmT3co9kRbb+Jb2v6ZoCwdKI6vZtn/mw2UgdBjrHJpdzvzlXvTtj3/u5CdXzwfL33sb7V3JelxoaLeJtaqK64 X-Gm-Message-State: AOJu0YwLr4GfeNzT+EPIVKIPZ0jcPkzfYj2boTF5p5xGQAt4FZB57q1C ajHZw8imEOJjOnKQWKAZcZPiYg3GEylK8OY29G4tVECra6+2phP7 X-Received: by 2002:a17:902:cecc:b0:1e2:9c3b:df8d with SMTP id d12-20020a170902cecc00b001e29c3bdf8dmr4846362plg.20.1713460088935; Thu, 18 Apr 2024 10:08:08 -0700 (PDT) Received: from localhost.localdomain ([67.198.131.126]) by smtp.gmail.com with ESMTPSA id m10-20020a170902f20a00b001e8a90b8ac7sm616677plc.303.2024.04.18.10.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 10:08:08 -0700 (PDT) From: Yick Xie To: willemdebruijn.kernel@gmail.com, willemb@google.com Cc: netdev@vger.kernel.org, davem@davemloft.net, dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net v3] udp: preserve the connected status if only UDP cmsg Date: Fri, 19 Apr 2024 01:06:10 +0800 Message-Id: <20240418170610.867084-1-yick.xie@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <6621259d66d0f_ec9b929478@willemb.c.googlers.com.notmuch> References: <6621259d66d0f_ec9b929478@willemb.c.googlers.com.notmuch> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit If "udp_cmsg_send()" returned 0 (i.e. only UDP cmsg), "connected" should not be set to 0. Otherwise it stops the connected socket from using the cached route. Fixes: 2e8de8576343 ("udp: add gso segment cmsg") Signed-off-by: Yick Xie Cc: stable@vger.kernel.org --- v3: Fix the IPV6 counterpart and revise the subject v2: Add Fixes tag v1: https://lore.kernel.org/netdev/20240414195213.106209-1-yick.xie@gmail.com/ --- net/ipv4/udp.c | 5 +++-- net/ipv6/udp.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index c02bf011d4a6..420905be5f30 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1123,16 +1123,17 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) if (msg->msg_controllen) { err = udp_cmsg_send(sk, msg, &ipc.gso_size); - if (err > 0) + if (err > 0) { err = ip_cmsg_send(sk, msg, &ipc, sk->sk_family == AF_INET6); + connected = 0; + } if (unlikely(err < 0)) { kfree(ipc.opt); return err; } if (ipc.opt) free = 1; - connected = 0; } if (!ipc.opt) { struct ip_options_rcu *inet_opt; diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 8b1dd7f51249..1a4cccdd40c9 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1474,9 +1474,11 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) ipc6.opt = opt; err = udp_cmsg_send(sk, msg, &ipc6.gso_size); - if (err > 0) + if (err > 0) { err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, fl6, &ipc6); + connected = false; + } if (err < 0) { fl6_sock_release(flowlabel); return err; @@ -1488,7 +1490,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } if (!(opt->opt_nflen|opt->opt_flen)) opt = NULL; - connected = false; } if (!opt) { opt = txopt_get(np); -- 2.34.1