From patchwork Thu Oct 21 16:22:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575761 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CF3FC433FE for ; Thu, 21 Oct 2021 16:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 744EB6120F for ; Thu, 21 Oct 2021 16:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231873AbhJUQZS (ORCPT ); Thu, 21 Oct 2021 12:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbhJUQZR (ORCPT ); Thu, 21 Oct 2021 12:25:17 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24B1CC061764 for ; Thu, 21 Oct 2021 09:23:01 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id ls14-20020a17090b350e00b001a00e2251c8so916500pjb.4 for ; Thu, 21 Oct 2021 09:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dfltF+KdoBWysgdk4AaWUKJJEeefM25wtANwmdckgLY=; b=AhK+IgPxuQhOXvjxETC0QY2cGZD5UMQ7Z98eme3opfGqFbrINxhN+WHRsYdwJxq4v9 XPCB2D7LQtWn92KIgwa3474oAhgvbTzSAJS7fmI/UL5ovZKzyh+r4w5gxHQ5Jxg8gGUb gpe6MWlFC1RKspM6RHGc1K7G19sNfh3ejfsuCHjS+Wj6KNVvcCVUjCmUQWRUAzw012gO NJlRR5MEh3Nr02WBgLkIVPIE4OuDnP0kIy5CChH/sLH32L6qZ2pCZ2MgwB9oA1SmeJXC sUggL/RFtOi/c4h8I4jPJYArjBB1E0C2fIOQRU+nXCASE2Tdz4XtemSsun9VWxunr0SS ypbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dfltF+KdoBWysgdk4AaWUKJJEeefM25wtANwmdckgLY=; b=CPAmhFP+fJdVbzIXw5+RZjPi2UJ3c/EeyWtP5Sy3KpwtIaC6rhDJQ+NyJZoNCI925q Q4vl2lWrJUl0vn9J7Xp6giSLMMLinF+U9HF+zCd9U3k17csPwd6W42yG35zCJSQ4OEyr vaYkRsirwSibjk/xC6xNHsOnUoM2fgwdPKW3q4hiaHpNqdFll3n5bTdFxEUDD0pIZ5a/ tAkgNh1e7VmSsegrJq1cPUvEvGNx3G+rOxVwYyFYTGfWGv+/b3T2HQezoqRvuMPCsfnX O4GP/nc0gQLxeq7QFYCew6r+pQ3kAFV8BX8Y2cJmcRY7WwlrD4KfrNU77YRI9SHKy0hs 6rIQ== X-Gm-Message-State: AOAM532LH3n9w1X/zo7kW3oU9lFD3QnpD9IPQO4zHYVB8J1JCbD6Yskx Tzx+ZkMb/IwF6g1Ib5Jtx98= X-Google-Smtp-Source: ABdhPJzQnXLLGjcAU6aEYoAAPeRXKDyVb1dz4c5Dq4bbMendHFU0MLvIlSLBwA2hQ3Kj51VlCjPe/g== X-Received: by 2002:a17:90b:4c11:: with SMTP id na17mr7882895pjb.105.1634833380760; Thu, 21 Oct 2021 09:23:00 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:00 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell , "Ahmed S . Darwish" , Sebastian Andrzej Siewior Subject: [PATCH net-next 1/2] net: sched: fix logic error in qdisc_run_begin() Date: Thu, 21 Oct 2021 09:22:43 -0700 Message-Id: <20211021162253.333616-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet For non TCQ_F_NOLOCK qdisc, qdisc_run_begin() tries to set __QDISC_STATE_RUNNING and should return true if the bit was not set. test_and_set_bit() returns old bit value, therefore we need to invert. Fixes: 29cbcd858283 ("net: sched: Remove Qdisc::running sequence counter") Signed-off-by: Eric Dumazet Cc: Ahmed S. Darwish Cc: Sebastian Andrzej Siewior --- include/net/sch_generic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index baad2ab4d971cd3fdc8d59acdd72d39fa6230370..e0988c56dd8fd7aa3dff6bd971da3c81f1a20626 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -217,7 +217,7 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc) */ return spin_trylock(&qdisc->seqlock); } - return test_and_set_bit(__QDISC_STATE_RUNNING, &qdisc->state); + return !test_and_set_bit(__QDISC_STATE_RUNNING, &qdisc->state); } static inline void qdisc_run_end(struct Qdisc *qdisc) From patchwork Thu Oct 21 16:22:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575765 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9911C433F5 for ; Thu, 21 Oct 2021 16:23:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C554D6121E for ; Thu, 21 Oct 2021 16:23:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231865AbhJUQZa (ORCPT ); Thu, 21 Oct 2021 12:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231883AbhJUQZU (ORCPT ); Thu, 21 Oct 2021 12:25:20 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32138C061764 for ; Thu, 21 Oct 2021 09:23:04 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id y4so816720plb.0 for ; Thu, 21 Oct 2021 09:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rOil8ym42aNEoVie1dS9OFZdqUr5P1OG10M6EXwsAtU=; b=CbEUW/qmnNc4Z/xuiDkKie58q904IslfgS2waKR6juc1E0YHmMO5hYYD0QRmUIo4Kw rrVpkqm6RbTSNEBoNFEJ9jRYqHRDpZrxWjih9bUygUNsSdahYveIb+FikIih1/kP1Uk/ l6JZQL+B9gad7D4j+51Trkxu5Dw9qxtV6K2pxC1G+JEyyXGIJ9yxYOMy2HE3w2AAyqoJ TdJYV+eAsqboYdqPUctfJmELIf6zzNS6G4M5yvGih3lcw1+ZCDaSfIOMhha9IATCvmVC xUWqkU6BJKOGar0DYHULU2GGObYK7DnA95NeDRG0mvHi29IDX3a4ehmTPmf8ndZaQ8/2 Ulug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rOil8ym42aNEoVie1dS9OFZdqUr5P1OG10M6EXwsAtU=; b=TJOZZtccd372nIqzUG0AfT923mZ0FLDm7LAFhZmembK/2s2Go9ZD/3SevuiuexZCZ5 /47i1w4KbM/uieOC9WC3avbT0IY5LwOtk3kEz+QtwaPBc2kYsZLp35cids2/ohDNioWT WkTM4FaCw8ct0EZEPGA4AbLbQO4EDc9RDYxkFRhkT9oAO5qm6HBZMjTENnSOGskaTIMx 9TGUohClFLCtny+dvDiXIZyPWNCK7Tdzj0v2v5HQo+erik3+NtwnDw9fGfIK2vyJNY7f /hgt6ikmIY5WSmFKFuiw9OtTz836AEBYAQwetT5Hy5Fyuu+5HXHXsetHkVB5iTl/GYXr +0oQ== X-Gm-Message-State: AOAM5327b3wjCBYw4GgbPhdUqSBX9+4oLb7cU/U0AQBrJ15BG4ZEydbm drrhsgEQLnlOpuCEhXzxqE4= X-Google-Smtp-Source: ABdhPJy/f2GO5nfAVhppzyvNl28lNwTrfIMmLnYlrOvsn37RCOrsbdaVqPjuD+ahxpwOkwInhhzB6g== X-Received: by 2002:a17:90a:8a8c:: with SMTP id x12mr7720352pjn.44.1634833383659; Thu, 21 Oct 2021 09:23:03 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:03 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 2/9] ipv6: move inet6_sk(sk)->rx_dst_cookie to sk->sk_rx_dst_cookie Date: Thu, 21 Oct 2021 09:22:45 -0700 Message-Id: <20211021162253.333616-4-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Increase cache locality by moving rx_dst_coookie next to sk->sk_rx_dst This removes one or two cache line misses in IPv6 early demux (TCP/UDP) Signed-off-by: Eric Dumazet --- include/linux/ipv6.h | 1 - include/net/sock.h | 2 ++ net/ipv6/tcp_ipv6.c | 6 +++--- net/ipv6/udp.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index ef4a69865737cee82a72c35f3421a535b607c7a6..c383630d3f0658908eac65c030daf97b0a0d0c7c 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -282,7 +282,6 @@ struct ipv6_pinfo { __be32 rcv_flowinfo; __u32 dst_cookie; - __u32 rx_dst_cookie; struct ipv6_mc_socklist __rcu *ipv6_mc_list; struct ipv6_ac_socklist *ipv6_ac_list; diff --git a/include/net/sock.h b/include/net/sock.h index 0bfb3f138bdab01bd97498e1126d111743000c8c..99c4194cb61add848e3a35db0f952c4193f5ea1f 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -260,6 +260,7 @@ struct bpf_local_storage; * @sk_wq: sock wait queue and async head * @sk_rx_dst: receive input route used by early demux * @sk_rx_dst_ifindex: ifindex for @sk_rx_dst + * @sk_rx_dst_cookie: cookie for @sk_rx_dst * @sk_dst_cache: destination cache * @sk_dst_pending_confirm: need to confirm neighbour * @sk_policy: flow policy @@ -432,6 +433,7 @@ struct sock { #endif struct dst_entry *sk_rx_dst; int sk_rx_dst_ifindex; + u32 sk_rx_dst_cookie; struct dst_entry __rcu *sk_dst_cache; atomic_t sk_omem_alloc; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 833b5ca8cc83798e5303542fc7522a86d97518ae..360c79c8e3099e54d125d454b7f5eb406678c91f 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -109,7 +109,7 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) sk->sk_rx_dst = dst; sk->sk_rx_dst_ifindex = skb->skb_iif; - tcp_inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt); + sk->sk_rx_dst_cookie = rt6_get_cookie(rt); } } @@ -1508,7 +1508,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) if (dst) { if (sk->sk_rx_dst_ifindex != skb->skb_iif || INDIRECT_CALL_1(dst->ops->check, ip6_dst_check, - dst, np->rx_dst_cookie) == NULL) { + dst, sk->sk_rx_dst_cookie) == NULL) { dst_release(dst); sk->sk_rx_dst = NULL; } @@ -1869,7 +1869,7 @@ INDIRECT_CALLABLE_SCOPE void tcp_v6_early_demux(struct sk_buff *skb) struct dst_entry *dst = READ_ONCE(sk->sk_rx_dst); if (dst) - dst = dst_check(dst, tcp_inet6_sk(sk)->rx_dst_cookie); + dst = dst_check(dst, sk->sk_rx_dst_cookie); if (dst && sk->sk_rx_dst_ifindex == skb->skb_iif) skb_dst_set_noref(skb, dst); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 8d785232b4796b7cafe14a35dedcbb0aaa2c37c2..14a94cddcf0bcf63d8351c66b94a08770694a9c8 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -884,7 +884,7 @@ static void udp6_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst) if (udp_sk_rx_dst_set(sk, dst)) { const struct rt6_info *rt = (const struct rt6_info *)dst; - inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt); + sk->sk_rx_dst_cookie = rt6_get_cookie(rt); } } @@ -1073,7 +1073,7 @@ INDIRECT_CALLABLE_SCOPE void udp_v6_early_demux(struct sk_buff *skb) dst = READ_ONCE(sk->sk_rx_dst); if (dst) - dst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie); + dst = dst_check(dst, sk->sk_rx_dst_cookie); if (dst) { /* set noref for now. * any place which wants to hold dst has to call From patchwork Thu Oct 21 16:22:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575767 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84906C4332F for ; Thu, 21 Oct 2021 16:23:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64EAF6121E for ; Thu, 21 Oct 2021 16:23:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231924AbhJUQZb (ORCPT ); Thu, 21 Oct 2021 12:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231898AbhJUQZX (ORCPT ); Thu, 21 Oct 2021 12:25:23 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D97C061348 for ; Thu, 21 Oct 2021 09:23:06 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id a15-20020a17090a688f00b001a132a1679bso3560863pjd.0 for ; Thu, 21 Oct 2021 09:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ol7MeYN99tKYniOogeOey/QfrV6TG+g6eFWfS4txJpo=; b=KZtBrCjjXo0pkSZrR5ERebhFCQlU9s7iPMDAtGefDA9qsxe66PybmG5w8gYX6iTVYS x8nHY0J5pT0XW4SsLa8VoTn1PFGrygxg9E6n05eNRfGHT1a7ehJ8pDxEAPf6ZKZEX+zt Lm1G3Ps2y6aHx5ghjUrnes6Tz3g6aCMWTGWdLxDbDRDQBhouGaoRhLj7u0HDMFCKGa6A W4Ls623z1b3JcribQtI2vstDREuMNc0QNNMN75KmYJ8FYH0CV/vBQggzS9vtq6Ww2cVU o/WykO1Y9gr1AYQV0N2SmWIGlXA6BaSgO68MokORE3fdn0LxxGVREpGNc5N91YeetJ2K pz6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ol7MeYN99tKYniOogeOey/QfrV6TG+g6eFWfS4txJpo=; b=8Rfgxa591N3y8ShhX9yJLE0TwSAaDFsfUcWSsD6FZgD1lxhDSsZLw7/TyiuvhAkQxj cCKnfUI5gKO3uvSeBf7LifIA0Q4k8P9GHBYnNO6gU/wvLH1u8GV1LvqANxuhKW4F/qIo sFRRgTyGjNlzjVKiYYep1AHGcBmapaIfcoIaWg625L5ot7cuwgH9pdoO/66HRLoyg2Is E+yalnCdMsCVK1V3qktHI59WPaByD8wF5VLfutlphh/TtacTeml9srKMqQElhaaJRHmc gsgsCoCuCJzdAIBQFl48f2qK9QypMjEqvq9wJYMDpCXOtd0YRdf4qazKkMpc5sNZ3MvH 0dig== X-Gm-Message-State: AOAM531YTmEZ3AOVOEH8xbhhPuNf4WMeli1C5b/NzFkza04ZyB7RwIg9 cfpE60xEm/k/gTCcOILCmM8= X-Google-Smtp-Source: ABdhPJyEKzxD5tOnqPnuVGlRZhHVudoh8Moh8At6h+i/W2fELL6dmYKhPudkPVmTB2ANqPbuwA9gXg== X-Received: by 2002:a17:90b:4b83:: with SMTP id lr3mr7764529pjb.45.1634833386502; Thu, 21 Oct 2021 09:23:06 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:06 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 3/9] net: avoid dirtying sk->sk_napi_id Date: Thu, 21 Oct 2021 09:22:47 -0700 Message-Id: <20211021162253.333616-6-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet sk_napi_id is located in a cache line that can be kept read mostly. Signed-off-by: Eric Dumazet --- include/net/busy_poll.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h index 40296ed976a9778ceb239b99ad783cb99b8b92ef..4202c609bb0b09345c0f1c5105adf409a3a89f74 100644 --- a/include/net/busy_poll.h +++ b/include/net/busy_poll.h @@ -130,7 +130,8 @@ static inline void skb_mark_napi_id(struct sk_buff *skb, static inline void sk_mark_napi_id(struct sock *sk, const struct sk_buff *skb) { #ifdef CONFIG_NET_RX_BUSY_POLL - WRITE_ONCE(sk->sk_napi_id, skb->napi_id); + if (unlikely(READ_ONCE(sk->sk_napi_id) != skb->napi_id)) + WRITE_ONCE(sk->sk_napi_id, skb->napi_id); #endif sk_rx_queue_set(sk, skb); } From patchwork Thu Oct 21 16:22:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575771 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CFFFC433EF for ; Thu, 21 Oct 2021 16:23:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2521261251 for ; Thu, 21 Oct 2021 16:23:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231937AbhJUQZc (ORCPT ); Thu, 21 Oct 2021 12:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbhJUQZY (ORCPT ); Thu, 21 Oct 2021 12:25:24 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50CCBC061243 for ; Thu, 21 Oct 2021 09:23:08 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id e10so768473plh.8 for ; Thu, 21 Oct 2021 09:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s1stloSYxu083kFvymqt3Z08n7JsHCUpgo2FwN9CJVs=; b=OlPisfMM1WO8LmPnZHh/PQoIk78PqQB8XPNaY3NlL1X3fQLGvPFGpQfhpDqsoVKoa5 pP433iEpby3ku93PY4E6x3IucrnjQ1o4DVeOQQjSklBVZ0Cgo77xr4QDm2bzE2c3TlJx aMuQcvWIlyc08McpxKAmoCRMzxQ+KsDsXH6T8o0+Gl/r/l5QPwd+agwmjIendRNy9EY9 T1/tSFUGnKGoTzsJDL0BLuu5vcgENU8uIswhKqAezwGdK4XsNRuH6N/rt/fnI5Y1Piij NCT76+tXYFr8/yY0HzTT6weA6cQPf539LC4gPf90c1ITQAKgoL8QrYuxIO6jWZNv2mgH xUKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s1stloSYxu083kFvymqt3Z08n7JsHCUpgo2FwN9CJVs=; b=WhLlV5z+80wemmYifc9iMSdpzKX2GEmsRU0Z/myrmHrpeWthuoxuhGKtCSIu9MznJT dOG54L/LFjuYNdvtRRxd+OUZOYAKrtzRYiviC+AJMzVLoh+2sjaB3bVtY2bixc372fvL /NcPODPq2u8WW/btkLI/MfBC4NIHsUntrmZywXeHMd8PGzmlng+K+vPoH359N0sME8Zc URCa4a+zhbJyTJqizD6bDNl4eQ1f0XLjIS28/9Yj+s6meX+G9kO5GXLukJWAUNu0dAT7 XVIN0oJ7xaqOUOTTNjxoZnu5BC56T7fdnkzdVuwSUaIQOvp0Gi3+ggYBdHCCzDq0hklf ge3w== X-Gm-Message-State: AOAM533Azj8G09iHYxJ1wfGC4pfSAHWfM92a57Yk+noPUSmYnLl9J8QQ qoa2bOEO8Gwv6TM2iaRlodM= X-Google-Smtp-Source: ABdhPJysMv6tvNfbF66GEXRftHJ3MIcoAWDYQkD10uhcyKuE024B/jHzcnNNtl1rRGwcByQ/yrHX7A== X-Received: by 2002:a17:90a:b391:: with SMTP id e17mr7891813pjr.137.1634833387901; Thu, 21 Oct 2021 09:23:07 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:07 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 4/9] net: avoid dirtying sk->sk_rx_queue_mapping Date: Thu, 21 Oct 2021 09:22:48 -0700 Message-Id: <20211021162253.333616-7-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet sk_rx_queue_mapping is located in a cache line that should be kept read mostly. Signed-off-by: Eric Dumazet --- include/net/sock.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 99c4194cb61add848e3a35db0f952c4193f5ea1f..b4d3744b188ad869b4ec55f78e04236b710898de 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1916,10 +1916,8 @@ static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb) if (skb_rx_queue_recorded(skb)) { u16 rx_queue = skb_get_rx_queue(skb); - if (WARN_ON_ONCE(rx_queue == NO_QUEUE_MAPPING)) - return; - - sk->sk_rx_queue_mapping = rx_queue; + if (unlikely(READ_ONCE(sk->sk_rx_queue_mapping) != rx_queue)) + WRITE_ONCE(sk->sk_rx_queue_mapping, rx_queue); } #endif } From patchwork Thu Oct 21 16:22:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575773 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2138EC433FE for ; Thu, 21 Oct 2021 16:23:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0544960F9F for ; Thu, 21 Oct 2021 16:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231941AbhJUQZd (ORCPT ); Thu, 21 Oct 2021 12:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231877AbhJUQZZ (ORCPT ); Thu, 21 Oct 2021 12:25:25 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91529C061220 for ; Thu, 21 Oct 2021 09:23:09 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id ls18so867297pjb.3 for ; Thu, 21 Oct 2021 09:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6wiiQ7sBiLnaUvF7+3f+M8Xxmred+r5+dtf2RzCMq14=; b=LPktCy6yjNy1EeLbwBXG1Km3a8HUk7IbiTqOwWmjyoN5rwysX+n5L2c3Cme/8LSe7o lUKJNpI34irW45/+SYMcnfmxPOiOVXlCPW1kYen+ry28yX8PfRD6QndNCDMiRknj8TbH 0o6VQESBZLvJcb0nIrRWM1KciTycvaAVM1mz3zmko1jak5BCIgEPZE6EIG3skHejdeVw fozpv+6WSPnvtx3vG/sXZx8yJeoWWdAP0cHSG+xZ4xg2ozUoJTHQQ5of6m9xdJ2ip5rB Fd5SAJpmty7hixHmLBOmJ/KKKypBsX3elmVYEHwVbRQKQ0BsElwuEByYoZlp4Ghfrtbb agVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6wiiQ7sBiLnaUvF7+3f+M8Xxmred+r5+dtf2RzCMq14=; b=hVdx5FiKu8T8MzWvQW5sL3t1KMd8FN8zZgVUj5dvLa+e99o+6scWojcZlj6kybfZZA bTbGKHXsk94uuAcWXULJeS9f6q2zrIQzCUoPxNI22kVSajahYmn24oNQSC/aRhczP8yB zcIJopVP8WuRhsB6nFjG54NJbVnkviMLq7dTwpHcOjdau0AQRUu7Pd86WRR7YUxNmPEf UergcbEMjK18hHht9IuFcUgfnStH0tif3c2x26scsdMLikQhE9D8R2n5E20BYx0wwACl ZiLbYD7Vyz6Wzw4sxEjixZ4UlCFie1SiBx8MclgPPdAM3//Rg4pttO6e8INHaZAJs2yn LIiA== X-Gm-Message-State: AOAM531/+RFELvxoPSW48xxqNez3/H35P4VzpyGkZbhav5GLVm2gRGKU n/kuOuF5Ko5ktCrNyyPXgLQ= X-Google-Smtp-Source: ABdhPJyxobPcNReIKYI7oxeBZHMWd6uYTpX287nCaivWAz18vHoTD8QLCIxSz28vfE5LHj5yP2VS7Q== X-Received: by 2002:a17:90b:3ec6:: with SMTP id rm6mr7807302pjb.27.1634833389073; Thu, 21 Oct 2021 09:23:09 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:08 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 5/9] ipv6: annotate data races around np->min_hopcount Date: Thu, 21 Oct 2021 09:22:49 -0700 Message-Id: <20211021162253.333616-8-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet No report yet from KCSAN, yet worth documenting the races. Signed-off-by: Eric Dumazet --- net/ipv6/ipv6_sockglue.c | 5 ++++- net/ipv6/tcp_ipv6.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index e4bdb09c558670f342f1abad5dfd8252f497aa68..9c3d28764b5c3a47a73491ea5d656867ece4fed2 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -950,7 +950,10 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, goto e_inval; if (val < 0 || val > 255) goto e_inval; - np->min_hopcount = val; + /* tcp_v6_err() and tcp_v6_rcv() might read min_hopcount + * while we are changing it. + */ + WRITE_ONCE(np->min_hopcount, val); retv = 0; break; case IPV6_DONTFRAG: diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 360c79c8e3099e54d125d454b7f5eb406678c91f..2247f525364b16e89afedbec8f4ec3367bf88aa8 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -414,7 +414,8 @@ static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, if (sk->sk_state == TCP_CLOSE) goto out; - if (ipv6_hdr(skb)->hop_limit < tcp_inet6_sk(sk)->min_hopcount) { + /* min_hopcount can be changed concurrently from do_ipv6_setsockopt() */ + if (ipv6_hdr(skb)->hop_limit < READ_ONCE(tcp_inet6_sk(sk)->min_hopcount)) { __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); goto out; } @@ -1723,7 +1724,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) return 0; } } - if (hdr->hop_limit < tcp_inet6_sk(sk)->min_hopcount) { + /* min_hopcount can be changed concurrently from do_ipv6_setsockopt() */ + if (hdr->hop_limit < READ_ONCE(tcp_inet6_sk(sk)->min_hopcount)) { __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); goto discard_and_relse; } From patchwork Thu Oct 21 16:22:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575775 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBE03C433EF for ; Thu, 21 Oct 2021 16:23:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D27D26121F for ; Thu, 21 Oct 2021 16:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbhJUQZe (ORCPT ); Thu, 21 Oct 2021 12:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231912AbhJUQZ1 (ORCPT ); Thu, 21 Oct 2021 12:25:27 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19211C061224 for ; Thu, 21 Oct 2021 09:23:11 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id q10-20020a17090a1b0a00b001a076a59640so6089710pjq.0 for ; Thu, 21 Oct 2021 09:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a78ceogwZklintSvLdEa+VabuxrsNS5i6SlSoSFi624=; b=M6FUBtSar+1rFTnD7SHgo+ietdAi7aVw7eVL5kL+FqPA02ZnGrHbCYrcyKLvuMCf+k YbpTSwALsaWwAAOf1yvZ+dftA38KCgeT8Zf/R9P1ohFngz6/iLMtg5FhjaQnmRZ4ClEv cz8xVeoTQ9qxSkjaAYSNjczUBxJURUNKwqGVQJyXDTsEpPrpe0RbNOF530WBlhPzAzhx 71K55q5RlUsUkRcIcwVk/aK55eH3jGjOspZYCcVMKYd9YLy2Pnnft9Lmw/xmprenxlCs pDhsOEsMR+t9QICn3Y7Zrf0+m+Wf4RmU83wXvF/4M5l7zH3TOi76wzRm97lKZcLSbSfZ 0Ezg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a78ceogwZklintSvLdEa+VabuxrsNS5i6SlSoSFi624=; b=LdFLsnTJO6owW3veZ0kxiBYw+AplgqTQLnTIFcKM/A9tXkXySnw27n5hKTqTJM+l3Y DJCMtrEdlY89Vpq04G9MJgKjzZ7WOxI3zcmDfQbLY6ZGdCWK5jLP0Lo9HfLWysxi5WIP lw2xFiACY5NrXcaEKAX2BdqaKMyCKMK27O8WW520V/9Vebs1qwYsy8EOPgDWKiGtulib nN/xrrnXMmhNXNrx5griP0e40NHc+wqwk94Lv5v8rRzmkaCsEFN1e0aBuqUQhdVM3jFc guXh+uroRL46kXhZFI+GT/h+1gwoR5KcaQE0VvOcXSfE5odldJ+akd1MNpVLCY6RScIF HgFA== X-Gm-Message-State: AOAM531+EadAN3q6TXd7Milz+ds4k2DhgBP/Ju3yFvVPnS96uAGWnmbg 86Dhc2GNVeHmek3v+mBwaGo= X-Google-Smtp-Source: ABdhPJy10zr8n+SqheZm5/ucrY/nCwMd4iP/+rAuJ1IjBHF8yyUH1bDuPmpLtFmw+59T2UMQ8RducA== X-Received: by 2002:a17:90a:de0b:: with SMTP id m11mr7685928pjv.90.1634833390613; Thu, 21 Oct 2021 09:23:10 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:10 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 6/9] ipv6: guard IPV6_MINHOPCOUNT with a static key Date: Thu, 21 Oct 2021 09:22:50 -0700 Message-Id: <20211021162253.333616-9-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet RFC 5082 IPV6_MINHOPCOUNT is rarely used on hosts. Add a static key to remove from TCP fast path useless code, and potential cache line miss to fetch tcp_inet6_sk(sk)->min_hopcount Note that once ip6_min_hopcount static key has been enabled, it stays enabled until next boot. Signed-off-by: Eric Dumazet --- include/net/ipv6.h | 1 + net/ipv6/ipv6_sockglue.c | 6 ++++++ net/ipv6/tcp_ipv6.c | 21 +++++++++++++-------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index f2d0ecc257bb28e6dd162d180c371e2b0487c8e3..c19bf51ded1d026e795a3f9ae0ff3be766fc174e 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1092,6 +1092,7 @@ struct in6_addr *fl6_update_dst(struct flowi6 *fl6, /* * socket options (ipv6_sockglue.c) */ +DECLARE_STATIC_KEY_FALSE(ip6_min_hopcount); int ipv6_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen); diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 9c3d28764b5c3a47a73491ea5d656867ece4fed2..41efca817db4228f265235a471449a3790075ce7 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -55,6 +55,8 @@ struct ip6_ra_chain *ip6_ra_chain; DEFINE_RWLOCK(ip6_ra_lock); +DEFINE_STATIC_KEY_FALSE(ip6_min_hopcount); + int ip6_ra_control(struct sock *sk, int sel) { struct ip6_ra_chain *ra, *new_ra, **rap; @@ -950,6 +952,10 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, goto e_inval; if (val < 0 || val > 255) goto e_inval; + + if (val) + static_branch_enable(&ip6_min_hopcount); + /* tcp_v6_err() and tcp_v6_rcv() might read min_hopcount * while we are changing it. */ diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2247f525364b16e89afedbec8f4ec3367bf88aa8..bbff3df27d1c24d7a47849b28297ba129baafc99 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -414,10 +414,12 @@ static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, if (sk->sk_state == TCP_CLOSE) goto out; - /* min_hopcount can be changed concurrently from do_ipv6_setsockopt() */ - if (ipv6_hdr(skb)->hop_limit < READ_ONCE(tcp_inet6_sk(sk)->min_hopcount)) { - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); - goto out; + if (static_branch_unlikely(&ip6_min_hopcount)) { + /* min_hopcount can be changed concurrently from do_ipv6_setsockopt() */ + if (ipv6_hdr(skb)->hop_limit < READ_ONCE(tcp_inet6_sk(sk)->min_hopcount)) { + __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); + goto out; + } } tp = tcp_sk(sk); @@ -1724,10 +1726,13 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) return 0; } } - /* min_hopcount can be changed concurrently from do_ipv6_setsockopt() */ - if (hdr->hop_limit < READ_ONCE(tcp_inet6_sk(sk)->min_hopcount)) { - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); - goto discard_and_relse; + + if (static_branch_unlikely(&ip6_min_hopcount)) { + /* min_hopcount can be changed concurrently from do_ipv6_setsockopt() */ + if (hdr->hop_limit < READ_ONCE(tcp_inet6_sk(sk)->min_hopcount)) { + __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); + goto discard_and_relse; + } } if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) From patchwork Thu Oct 21 16:22:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575777 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC851C433F5 for ; Thu, 21 Oct 2021 16:23:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2BE96121E for ; Thu, 21 Oct 2021 16:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231912AbhJUQZf (ORCPT ); Thu, 21 Oct 2021 12:25:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231921AbhJUQZ2 (ORCPT ); Thu, 21 Oct 2021 12:25:28 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47BEEC061764 for ; Thu, 21 Oct 2021 09:23:12 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id o4-20020a17090a3d4400b001a1c8344c3fso1413202pjf.3 for ; Thu, 21 Oct 2021 09:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YwyvtW42o6k4NUXLTo2LNQBxBmdqEY5CXK69JvWzulU=; b=PsJEs4pJ58s5qcVOH2dtX32J36DG3dBrAYKkUyxm73TTbrlpfHqYozACZY6L7Mhi3q GWrGeUbJPfoTzv8n+NnJBzJ+rB17KgCJJpQDns2qOeD6c83YYIc7cLQletI54Hn4jOqZ 3AwvWSrJNApN3EztyT0+BSOcigVFswezc9Q+Fu0A2HlkNUsoSadmex598Fq7lWuSqegm oFNaXdGVagRZu90YP0gPLdasVhkc4KAGRjB1LtnB80jVgL9acDQnlk+MmLDgr53pZcJF UelZ5JYLMrmjl5RBMXmveujdpiCOm9nxadWsOHDIit8xc+hw3auLxIKoJVQt+XiF4vlu Dung== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YwyvtW42o6k4NUXLTo2LNQBxBmdqEY5CXK69JvWzulU=; b=SBDi6MIN6D6/s6k/xvb41KsGpa05MGde7PxaR0LApFHd2GP2+QHOsg3BJtfDvbwXeB FueQCIHJu68MHWjvfOzjZgii+qlyMI0OLeBEjzZX2ep5Yu62tgRxaVvB3sPkggBBu262 cT4h0HVQkU1OUFdqN1pQZqHnTH3CSJkEOIDm8uFuFMN1s+8dB+zijvsSkvLMNwup/CPM FYuwv3w2juhTqAPJ38SYkVDfAF/6J3/0htYcZJ4P9VIedj6WlJuIAzla9TvHNKEPSLjx YJdseiBW/kYppOI0S3XpVNT/9PyVPfT+czOmiEYbiLm5GmSKgbWmEv9/X0u+oA68d2zN 1Xww== X-Gm-Message-State: AOAM532mAYL7+So17BpTnkHhjkebgEeHzDomrx7LjoswJYuAZiYN9FNn FDO+ZKnk9AuWpM2LDfrJxok= X-Google-Smtp-Source: ABdhPJzPyign1MCB84l0+29usY0XSchU3YaXyaVFD1+FQHN10NeKJLPD6NzB16CMYOR/IJgtGzke3Q== X-Received: by 2002:a17:90a:4595:: with SMTP id v21mr7678631pjg.43.1634833391799; Thu, 21 Oct 2021 09:23:11 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:11 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 7/9] ipv4: annotate data races arount inet->min_ttl Date: Thu, 21 Oct 2021 09:22:51 -0700 Message-Id: <20211021162253.333616-10-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet No report yet from KCSAN, yet worth documenting the races. Signed-off-by: Eric Dumazet --- net/ipv4/ip_sockglue.c | 5 ++++- net/ipv4/tcp_ipv4.c | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index b297bb28556ec5cf383068f67ee910af38591cc3..d5487c8580674a01df8c7d8ce88f97c9add846b6 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1352,7 +1352,10 @@ static int do_ip_setsockopt(struct sock *sk, int level, int optname, goto e_inval; if (val < 0 || val > 255) goto e_inval; - inet->min_ttl = val; + /* tcp_v4_err() and tcp_v4_rcv() might read min_ttl + * while we are changint it. + */ + WRITE_ONCE(inet->min_ttl, val); break; default: diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index e8ca8539b436cf8a8af5b53645a25923003afc41..97b8acf726d0cdcb6b87b6ef45e366591d997a2b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -508,7 +508,8 @@ int tcp_v4_err(struct sk_buff *skb, u32 info) if (sk->sk_state == TCP_CLOSE) goto out; - if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) { + /* min_ttl can be changed concurrently from do_ip_setsockopt() */ + if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) { __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); goto out; } @@ -2049,7 +2050,9 @@ int tcp_v4_rcv(struct sk_buff *skb) return 0; } } - if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) { + + /* min_ttl can be changed concurrently from do_ip_setsockopt() */ + if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) { __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); goto discard_and_relse; } From patchwork Thu Oct 21 16:22:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575779 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C32B2C433FE for ; Thu, 21 Oct 2021 16:23:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A46556121F for ; Thu, 21 Oct 2021 16:23:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231921AbhJUQZg (ORCPT ); Thu, 21 Oct 2021 12:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbhJUQZ3 (ORCPT ); Thu, 21 Oct 2021 12:25:29 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8520CC061225 for ; Thu, 21 Oct 2021 09:23:13 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id f21so790660plb.3 for ; Thu, 21 Oct 2021 09:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FQLSQHvYU3ir45py5qySQ0fLYWleklAkyTTP8P9C2zE=; b=EaXYoOtNQ44K5bKS/S3+csn+l5V3dceGl65VuYRXu8zsYqIMbcplo96FP4qK287XGo xVHn8QGzOEEeUYR6faVuLxAYxufkmEnXQ38gTDvfgBHsa1EtNoI1CFX9rrosd0xtcESo 3TV70M+4I13UklqRkoxmpt7i6UEZAs3einvUuHiC4XggBiELOwjpngQL6xDpIuyNsr49 DWOQOFmBBSS0jL00/sYDZIXw/4RRg9ywajQr6yz8KySDpY5K5vMYfpKKPzfxRWcpBM2z xQgeztl9nKZaQACcfdf7dLqW7MUkF/QesmUmoBgwCxIuJNwbytSN+tmoQ65Jq2D+lYW3 WI8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FQLSQHvYU3ir45py5qySQ0fLYWleklAkyTTP8P9C2zE=; b=HGtzyQy5vLm/ZEUAFCwDmUv4Up0/GW6G6mRoyPvBjj+TOxPxrFYTenHTYYEV1S2pxG yz6dbSrBzNMMOZdx+8lXHgKktiCZ82QPVKCydrHeUliDQlzVFRQ63fn3hyHOAOf+HlIv Csdmr8+ubv7Dr9vhFIzY5QPNbe2gWQNdFvt8LMkC7Bg39a+aqhTxTYeFeJJX9AI80q7b Vg0peoRS1HZJrTm3r0fLrB6t2Hh7d3MAlvMYs1RemJz885yGxbfe6k/SpR78ToGoDfB8 jDNr82lRjB7dMFZhc/eTe0qAAiHgLSAR3ve3/dgIa4EDuF380NacQV2KGZ04LaCQtUxP cPaw== X-Gm-Message-State: AOAM530C+dfmFer8wlWoCVDoAX6idmGlXvKN21m0KipoqcXXSmlP98jV y/l2w9f5ScNJIX+JLC9ajno= X-Google-Smtp-Source: ABdhPJxvvBdqHSGsBeeezrYcWoSAUCCqivlgPVeE2gDiYW03MVJYrDPmgRaqjN/nnHo0PoKkDFEVXg== X-Received: by 2002:a17:90a:d582:: with SMTP id v2mr7710146pju.46.1634833393083; Thu, 21 Oct 2021 09:23:13 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:12 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 8/9] ipv4: guard IP_MINTTL with a static key Date: Thu, 21 Oct 2021 09:22:52 -0700 Message-Id: <20211021162253.333616-11-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet RFC 5082 IP_MINTTL option is rarely used on hosts. Add a static key to remove from TCP fast path useless code, and potential cache line miss to fetch inet_sk(sk)->min_ttl Note that once ip4_min_ttl static key has been enabled, it stays enabled until next boot. Signed-off-by: Eric Dumazet --- include/net/ip.h | 2 ++ net/ipv4/ip_sockglue.c | 6 ++++++ net/ipv4/tcp_ipv4.c | 20 ++++++++++++-------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index cf229a53119428307da898af4b0dc23e1cecc053..b71e88507c4a0907011c41e1ed0148eb873b5186 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -750,6 +751,7 @@ void ip_cmsg_recv_offset(struct msghdr *msg, struct sock *sk, struct sk_buff *skb, int tlen, int offset); int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, bool allow_ipv6); +DECLARE_STATIC_KEY_FALSE(ip4_min_ttl); int ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen); int ip_getsockopt(struct sock *sk, int level, int optname, char __user *optval, diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index d5487c8580674a01df8c7d8ce88f97c9add846b6..38d29b175ca6646c280e0626e8e935b348f00f08 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -886,6 +886,8 @@ static int compat_ip_mcast_join_leave(struct sock *sk, int optname, return ip_mc_leave_group(sk, &mreq); } +DEFINE_STATIC_KEY_FALSE(ip4_min_ttl); + static int do_ip_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen) { @@ -1352,6 +1354,10 @@ static int do_ip_setsockopt(struct sock *sk, int level, int optname, goto e_inval; if (val < 0 || val > 255) goto e_inval; + + if (val) + static_branch_enable(&ip4_min_ttl); + /* tcp_v4_err() and tcp_v4_rcv() might read min_ttl * while we are changint it. */ diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 97b8acf726d0cdcb6b87b6ef45e366591d997a2b..8e9f05d9c54c316e6f6d0603ad786399f9c6345c 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -508,10 +508,12 @@ int tcp_v4_err(struct sk_buff *skb, u32 info) if (sk->sk_state == TCP_CLOSE) goto out; - /* min_ttl can be changed concurrently from do_ip_setsockopt() */ - if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) { - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); - goto out; + if (static_branch_unlikely(&ip4_min_ttl)) { + /* min_ttl can be changed concurrently from do_ip_setsockopt() */ + if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) { + __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); + goto out; + } } tp = tcp_sk(sk); @@ -2051,10 +2053,12 @@ int tcp_v4_rcv(struct sk_buff *skb) } } - /* min_ttl can be changed concurrently from do_ip_setsockopt() */ - if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) { - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); - goto discard_and_relse; + if (static_branch_unlikely(&ip4_min_ttl)) { + /* min_ttl can be changed concurrently from do_ip_setsockopt() */ + if (unlikely(iph->ttl < READ_ONCE(inet_sk(sk)->min_ttl))) { + __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); + goto discard_and_relse; + } } if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) From patchwork Thu Oct 21 16:22:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12575781 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28762C433F5 for ; Thu, 21 Oct 2021 16:23:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DC046121E for ; Thu, 21 Oct 2021 16:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231944AbhJUQZh (ORCPT ); Thu, 21 Oct 2021 12:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231889AbhJUQZb (ORCPT ); Thu, 21 Oct 2021 12:25:31 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0669AC0613B9 for ; Thu, 21 Oct 2021 09:23:15 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id f21so790707plb.3 for ; Thu, 21 Oct 2021 09:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tp6na0t+X0SDpQWMbmuqv49PPB2H80BGCxXgsnVFAKA=; b=WVQZQE5fOD4sEF+Nx0tVIzfC45Dt2Gf3WW5OvZVn3V9CDBx1lQXnPYcF44JnNogp80 JZ8YvkWsJgRRUpBqqKWpJXMrqhrrlPNHd6gC6G2ndkvkjr4rhAZhWxIl2i/0XHYVh1xr fBy76gUx+2G072EIBp0qgkjHK26clTN1feogvO/xh4oOogugbGY5hgtO8WBb6mmdB9MJ ygKGFc54CeBvsy1lWBGvN85CdvjsCIzInK4q0hXnMR+nOhRbsGvOLpWWbElmk4t3VKPQ UR19YzaSp5JhMef31WNedvnAYLtt0eju5yMXIitlBKhLGU8kJutYbXkENhhglo6fNZHG B5+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tp6na0t+X0SDpQWMbmuqv49PPB2H80BGCxXgsnVFAKA=; b=wpAO4/0Rofy5LdeyFEQKpYTyu5ZX0CsBZ03LAS3lI67nVbCx83seWim0NRdQcizXg3 f/2clKKz6lnty4uIRVQ4fUHExNu3/qXSOuhR7Qe0uXRwMU2v8HlJ9QpKdNOYoDyYsa9i qTtQ0CTWRTFkgtReZxDx44o1ND+W4S5jhASdunJqjJKFCmHW3wUK5K9Iufcz7+cRg3Cf 5hc7vaSoeKDj4X+J/Hk/OHKuA8Xq9wpFmEPTNX2b9bw0KYfrOlzfb6+717ZiSvduJMtI cQfhRwuRStwFiL0DIWcNHOth6PYjpHl3KrpCS4D1D2ohtJJhZ/aiUsjHEqAsWYqoA8a0 UAlg== X-Gm-Message-State: AOAM533qdEaaX/UwGRwP1Bi9AoP/QKbR4HjHuIn0G97pkB4gGqFzbvrd bKn+HcyfUWomMURPuliAp8I= X-Google-Smtp-Source: ABdhPJwsQ058r0n3kPEKxq1mSXoDAOX+mLtGecM3rDLHpn0DimpfIgZPEOo7dRU0xC6/q34aV2jTkA== X-Received: by 2002:a17:90b:4a05:: with SMTP id kk5mr7728353pjb.25.1634833394633; Thu, 21 Oct 2021 09:23:14 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c17a:20ce:f4d9:d04c]) by smtp.gmail.com with ESMTPSA id n22sm6719291pfo.15.2021.10.21.09.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 09:23:14 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Eric Dumazet , Soheil Hassas Yeganeh , Neal Cardwell Subject: [PATCH net-next 9/9] ipv6/tcp: small drop monitor changes Date: Thu, 21 Oct 2021 09:22:53 -0700 Message-Id: <20211021162253.333616-12-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.33.0.1079.g6e70778dc9-goog In-Reply-To: <20211021162253.333616-1-eric.dumazet@gmail.com> References: <20211021162253.333616-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Two kfree_skb() calls must be replaced by consume_skb() for skbs that are not technically dropped. Signed-off-by: Eric Dumazet --- net/ipv6/tcp_ipv6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index bbff3df27d1c24d7a47849b28297ba129baafc99..5504564f7e252e048df456156cf1183b5f01826c 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -572,7 +572,7 @@ static int tcp_v6_send_synack(const struct sock *sk, struct dst_entry *dst, static void tcp_v6_reqsk_destructor(struct request_sock *req) { kfree(inet_rsk(req)->ipv6_opt); - kfree_skb(inet_rsk(req)->pktopts); + consume_skb(inet_rsk(req)->pktopts); } #ifdef CONFIG_TCP_MD5SIG @@ -1591,7 +1591,7 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) } } - kfree_skb(opt_skb); + consume_skb(opt_skb); return 0; }