From patchwork Sun Feb 20 07:06:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752593 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9121C433FE for ; Sun, 20 Feb 2022 07:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234910AbiBTHIO (ORCPT ); Sun, 20 Feb 2022 02:08:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234501AbiBTHIK (ORCPT ); Sun, 20 Feb 2022 02:08:10 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 206EB4D244; Sat, 19 Feb 2022 23:07:50 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id d17so5995236pfl.0; Sat, 19 Feb 2022 23:07:50 -0800 (PST) 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=WjAM/H6V8k6iZ0h/t53GnXn7S+EJJ1PCS7UmZdIQVy8=; b=O+cyc5udZpU4yHr2EPNr0sJYLCARZEX+7ZO1ttqmPRwSENUoO0Vp+SNs4phv3Y3z2a epLgHnQFoLKZF7UaFsS9hKBWrzhA7gIsur3bujkKiD7i+9D09HxWJTI3AnHCHPSqNN8U fjLy84hMRBkOHxRQjaXopQW/W304CAhNiXe1ooOBIyxacaR7TgJ0DrdelE2ELXVlG0ke 77Ue2p/nEkv5O6JDXE7U9SXdzRKX86PRMtngSfFSZ+aeEC1iT5Uqjoz5X8nO2fnakjGG P2ZYPzJkjDlHyxabLn9k4INCBIXQ8hLzUnlX+kz7d7F4ilel/SCAX77V4CgEBLYjXs6R CASw== 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=WjAM/H6V8k6iZ0h/t53GnXn7S+EJJ1PCS7UmZdIQVy8=; b=L0KBg5hEh8C80D8ljOJa+4gEDpoeyfXD7EBZw2ke4BPommscCHILjV2TPXt3JyBrIg /CFXndprjQES4XMz9+VosQhbF7shXFJQFIyqc7OM7/qX3HL14HoGxsOjv6ZBSUVticwP a71ks6tCfU7MHhGjjgENZqBSjMb+dJlVLO8PQphl0HuNzBc1cs6t9SmTTbqMoGheqTXa 3sBF4r6nX2YQA952AxG9ZzORWYsSUfdIlpwBGO6FMgwg6pHg/+RLmzZ4AuiLLtRuy7eR Y59OmLIFXqqYf+LXlAZCuyaHPC3p/lNbAMUmBu8Y2yFxENrxrdhn33dvjo83vechMvCj 8kAw== X-Gm-Message-State: AOAM533DNeRpQxeasgudKlmqMKGhafocdsV7dqlhvVOdk1pc2kd2rRwU 9xzOpzPI9dpDgJtWo00QzP8= X-Google-Smtp-Source: ABdhPJyvXrJ78R86NabS4SWc47bJcQrA4vRrbIAbpeLGtsp7EfikVFBINoHX572LfD9/BD23sTJhXg== X-Received: by 2002:a63:1844:0:b0:36c:6a88:ad72 with SMTP id 4-20020a631844000000b0036c6a88ad72mr11664906pgy.329.1645340869710; Sat, 19 Feb 2022 23:07:49 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:07:49 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 1/9] net: tcp: introduce tcp_drop_reason() Date: Sun, 20 Feb 2022 15:06:29 +0800 Message-Id: <20220220070637.162720-2-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong For TCP protocol, tcp_drop() is used to free the skb when it needs to be dropped. To make use of kfree_skb_reason() and pass the drop reason to it, introduce the function tcp_drop_reason(). Meanwhile, make tcp_drop() an inline call to tcp_drop_reason(). Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- v3: - remove the 'inline' of tcp_drop() --- net/ipv4/tcp_input.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index af94a6d22a9d..2bcbefa4322a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4684,10 +4684,16 @@ static bool tcp_ooo_try_coalesce(struct sock *sk, return res; } -static void tcp_drop(struct sock *sk, struct sk_buff *skb) +static void tcp_drop_reason(struct sock *sk, struct sk_buff *skb, + enum skb_drop_reason reason) { sk_drops_add(sk, skb); - __kfree_skb(skb); + kfree_skb_reason(skb, reason); +} + +static void tcp_drop(struct sock *sk, struct sk_buff *skb) +{ + tcp_drop_reason(sk, skb, SKB_DROP_REASON_NOT_SPECIFIED); } /* This one checks to see if we can put data from the From patchwork Sun Feb 20 07:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752596 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C56EC4332F for ; Sun, 20 Feb 2022 07:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242920AbiBTHI3 (ORCPT ); Sun, 20 Feb 2022 02:08:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239157AbiBTHIS (ORCPT ); Sun, 20 Feb 2022 02:08:18 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ACB54D9C8; Sat, 19 Feb 2022 23:07:57 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id i21so5938628pfd.13; Sat, 19 Feb 2022 23:07:57 -0800 (PST) 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=+zj+yKOOAhMIrT7/fa7Kt9wEioXPkrCjpEMqA6i4/zg=; b=ktskm5JJNJzRwK2BdESHlVWUEyr3cDAJOMNV26aHNcoSvtDhYSEqq+3IuKMuHle7LZ n2EbF9lwnTTDbi9rXp/GouLzbmlFSi4x7ui1tswxHhmBT6Jwogp3XY+C+9uGGtdT3wjB S1zMwT/BamCbnFk8GAVb9A1pd000wNB19R5ecPV3OnLTMlxw5Z51fIPftbFxkQMlb0Ra /ksRRI5jKSEuixYBOO1Kg1MF9LYd6IkDrUqPKyNVZHg0wwSn3LAtklEFPlXak/lQRVHC Z9wSgYX/s5RVNDP63WU7hAQdGGezj9Nk7Yqj41+oivF0U5dsd2P5fIFIFvNBrDU17BKT uT3A== 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=+zj+yKOOAhMIrT7/fa7Kt9wEioXPkrCjpEMqA6i4/zg=; b=yoYDT9ooiNNAWx+ycHk7rcpqH56Rjb0vVcVxBzlJl+mj3NyK3dIc62wBjsoIMihLyw JqXT4tjJE/1BDiEO+Bo5ySOp3u45Z5qATxAUiavBRDTdloZ89XTUwSAYmax5xZ/qBAgR WNr4ax0vO/VI1KUZPGLhlMCZ2xrGbecRPjPMI7Gq80y5bdYGxyeLk2q5FecKugTQ7FBt /nBHhlWLASTcLdgWLEmKoW7m+iEXWCr/jnrgompjaLP4OYN9izu3bKeZoRyY7Pnqkt5z lvVUM6H00GvpI96Y26+MrMuA/Oi9noVdQVUkFrzSpnBoWK6A6XUNbZ5cZvyR7TzioG/j +3ZQ== X-Gm-Message-State: AOAM530X1yR87Cri1fjkcIUnBAHytI9MscG4+EaLI5ELjrJ6OtAe8+Us e8ON8osat96VvCV0zfOB/p0= X-Google-Smtp-Source: ABdhPJyPJBzi6n4eVRH7QLIn5zQP7POaIgpOFomfa8aXQLvP9JI/gotL3CGGzK4OchXTWaa6Umoqrg== X-Received: by 2002:a05:6a00:1995:b0:4e1:a7dd:96d6 with SMTP id d21-20020a056a00199500b004e1a7dd96d6mr14842539pfl.16.1645340876722; Sat, 19 Feb 2022 23:07:56 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:07:56 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 2/9] net: tcp: add skb drop reasons to tcp_v4_rcv() Date: Sun, 20 Feb 2022 15:06:30 +0800 Message-Id: <20220220070637.162720-3-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Use kfree_skb_reason() for some path in tcp_v4_rcv() that missed before, including: SKB_DROP_REASON_SOCKET_FILTER SKB_DROP_REASON_XFRM_POLICY Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- v2: - let NO_SOCKET trump the XFRM failure --- net/ipv4/tcp_ipv4.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 6873f46fc8ba..a3beab01e9a7 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2057,6 +2057,8 @@ int tcp_v4_rcv(struct sk_buff *skb) iph = ip_hdr(skb); tcp_v4_fill_cb(skb, iph, th); nsk = tcp_check_req(sk, skb, req, false, &req_stolen); + } else { + drop_reason = SKB_DROP_REASON_SOCKET_FILTER; } if (!nsk) { reqsk_put(req); @@ -2092,8 +2094,10 @@ int tcp_v4_rcv(struct sk_buff *skb) } } - if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) + if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { + drop_reason = SKB_DROP_REASON_XFRM_POLICY; goto discard_and_relse; + } if (tcp_v4_inbound_md5_hash(sk, skb, dif, sdif)) goto discard_and_relse; @@ -2166,6 +2170,7 @@ int tcp_v4_rcv(struct sk_buff *skb) do_time_wait: if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { + drop_reason = SKB_DROP_REASON_XFRM_POLICY; inet_twsk_put(inet_twsk(sk)); goto discard_it; } From patchwork Sun Feb 20 07:06:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752594 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFCBEC433EF for ; Sun, 20 Feb 2022 07:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243041AbiBTHIc (ORCPT ); Sun, 20 Feb 2022 02:08:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236524AbiBTHI1 (ORCPT ); Sun, 20 Feb 2022 02:08:27 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 485F04D9DB; Sat, 19 Feb 2022 23:08:04 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id w37so5149855pga.7; Sat, 19 Feb 2022 23:08:04 -0800 (PST) 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=8u5WsBGNkZ7pT95RfoIg7CD5GpWfzFZGJFFZCp3bMAA=; b=qMvJ9sniefGek1IVFdhPZTpyvssbYOLVB7YbhrHr8WqHIzKrNaBC0C6S2L98Wv0Tpb M+jHs5tQBRFCSoEwq3N/dgEBWabtmcubYlNtxWOC1z7dlW+kFxZH1vbH8NM7ktNWFL3P b+P/qIw+PwSVlClCFlBx10JaHGd/j9NFR8uJ82yxU5CPXGlg66KYcn5xgb7sC8A1TdaU 6LFwYdje4nFBqYJG3aY1Ot0xIV2GrHMyl6E00TmuML9d/o/2sUNkhX+KDwuyS6m6g8I1 7beNLaTypmoNEKAqW6mO7pGeq+GFh6rplit+RPRqxV14Uj/dFa5FGnMsEHwcFQRKLKWy PrUA== 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=8u5WsBGNkZ7pT95RfoIg7CD5GpWfzFZGJFFZCp3bMAA=; b=lgf0q/QBPUZAkVxhv6ImuDrIlWDF6S3TX0kVKOD/wRy2kxdtroJTD5JaYRwdhIergd vM1iX5fVnDN5Tc68uGIfvtAhPStYAkVgI61o+83MmpU8Q7uBAwfiLpa5Q3pgELBqaDOS c50JcG4fLtw8R3d341Efcw48zrZSfCDrXSCIUHSSdaad5SGro5apGYOoZ5ciXPCVKTtC 3tJuYXd66hsEPGIMiLrkewQDH3IcOiEjprWRC3ZwlQZdO6Y9Uaxl/a0tqsb0gmlv8AMr kJ7pt0i6MSyZ05kYmUT7FNMTH+g0i5reLPNzVuvh9mwRtDbq7exnqXb7Z19tOyj3EUaB WAvw== X-Gm-Message-State: AOAM532SpIsz3xPOkGx7Suv596F0LEKY2XuzcNNxVe7T8F35lkjk+LcM qp9M9nOeg3EOkGALw6JzE1Y= X-Google-Smtp-Source: ABdhPJxjp1/yZgsFZkomrtMEQ0mkh/Wclyl0cElsG13pPemp2GHsno2uQc3AQls1YV0Ayk/eAtlZsQ== X-Received: by 2002:a05:6a00:27a7:b0:4e1:5cf4:2429 with SMTP id bd39-20020a056a0027a700b004e15cf42429mr15169090pfb.73.1645340883788; Sat, 19 Feb 2022 23:08:03 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:08:03 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 3/9] net: tcp: use kfree_skb_reason() for tcp_v6_rcv() Date: Sun, 20 Feb 2022 15:06:31 +0800 Message-Id: <20220220070637.162720-4-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace kfree_skb() used in tcp_v6_rcv() with kfree_skb_reason(). Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- v2: - let NO_SOCKET trump the XFRM failure --- net/ipv6/tcp_ipv6.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 0c648bf07f39..0aa17073df1a 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1627,6 +1627,7 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr, INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) { + enum skb_drop_reason drop_reason; int sdif = inet6_sdif(skb); int dif = inet6_iif(skb); const struct tcphdr *th; @@ -1636,6 +1637,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) int ret; struct net *net = dev_net(skb->dev); + drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; if (skb->pkt_type != PACKET_HOST) goto discard_it; @@ -1649,8 +1651,10 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) th = (const struct tcphdr *)skb->data; - if (unlikely(th->doff < sizeof(struct tcphdr)/4)) + if (unlikely(th->doff < sizeof(struct tcphdr) / 4)) { + drop_reason = SKB_DROP_REASON_PKT_TOO_SMALL; goto bad_packet; + } if (!pskb_may_pull(skb, th->doff*4)) goto discard_it; @@ -1706,6 +1710,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) hdr = ipv6_hdr(skb); tcp_v6_fill_cb(skb, hdr, th); nsk = tcp_check_req(sk, skb, req, false, &req_stolen); + } else { + drop_reason = SKB_DROP_REASON_SOCKET_FILTER; } if (!nsk) { reqsk_put(req); @@ -1741,14 +1747,18 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) } } - if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) + if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) { + drop_reason = SKB_DROP_REASON_XFRM_POLICY; goto discard_and_relse; + } if (tcp_v6_inbound_md5_hash(sk, skb, dif, sdif)) goto discard_and_relse; - if (tcp_filter(sk, skb)) + if (tcp_filter(sk, skb)) { + drop_reason = SKB_DROP_REASON_SOCKET_FILTER; goto discard_and_relse; + } th = (const struct tcphdr *)skb->data; hdr = ipv6_hdr(skb); tcp_v6_fill_cb(skb, hdr, th); @@ -1779,6 +1789,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) return ret ? -1 : 0; no_tcp_socket: + drop_reason = SKB_DROP_REASON_NO_SOCKET; if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) goto discard_it; @@ -1786,6 +1797,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) if (tcp_checksum_complete(skb)) { csum_error: + drop_reason = SKB_DROP_REASON_TCP_CSUM; trace_tcp_bad_csum(skb); __TCP_INC_STATS(net, TCP_MIB_CSUMERRORS); bad_packet: @@ -1795,7 +1807,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) } discard_it: - kfree_skb(skb); + kfree_skb_reason(skb, drop_reason); return 0; discard_and_relse: @@ -1806,6 +1818,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) do_time_wait: if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { + drop_reason = SKB_DROP_REASON_XFRM_POLICY; inet_twsk_put(inet_twsk(sk)); goto discard_it; } From patchwork Sun Feb 20 07:06:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752595 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BBB1C433F5 for ; Sun, 20 Feb 2022 07:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237533AbiBTHId (ORCPT ); Sun, 20 Feb 2022 02:08:33 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243004AbiBTHIb (ORCPT ); Sun, 20 Feb 2022 02:08:31 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A3F74D9C8; Sat, 19 Feb 2022 23:08:11 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id y16so3995094pjt.0; Sat, 19 Feb 2022 23:08:11 -0800 (PST) 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=mDOubhNw/a9sRYXV+7JLa5rcAVT46EltzMksSTCmpVE=; b=qVAh4qGNhC5Od0Ow7mFYPpH2xhkeLpm8qA91VpEhs6y5uNT+gsJbr9EO33iXR6IT37 ity1CEfMUCEkru6df2stgj17shjKriWCRQf5AiZWzHqbmELmXR6TuKY4DTAGvTpqFbxa Up5aoKKdV+uRL1mVjT2N0DVOhWlR3DxLOMVVV2C++LHFJ++NbwJzrXSGl8lhkiynrB3Z DSqyvI8PpqyffOIPxLMs3j7AC94dDIYahJ3ozi4zqJ8M18VKFsR9OA7UD7Tl0USEyy1F oCT5DH/fe2nfUWa+8og9Vn8j8R7g4Mdgecz5csdV16T/LQwT5OMwYombFTWE9Ftjp1uA xPtw== 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=mDOubhNw/a9sRYXV+7JLa5rcAVT46EltzMksSTCmpVE=; b=dI4FlbUXq2GXgcn6yiG827pTzrnKHYbzwt0m90vX2Z0PHwOXkS22y5gH0bcG+uaBJQ fDRum3p6OQMWekUCKi6kcCjE0pTrwi8+q/Icy6XdXaLCI4Z2u24jflOW9wfgBeTb0evX ugHDLmkELdLe92J+9pms+McBo8pqda2p+nnNjZcZGV3CEwdwk34qBmqLvw6WgPuzmGsW vtMuCvM/S7GLBEg/Tjr278TzZMNAVXog073owZUtAdhEMWv1Q/f8+Qyk55iErQ8Hh6Lz yPsaemFU4PN42JL8R7wpNtYDZlAeup8+50hl4mSGrT7yzHL+Iqbamw0pqseC6tKYzSNT le/A== X-Gm-Message-State: AOAM533wofq6PsFwBsUL/959pxUpjF4K8SO6KjfDVha4iCyDjLR4USaC jnzu2hAREHOvbUCN4DVdb88= X-Google-Smtp-Source: ABdhPJwPXkbhp0gJiSoqko7WLsRVz+OFZrAwazZBvBklxjQ3oVRyVUNEcKKzxFlUJi6Sxhqyc0p3Zw== X-Received: by 2002:a17:902:f711:b0:14d:61ba:8baf with SMTP id h17-20020a170902f71100b0014d61ba8bafmr14244325plo.39.1645340890856; Sat, 19 Feb 2022 23:08:10 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:08:10 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 4/9] net: tcp: add skb drop reasons to tcp_v{4,6}_inbound_md5_hash() Date: Sun, 20 Feb 2022 15:06:32 +0800 Message-Id: <20220220070637.162720-5-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Pass the address of drop reason to tcp_v4_inbound_md5_hash() and tcp_v6_inbound_md5_hash() to store the reasons for skb drops when this function fails. Therefore, the drop reason can be passed to kfree_skb_reason() when the skb needs to be freed. Following drop reasons are added: SKB_DROP_REASON_TCP_MD5NOTFOUND SKB_DROP_REASON_TCP_MD5UNEXPECTED SKB_DROP_REASON_TCP_MD5FAILURE SKB_DROP_REASON_TCP_MD5* above correspond to LINUX_MIB_TCPMD5* Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- include/linux/skbuff.h | 12 ++++++++++++ include/trace/events/skb.h | 4 ++++ net/ipv4/tcp_ipv4.c | 13 +++++++++---- net/ipv6/tcp_ipv6.c | 11 ++++++++--- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a5adbf6b51e8..46678eb587ff 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -346,6 +346,18 @@ enum skb_drop_reason { * udp packet drop out of * udp_memory_allocated. */ + SKB_DROP_REASON_TCP_MD5NOTFOUND, /* no MD5 hash and one + * expected, corresponding + * to LINUX_MIB_TCPMD5NOTFOUND + */ + SKB_DROP_REASON_TCP_MD5UNEXPECTED, /* MD5 hash and we're not + * expecting one, corresponding + * to LINUX_MIB_TCPMD5UNEXPECTED + */ + SKB_DROP_REASON_TCP_MD5FAILURE, /* MD5 hash and its wrong, + * corresponding to + * LINUX_MIB_TCPMD5FAILURE + */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index cfcfd26399f7..46c06b0be850 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -27,6 +27,10 @@ EM(SKB_DROP_REASON_IP_NOPROTO, IP_NOPROTO) \ EM(SKB_DROP_REASON_SOCKET_RCVBUFF, SOCKET_RCVBUFF) \ EM(SKB_DROP_REASON_PROTO_MEM, PROTO_MEM) \ + EM(SKB_DROP_REASON_TCP_MD5NOTFOUND, TCP_MD5NOTFOUND) \ + EM(SKB_DROP_REASON_TCP_MD5UNEXPECTED, \ + TCP_MD5UNEXPECTED) \ + EM(SKB_DROP_REASON_TCP_MD5FAILURE, TCP_MD5FAILURE) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a3beab01e9a7..d3c417119057 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1412,7 +1412,8 @@ EXPORT_SYMBOL(tcp_v4_md5_hash_skb); /* Called with rcu_read_lock() */ static bool tcp_v4_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb, - int dif, int sdif) + int dif, int sdif, + enum skb_drop_reason *reason) { #ifdef CONFIG_TCP_MD5SIG /* @@ -1445,11 +1446,13 @@ static bool tcp_v4_inbound_md5_hash(const struct sock *sk, return false; if (hash_expected && !hash_location) { + *reason = SKB_DROP_REASON_TCP_MD5NOTFOUND; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND); return true; } if (!hash_expected && hash_location) { + *reason = SKB_DROP_REASON_TCP_MD5UNEXPECTED; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED); return true; } @@ -1462,6 +1465,7 @@ static bool tcp_v4_inbound_md5_hash(const struct sock *sk, NULL, skb); if (genhash || memcmp(hash_location, newhash, 16) != 0) { + *reason = SKB_DROP_REASON_TCP_MD5FAILURE; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE); net_info_ratelimited("MD5 Hash failed for (%pI4, %d)->(%pI4, %d)%s L3 index %d\n", &iph->saddr, ntohs(th->source), @@ -1971,13 +1975,13 @@ static void tcp_v4_fill_cb(struct sk_buff *skb, const struct iphdr *iph, int tcp_v4_rcv(struct sk_buff *skb) { struct net *net = dev_net(skb->dev); + enum skb_drop_reason drop_reason; int sdif = inet_sdif(skb); int dif = inet_iif(skb); const struct iphdr *iph; const struct tcphdr *th; bool refcounted; struct sock *sk; - int drop_reason; int ret; drop_reason = SKB_DROP_REASON_NOT_SPECIFIED; @@ -2025,7 +2029,8 @@ int tcp_v4_rcv(struct sk_buff *skb) struct sock *nsk; sk = req->rsk_listener; - if (unlikely(tcp_v4_inbound_md5_hash(sk, skb, dif, sdif))) { + if (unlikely(tcp_v4_inbound_md5_hash(sk, skb, dif, sdif, + &drop_reason))) { sk_drops_add(sk, skb); reqsk_put(req); goto discard_it; @@ -2099,7 +2104,7 @@ int tcp_v4_rcv(struct sk_buff *skb) goto discard_and_relse; } - if (tcp_v4_inbound_md5_hash(sk, skb, dif, sdif)) + if (tcp_v4_inbound_md5_hash(sk, skb, dif, sdif, &drop_reason)) goto discard_and_relse; nf_reset_ct(skb); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 0aa17073df1a..1262b790b146 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -775,7 +775,8 @@ static int tcp_v6_md5_hash_skb(char *md5_hash, static bool tcp_v6_inbound_md5_hash(const struct sock *sk, const struct sk_buff *skb, - int dif, int sdif) + int dif, int sdif, + enum skb_drop_reason *reason) { #ifdef CONFIG_TCP_MD5SIG const __u8 *hash_location = NULL; @@ -798,11 +799,13 @@ static bool tcp_v6_inbound_md5_hash(const struct sock *sk, return false; if (hash_expected && !hash_location) { + *reason = SKB_DROP_REASON_TCP_MD5NOTFOUND; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND); return true; } if (!hash_expected && hash_location) { + *reason = SKB_DROP_REASON_TCP_MD5UNEXPECTED; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED); return true; } @@ -813,6 +816,7 @@ static bool tcp_v6_inbound_md5_hash(const struct sock *sk, NULL, skb); if (genhash || memcmp(hash_location, newhash, 16) != 0) { + *reason = SKB_DROP_REASON_TCP_MD5FAILURE; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE); net_info_ratelimited("MD5 Hash %s for [%pI6c]:%u->[%pI6c]:%u L3 index %d\n", genhash ? "failed" : "mismatch", @@ -1681,7 +1685,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) struct sock *nsk; sk = req->rsk_listener; - if (tcp_v6_inbound_md5_hash(sk, skb, dif, sdif)) { + if (tcp_v6_inbound_md5_hash(sk, skb, dif, sdif, + &drop_reason)) { sk_drops_add(sk, skb); reqsk_put(req); goto discard_it; @@ -1752,7 +1757,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) goto discard_and_relse; } - if (tcp_v6_inbound_md5_hash(sk, skb, dif, sdif)) + if (tcp_v6_inbound_md5_hash(sk, skb, dif, sdif, &drop_reason)) goto discard_and_relse; if (tcp_filter(sk, skb)) { From patchwork Sun Feb 20 07:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752597 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 870F8C433FE for ; Sun, 20 Feb 2022 07:08:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243509AbiBTHJD (ORCPT ); Sun, 20 Feb 2022 02:09:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243464AbiBTHI6 (ORCPT ); Sun, 20 Feb 2022 02:08:58 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BAA14D9EB; Sat, 19 Feb 2022 23:08:18 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id ay3so1597197plb.1; Sat, 19 Feb 2022 23:08:18 -0800 (PST) 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=DbbNOV68vkmEiWU6Oj+oPKRTONiCzDjrU+Vk7Cw0dQ8=; b=JgxrsgWUOHSPgwJ0q6CXqNBxRDZVmHTU1BXWoi2hj6+2lAxwZQjhc6m7QKe0Imbxqu yEXyFosLOdHDsHh1stQg/duIIe5KRCjpcj0VOEQedlyNs+2mMLxqtQfy9EqQSJUT7/bM BvSWzgriaID4IdmZzq6tU6/s9Wp9VmUryqHSgKaytq3/t/h7OAuOXc4koMPEKb7RuabM 8UPs40ym6+oxzIvbA//cBOeZV4Bzha2qyLemFL0n9Rf7TK6LBYbvAWxTI2e83zrwW5NA N6l1bcQGzqxjwoaRkiIGch5UH9DKuLox07HjNGijci+q6SBDEpeve1vHDDEHvwkzWxC5 SRqA== 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=DbbNOV68vkmEiWU6Oj+oPKRTONiCzDjrU+Vk7Cw0dQ8=; b=276REIHAORg7XXA5DfoM5qyySkACvMeDTI+jND/kRbXeUiTVy9uvlI/HppSWz7cu1r iBw3FnMjhpMDkKPS1V164jxq0JGBSg66DBPUOUMZXynXQ5iGFAGhDPeWsVFVeoss2kBo XjGjOjo8I2fGMH2A0PcZsfC5wqf7uuf2rgcPlDQ9VygMFU/ys38yfY/qdYzBgSjZuucv Uh71zXRUZkmKszUkIrur9qmZw3N+H0ssgx6rCeJn+Jhzgwk+RMCbgXIhTiybhxDZgE8f +sDBlyoI4Eo4eu1YqOF+GFV2H6A6iTrbO7hX3QVxcfrqAxN9AxPmAwBG5qSP3BP0wx/Y KgEA== X-Gm-Message-State: AOAM531Dq3AaQlQGRs2irgztW/IZcg4eimDR/KMcKl9kDX0rctkXpjFQ wtzlGZnUdEYMvQTtCMYZUGU= X-Google-Smtp-Source: ABdhPJw+dEz+p4UjR4z3rPqMMgAa4JKkZ8oscraFHe9EL9sZd7lnuct9SfYUJayY3bIBX8K12JVUtA== X-Received: by 2002:a17:90a:ab08:b0:1b9:c59:82c3 with SMTP id m8-20020a17090aab0800b001b90c5982c3mr20071502pjq.95.1645340897917; Sat, 19 Feb 2022 23:08:17 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:08:17 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 5/9] net: tcp: add skb drop reasons to tcp_add_backlog() Date: Sun, 20 Feb 2022 15:06:33 +0800 Message-Id: <20220220070637.162720-6-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Pass the address of drop_reason to tcp_add_backlog() to store the reasons for skb drops when fails. Following drop reasons are introduced: SKB_DROP_REASON_SOCKET_BACKLOG Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- include/linux/skbuff.h | 4 ++++ include/net/tcp.h | 3 ++- include/trace/events/skb.h | 1 + net/ipv4/tcp_ipv4.c | 7 +++++-- net/ipv6/tcp_ipv6.c | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 46678eb587ff..f7f33c79945b 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -358,6 +358,10 @@ enum skb_drop_reason { * corresponding to * LINUX_MIB_TCPMD5FAILURE */ + SKB_DROP_REASON_SOCKET_BACKLOG, /* failed to add skb to socket + * backlog (see + * LINUX_MIB_TCPBACKLOGDROP) + */ SKB_DROP_REASON_MAX, }; diff --git a/include/net/tcp.h b/include/net/tcp.h index eff2487d972d..04f4650e0ff0 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1367,7 +1367,8 @@ static inline bool tcp_checksum_complete(struct sk_buff *skb) __skb_checksum_complete(skb); } -bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb); +bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb, + enum skb_drop_reason *reason); #ifdef CONFIG_INET void __sk_defer_free_flush(struct sock *sk); diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 46c06b0be850..bfccd77e9071 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -31,6 +31,7 @@ EM(SKB_DROP_REASON_TCP_MD5UNEXPECTED, \ TCP_MD5UNEXPECTED) \ EM(SKB_DROP_REASON_TCP_MD5FAILURE, TCP_MD5FAILURE) \ + EM(SKB_DROP_REASON_SOCKET_BACKLOG, SOCKET_BACKLOG) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index d3c417119057..cbca8637ba2f 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1811,7 +1811,8 @@ int tcp_v4_early_demux(struct sk_buff *skb) return 0; } -bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) +bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb, + enum skb_drop_reason *reason) { u32 limit, tail_gso_size, tail_gso_segs; struct skb_shared_info *shinfo; @@ -1837,6 +1838,7 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) if (unlikely(tcp_checksum_complete(skb))) { bh_unlock_sock(sk); trace_tcp_bad_csum(skb); + *reason = SKB_DROP_REASON_TCP_CSUM; __TCP_INC_STATS(sock_net(sk), TCP_MIB_CSUMERRORS); __TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS); return true; @@ -1925,6 +1927,7 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) if (unlikely(sk_add_backlog(sk, skb, limit))) { bh_unlock_sock(sk); + *reason = SKB_DROP_REASON_SOCKET_BACKLOG; __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP); return true; } @@ -2133,7 +2136,7 @@ int tcp_v4_rcv(struct sk_buff *skb) if (!sock_owned_by_user(sk)) { ret = tcp_v4_do_rcv(sk, skb); } else { - if (tcp_add_backlog(sk, skb)) + if (tcp_add_backlog(sk, skb, &drop_reason)) goto discard_and_relse; } bh_unlock_sock(sk); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 1262b790b146..abf0ad547858 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1784,7 +1784,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) if (!sock_owned_by_user(sk)) { ret = tcp_v6_do_rcv(sk, skb); } else { - if (tcp_add_backlog(sk, skb)) + if (tcp_add_backlog(sk, skb, &drop_reason)) goto discard_and_relse; } bh_unlock_sock(sk); From patchwork Sun Feb 20 07:06:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752598 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC3A1C433EF for ; Sun, 20 Feb 2022 07:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243457AbiBTHJH (ORCPT ); Sun, 20 Feb 2022 02:09:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243481AbiBTHJA (ORCPT ); Sun, 20 Feb 2022 02:09:00 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 604AA4DF5E; Sat, 19 Feb 2022 23:08:25 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id j10-20020a17090a94ca00b001bc2a9596f6so554886pjw.5; Sat, 19 Feb 2022 23:08:25 -0800 (PST) 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=QPZoWV1SKW4iKxyXPzKvu7NeooPUoHjyNJIyJ7KsDy0=; b=j1Ycl3l7ax1SCuYlRD0hZNQwYMt1gZ2i7EbZ4o/xpXHbGTeYlbSuzkrZpqaezxF26a yMn1DG4+Fyt1x67BTLBtDGkoezn/wlX3gI4epYVoj+4kKsx0Fq9GoS9v6l4OSNMtHkNM Nrz1hfVd9zqMajqlI/Yr2lz8CocheR0fEw67/XxdPwQxCLc3vjYV5M6ihi9KOZsNhjcP caeueyqfSyRO64CW1FzA8pKceNq9qw2IMdIQmMXar4NVo3wRodvGrc/cbswylzLElF8p 6x+NumebyngS3aEmVPq13tmrsmjFHe3mRwHQ2Ogyf4tspKRZOyGpwW+hhSohp2EBJFqR uYlw== 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=QPZoWV1SKW4iKxyXPzKvu7NeooPUoHjyNJIyJ7KsDy0=; b=rD9nhQSPPpWfXSNZuvGUMQFyJS4pKfXgBOORIo7/WyYVXQqmifZ7YHZCim3vBRfPBo MKeW+va5/MJj4sZOtJhQ/veUSV0yxsaOB2yu8BMlRnsMQng6OPF1d5chTK+H10gDzoKp gFkDuC+aBoYnitNe3r2TRSrGcC5+CD9hnT19TbAGFxmH4woNUDK8PWECbH+pNo2afFKX 0sBD5kA9D6FyFcpzPI5C89843sIZu8nUFaOpS0ktV4MmH1wdiRU3Izq46xc5WRxxMPXq 7dA1g3zBVCp50v/Sj76A+kFmvtLrF2txqUKKTuflfU4pG0mMUJ8KfFNa48Ic7gIqnZ+v KKHA== X-Gm-Message-State: AOAM530P0qjEwW012qRvx0DOSKZHVr1eK4VqfAtAwBgO6NwD0u8aojxc vhtTcJFzXa0YdH4ANxdfhjg= X-Google-Smtp-Source: ABdhPJzspKnbl5A1pgj9ocX4cj94uj4n/en/TEZjjDavnyMt3x9k0kxQqbt++lhtrmCyj+gKjpdGoA== X-Received: by 2002:a17:90b:1e11:b0:1b9:d23:bc3c with SMTP id pg17-20020a17090b1e1100b001b90d23bc3cmr20012492pjb.77.1645340904943; Sat, 19 Feb 2022 23:08:24 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:08:24 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 6/9] net: tcp: use kfree_skb_reason() for tcp_v{4,6}_do_rcv() Date: Sun, 20 Feb 2022 15:06:34 +0800 Message-Id: <20220220070637.162720-7-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace kfree_skb() used in tcp_v4_do_rcv() and tcp_v6_do_rcv() with kfree_skb_reason(). Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- v2: - init 'reason' properly in tcp_v6_do_rcv() --- net/ipv4/tcp_ipv4.c | 5 ++++- net/ipv6/tcp_ipv6.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index cbca8637ba2f..d42824aedc36 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1708,6 +1708,7 @@ INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *, */ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) { + enum skb_drop_reason reason; struct sock *rsk; if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ @@ -1730,6 +1731,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) return 0; } + reason = SKB_DROP_REASON_NOT_SPECIFIED; if (tcp_checksum_complete(skb)) goto csum_err; @@ -1757,7 +1759,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) reset: tcp_v4_send_reset(rsk, skb); discard: - kfree_skb(skb); + kfree_skb_reason(skb, reason); /* Be careful here. If this function gets more complicated and * gcc suffers from register pressure on the x86, sk (in %ebx) * might be destroyed here. This current version compiles correctly, @@ -1766,6 +1768,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) return 0; csum_err: + reason = SKB_DROP_REASON_TCP_CSUM; trace_tcp_bad_csum(skb); TCP_INC_STATS(sock_net(sk), TCP_MIB_CSUMERRORS); TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index abf0ad547858..91cee8010285 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1476,6 +1476,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) { struct ipv6_pinfo *np = tcp_inet6_sk(sk); struct sk_buff *opt_skb = NULL; + enum skb_drop_reason reason; struct tcp_sock *tp; /* Imagine: socket is IPv6. IPv4 packet arrives, @@ -1510,6 +1511,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) if (np->rxopt.all) opt_skb = skb_clone(skb, sk_gfp_mask(sk, GFP_ATOMIC)); + reason = SKB_DROP_REASON_NOT_SPECIFIED; if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ struct dst_entry *dst; @@ -1563,9 +1565,10 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) discard: if (opt_skb) __kfree_skb(opt_skb); - kfree_skb(skb); + kfree_skb_reason(skb, reason); return 0; csum_err: + reason = SKB_DROP_REASON_TCP_CSUM; trace_tcp_bad_csum(skb); TCP_INC_STATS(sock_net(sk), TCP_MIB_CSUMERRORS); TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS); From patchwork Sun Feb 20 07:06:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752599 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDA02C433EF for ; Sun, 20 Feb 2022 07:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243483AbiBTHJJ (ORCPT ); Sun, 20 Feb 2022 02:09:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243512AbiBTHJE (ORCPT ); Sun, 20 Feb 2022 02:09:04 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6917B55499; Sat, 19 Feb 2022 23:08:32 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id 75so11537597pgb.4; Sat, 19 Feb 2022 23:08:32 -0800 (PST) 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=9Rso53u3lwifpD1f+9rlf58ETpRb1/NXtpda3rm+9ro=; b=DrYu/2vGN/cz2HQ3ThVdBXdR5zlZ/triJpgBZW9glj87iJnKKNKOqtU+FQoLIg3Up6 qGmMXpqtthvga/ZbKb4rs5AYhh7+lQSn5HBu2rsUCLUTqq4Elip8JQYX5hHL1RSKgXZw VPr+2A5ZFJ7IU+zbvEcTd/OiFPeDs+gkC/A0X7F9S+3TmgbT20eSD8BJ9q09nOFdMlac OrvHY7+HCGnyZ0siee3+CPf2mT/yA4oN9GK6cnl13Rc1DtWpgNhveAUBegdRT9KMS3xY pe1xPM8wyq6ffSUYv+1hbY/D4UxHuUFZvEIVi30uHg+3ZdSD3kyxXJEROR957At6f5JQ AElg== 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=9Rso53u3lwifpD1f+9rlf58ETpRb1/NXtpda3rm+9ro=; b=ZPyh3CfRfEMWkFf5LmAsgz/ZxpDeJN+63QC187xvOdWba14IRBDXLmLPV0UcX4ipY3 44zO4GRT3oyd6da8dDzuo9oiH2+2S07KuAIedKhQB4TQOVnMWZ79uy7bnlx9Wm4yrqPO 1wuuw37hLUjG/dWlRVb/mT5XlNFNRMWMUXhS4/+4Pk8z+GMtredONhlSwSGC6BVQi8Fy vb8yheio3uaCjWmkvc3Adb3c07OA5t3TFe8k7mEfyzUBR96UZuON/aRlrh+92T+Z7FdT fz3gcY9c14z9l/3AucK9r229dofn3pfeobLIKk2njwbfY0/GKBeLKJJei9RSNJOftdVa H1/A== X-Gm-Message-State: AOAM530JopVK3I9/dYVd/ICUFJLMj+Nnbjz7OD9UevhzLobUFdYXULjS 9XUe2P1hsBqw9FllIZTCozM= X-Google-Smtp-Source: ABdhPJz7Npz9xUYfeqYjhQnyu+jq2XiIxpzttji/ZprmbKrHablxHcizfHcBVRh6VlwSn04IhxuCyw== X-Received: by 2002:aa7:8890:0:b0:4e1:b25b:634c with SMTP id z16-20020aa78890000000b004e1b25b634cmr15181326pfe.31.1645340911972; Sat, 19 Feb 2022 23:08:31 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:08:31 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 7/9] net: tcp: use tcp_drop_reason() for tcp_rcv_established() Date: Sun, 20 Feb 2022 15:06:35 +0800 Message-Id: <20220220070637.162720-8-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace tcp_drop() used in tcp_rcv_established() with tcp_drop_reason(). Following drop reasons are added: SKB_DROP_REASON_TCP_FLAGS Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- include/linux/skbuff.h | 1 + include/trace/events/skb.h | 1 + net/ipv4/tcp_input.c | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index f7f33c79945b..671db9f49efe 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -362,6 +362,7 @@ enum skb_drop_reason { * backlog (see * LINUX_MIB_TCPBACKLOGDROP) */ + SKB_DROP_REASON_TCP_FLAGS, /* TCP flags invalid */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index bfccd77e9071..d332e7313a61 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -32,6 +32,7 @@ TCP_MD5UNEXPECTED) \ EM(SKB_DROP_REASON_TCP_MD5FAILURE, TCP_MD5FAILURE) \ EM(SKB_DROP_REASON_SOCKET_BACKLOG, SOCKET_BACKLOG) \ + EM(SKB_DROP_REASON_TCP_FLAGS, TCP_FLAGS) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 2bcbefa4322a..1899388e384a 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -5787,6 +5787,7 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, */ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) { + enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED; const struct tcphdr *th = (const struct tcphdr *)skb->data; struct tcp_sock *tp = tcp_sk(sk); unsigned int len = skb->len; @@ -5875,6 +5876,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) tp->rcv_rtt_last_tsecr = tp->rx_opt.rcv_tsecr; return; } else { /* Header too small */ + reason = SKB_DROP_REASON_PKT_TOO_SMALL; TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS); goto discard; } @@ -5930,8 +5932,10 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) if (len < (th->doff << 2) || tcp_checksum_complete(skb)) goto csum_error; - if (!th->ack && !th->rst && !th->syn) + if (!th->ack && !th->rst && !th->syn) { + reason = SKB_DROP_REASON_TCP_FLAGS; goto discard; + } /* * Standard slow path. @@ -5957,12 +5961,13 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb) return; csum_error: + reason = SKB_DROP_REASON_TCP_CSUM; trace_tcp_bad_csum(skb); TCP_INC_STATS(sock_net(sk), TCP_MIB_CSUMERRORS); TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS); discard: - tcp_drop(sk, skb); + tcp_drop_reason(sk, skb, reason); } EXPORT_SYMBOL(tcp_rcv_established); From patchwork Sun Feb 20 07:06:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752600 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F2FFC4332F for ; Sun, 20 Feb 2022 07:08:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243516AbiBTHJO (ORCPT ); Sun, 20 Feb 2022 02:09:14 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243523AbiBTHJE (ORCPT ); Sun, 20 Feb 2022 02:09:04 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60BB4D9C8; Sat, 19 Feb 2022 23:08:39 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id 4so1819864pll.6; Sat, 19 Feb 2022 23:08:39 -0800 (PST) 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=tLcjqdaR2l8lmDXCX6gb5BhKcZZd39bYSYKHEtq/KYM=; b=i1c3fTsgGE+FHDZjqHZ+5YOn3UjgNNdWfzxqx/aDCj1QNxRR1H1RfMOQmJu8Vyrw+i VtH4KcJxqA4NcBx2F4HPFzhdqGyrnDvJeXODSLm2xqNSrQrRNAkFNqN3ppko/iKwQQWO V5/Keh+Uu4dRy0YaFiOIE2D9+dpfdqxHXRvPhZ6+R87IL5s4ZapNzJWBDZlNF4WgHTC6 FwgACyvHqHOMyUDMgb0Q4UeIzfAy6GBiFtRsbRQg+VA1g6uG8Aod//dZQlWEtZQJgQDv 9cbXFNe6Fevi0Ck5Dgd3VvqXpUQsXs8Hiw3puxaIlACHyjAatxUSXAJlqMvTYgThPVAM wKPQ== 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=tLcjqdaR2l8lmDXCX6gb5BhKcZZd39bYSYKHEtq/KYM=; b=0kfVNmxe5KH3ol5aEX2QLl+wvV39GpIN5Wjs/H0I1vPWzOM3Tp3Bz0DUuEZpxUDF+g 4/l4JmLEmF4bXcJStV9X6oVnYieJG8MK0AXhjUzIaWXDwYSwY1IuUDpiEoIKRSuu5bIR WFiBLu6wFYArQSpC5W95b5PQfKwBS5aXIESAG65CKPKKRCxTjF5W2dp123agaNOjThJh CKrZ0YJHzpBzUo/1pABtRqUXW6P8LK7gHZJjNNmx3C0m8xYOwO1DwrxrjTdgoaa3F3v3 woBooylBtkD4fcOq7oKI+Cw7mEq/nHniUOOb6TqXIMGxaFyepATEoARNNyw6dfCpZaLw R7qQ== X-Gm-Message-State: AOAM53054fmch95l3nvUbEH9yiV4Bsmd6I6MdTD5GnurKGn5AkjKjUqr hITYgp+paqU8DkXYFC/u+pw= X-Google-Smtp-Source: ABdhPJy5DPP0HqKijpnbg5EQ1LoX0/Mgyq17VwxwCJr5wAFEylc26pXW3i0CLyuaPeniSi1zpsmowg== X-Received: by 2002:a17:90a:12c9:b0:1bc:1b9e:ea37 with SMTP id b9-20020a17090a12c900b001bc1b9eea37mr2938352pjg.65.1645340919112; Sat, 19 Feb 2022 23:08:39 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:08:38 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 8/9] net: tcp: use tcp_drop_reason() for tcp_data_queue() Date: Sun, 20 Feb 2022 15:06:36 +0800 Message-Id: <20220220070637.162720-9-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace tcp_drop() used in tcp_data_queue() with tcp_drop_reason(). Following drop reasons are introduced: SKB_DROP_REASON_TCP_ZEROWINDOW SKB_DROP_REASON_TCP_OLD_DATA SKB_DROP_REASON_TCP_OVERWINDOW SKB_DROP_REASON_TCP_OLD_DATA is used for the case that end_seq of skb less than the left edges of receive window. (Maybe there is a better name?) Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- include/linux/skbuff.h | 13 +++++++++++++ include/trace/events/skb.h | 3 +++ net/ipv4/tcp_input.c | 13 +++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 671db9f49efe..554ef2c848ee 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -363,6 +363,19 @@ enum skb_drop_reason { * LINUX_MIB_TCPBACKLOGDROP) */ SKB_DROP_REASON_TCP_FLAGS, /* TCP flags invalid */ + SKB_DROP_REASON_TCP_ZEROWINDOW, /* TCP receive window size is zero, + * see LINUX_MIB_TCPZEROWINDOWDROP + */ + SKB_DROP_REASON_TCP_OLD_DATA, /* the TCP data reveived is already + * received before (spurious retrans + * may happened), see + * LINUX_MIB_DELAYEDACKLOST + */ + SKB_DROP_REASON_TCP_OVERWINDOW, /* the TCP data is out of window, + * the seq of the first byte exceed + * the right edges of receive + * window + */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index d332e7313a61..cc1c8f7eaf72 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -33,6 +33,9 @@ EM(SKB_DROP_REASON_TCP_MD5FAILURE, TCP_MD5FAILURE) \ EM(SKB_DROP_REASON_SOCKET_BACKLOG, SOCKET_BACKLOG) \ EM(SKB_DROP_REASON_TCP_FLAGS, TCP_FLAGS) \ + EM(SKB_DROP_REASON_TCP_ZEROWINDOW, TCP_ZEROWINDOW) \ + EM(SKB_DROP_REASON_TCP_OLD_DATA, TCP_OLD_DATA) \ + EM(SKB_DROP_REASON_TCP_OVERWINDOW, TCP_OVERWINDOW) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 1899388e384a..4da636aa9282 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4988,6 +4988,7 @@ void tcp_data_ready(struct sock *sk) static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); + enum skb_drop_reason reason; bool fragstolen; int eaten; @@ -5006,6 +5007,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) skb_dst_drop(skb); __skb_pull(skb, tcp_hdr(skb)->doff * 4); + reason = SKB_DROP_REASON_NOT_SPECIFIED; tp->rx_opt.dsack = 0; /* Queue data for delivery to the user. @@ -5014,6 +5016,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) */ if (TCP_SKB_CB(skb)->seq == tp->rcv_nxt) { if (tcp_receive_window(tp) == 0) { + reason = SKB_DROP_REASON_TCP_ZEROWINDOW; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPZEROWINDOWDROP); goto out_of_window; } @@ -5023,6 +5026,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) if (skb_queue_len(&sk->sk_receive_queue) == 0) sk_forced_mem_schedule(sk, skb->truesize); else if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { + reason = SKB_DROP_REASON_PROTO_MEM; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP); sk->sk_data_ready(sk); goto drop; @@ -5059,6 +5063,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) if (!after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt)) { tcp_rcv_spurious_retrans(sk, skb); /* A retransmit, 2nd most common case. Force an immediate ack. */ + reason = SKB_DROP_REASON_TCP_OLD_DATA; NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKLOST); tcp_dsack_set(sk, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq); @@ -5066,13 +5071,16 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS); inet_csk_schedule_ack(sk); drop: - tcp_drop(sk, skb); + tcp_drop_reason(sk, skb, reason); return; } /* Out of window. F.e. zero window probe. */ - if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt + tcp_receive_window(tp))) + if (!before(TCP_SKB_CB(skb)->seq, + tp->rcv_nxt + tcp_receive_window(tp))) { + reason = SKB_DROP_REASON_TCP_OVERWINDOW; goto out_of_window; + } if (before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) { /* Partial packet, seq < rcv_next < end_seq */ @@ -5082,6 +5090,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) * remembering D-SACK for its head made in previous line. */ if (!tcp_receive_window(tp)) { + reason = SKB_DROP_REASON_TCP_ZEROWINDOW; NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPZEROWINDOWDROP); goto out_of_window; } From patchwork Sun Feb 20 07:06:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12752601 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3063EC433FE for ; Sun, 20 Feb 2022 07:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243586AbiBTHJh (ORCPT ); Sun, 20 Feb 2022 02:09:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243443AbiBTHJH (ORCPT ); Sun, 20 Feb 2022 02:09:07 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B843A4D9EB; Sat, 19 Feb 2022 23:08:46 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id 12so7978775pgd.0; Sat, 19 Feb 2022 23:08:46 -0800 (PST) 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=XJ39oTdHw30Rs1eV+6bRzBftzJyi2esQlImZGRiJ6OY=; b=ger11xmyvB1IycXNx0x2jaxHbAZdUN5ZIuftitPOlIt/gNqHcMCh3/8477+tRltGMy Njr+CyRG6cAMiCydj26116yp0/l56bkrujMGlqz+egRxjJv033T5Jek8GKGiKZdrip+B pPJf0xrxL4zFpo1GVTFYzq9aHOe6ghE/T4zcdXXW40hzD0jaCD2azw7W45Ibb9+WuAAX 39fBHAyKbp+mUhOCRCSyA5uWvwT14dgau1fE8Ng8ouAaK9jd2p9ffDlkyuaOM4y4f3P9 p74+ftajA5pRYNdN00DZdUew7CwtJsCOCckiKxWj9jyHIKt4ECn2etnuq/dQEAUimBJl pjtw== 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=XJ39oTdHw30Rs1eV+6bRzBftzJyi2esQlImZGRiJ6OY=; b=SMvilKhV6wpYKbgrz44rx01ms/xpDYqLrl7OqvoOdSoi0i2hnumwFCViXGeuRnkxMD Zcg27u+oYuHM9g3dO1j+TBnbJMWHedY6IeMex6NfKM/0ZpKn9DEtIMHhcqPfOegyj1bp liCbCcDTa4EphR76dlI0wpuHUrpewWmYOqR0WXCAMUBQs4/HUjFw2CjAoTM/PHlpqwJJ ZfWEwL8Y1XlfJNAyC7aDg5u5edN+0p9xJvT0Z+Ib1Jq19oEx27E3H6hCi2l1E2obsMNv wucS/jWIdSfe+Bzhc+2tojBLqjBJzC1XjH5X2eGcBDVAsvWITTVDNvlZu1fMYxYiksxE 2ZBQ== X-Gm-Message-State: AOAM533RNQaz17CbaE3JYWnK91vsRNXcsOtC8pC8rReVb1qOXB79Qnnk 4KgWF7RSFjWI/HrIk0+TCmc= X-Google-Smtp-Source: ABdhPJyPSa2up5yX8s7plzb+RE2ck9N9uBEzzJ53XXLH1HkzixnoSE1/4CpZiBlNEThszSJOC7bO8A== X-Received: by 2002:a65:52cc:0:b0:374:3ee6:c632 with SMTP id z12-20020a6552cc000000b003743ee6c632mr373131pgp.91.1645340926221; Sat, 19 Feb 2022 23:08:46 -0800 (PST) Received: from localhost.localdomain ([203.205.141.114]) by smtp.gmail.com with ESMTPSA id p1sm8351326pfo.212.2022.02.19.23.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 23:08:45 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: edumazet@google.com, davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, yoshfuji@linux-ipv6.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, memxor@gmail.com, atenart@kernel.org, bigeasy@linutronix.de, pabeni@redhat.com, linyunsheng@huawei.com, arnd@arndb.de, yajun.deng@linux.dev, roopa@nvidia.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, luiz.von.dentz@intel.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, flyingpeng@tencent.com, mengensun@tencent.com Subject: [PATCH net-next v3 9/9] net: tcp: use tcp_drop_reason() for tcp_data_queue_ofo() Date: Sun, 20 Feb 2022 15:06:37 +0800 Message-Id: <20220220070637.162720-10-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220220070637.162720-1-imagedong@tencent.com> References: <20220220070637.162720-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace tcp_drop() used in tcp_data_queue_ofo with tcp_drop_reason(). Following drop reasons are introduced: SKB_DROP_REASON_TCP_OFOMERGE Reviewed-by: Mengen Sun Reviewed-by: Hao Peng Signed-off-by: Menglong Dong Reviewed-by: Eric Dumazet Reviewed-by: David Ahern --- include/linux/skbuff.h | 4 ++++ include/trace/events/skb.h | 1 + net/ipv4/tcp_input.c | 10 ++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 554ef2c848ee..a3e90efe6586 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -376,6 +376,10 @@ enum skb_drop_reason { * the right edges of receive * window */ + SKB_DROP_REASON_TCP_OFOMERGE, /* the data of skb is already in + * the ofo queue, corresponding to + * LINUX_MIB_TCPOFOMERGE + */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index cc1c8f7eaf72..2ab7193313aa 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -36,6 +36,7 @@ EM(SKB_DROP_REASON_TCP_ZEROWINDOW, TCP_ZEROWINDOW) \ EM(SKB_DROP_REASON_TCP_OLD_DATA, TCP_OLD_DATA) \ EM(SKB_DROP_REASON_TCP_OVERWINDOW, TCP_OVERWINDOW) \ + EM(SKB_DROP_REASON_TCP_OFOMERGE, TCP_OFOMERGE) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 4da636aa9282..d3d7a7bef463 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4779,7 +4779,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) { NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP); sk->sk_data_ready(sk); - tcp_drop(sk, skb); + tcp_drop_reason(sk, skb, SKB_DROP_REASON_PROTO_MEM); return; } @@ -4842,7 +4842,8 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) /* All the bits are present. Drop. */ NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFOMERGE); - tcp_drop(sk, skb); + tcp_drop_reason(sk, skb, + SKB_DROP_REASON_TCP_OFOMERGE); skb = NULL; tcp_dsack_set(sk, seq, end_seq); goto add_sack; @@ -4861,7 +4862,8 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) TCP_SKB_CB(skb1)->end_seq); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFOMERGE); - tcp_drop(sk, skb1); + tcp_drop_reason(sk, skb1, + SKB_DROP_REASON_TCP_OFOMERGE); goto merge_right; } } else if (tcp_ooo_try_coalesce(sk, skb1, @@ -4889,7 +4891,7 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq, TCP_SKB_CB(skb1)->end_seq); NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFOMERGE); - tcp_drop(sk, skb1); + tcp_drop_reason(sk, skb1, SKB_DROP_REASON_TCP_OFOMERGE); } /* If there is no skb after us, we are the last_skb ! */ if (!skb1)