From patchwork Fri Oct 28 13:30:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13023622 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 2E971C38A02 for ; Fri, 28 Oct 2022 13:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230526AbiJ1NbG (ORCPT ); Fri, 28 Oct 2022 09:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230489AbiJ1Naw (ORCPT ); Fri, 28 Oct 2022 09:30:52 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F31E099B for ; Fri, 28 Oct 2022 06:30:50 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-368e6c449f2so44047977b3.5 for ; Fri, 28 Oct 2022 06:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mAhikDCYsTVoykDfFXufN3qfUUCZU6VugouuIlfHJYM=; b=reTALZZtmpImpkSoaPsgD1wZmofRxe7ov7ejP58f5tD82GU6aQQV4STXPFUZBsC5TE ncwU7bSL2hOHQGEfm8lpCtCTvQyd25uIO+WN7Hm92Z9dSRHVbEo992mEUhHf4lOQPjBy el7JpNNpw8hPBAQj10dVzRN2/dB2Exrjr12S5baYcwPp9Dy0w9qu7g6v+6zakhKN63ue BYRr77iJBDvQbIG6U/UQtvpnkXjSlHAAjgBoEFYYpmV+2Ori9VV6Ivsj6hnpFQnyW/kT pQ4zHCvuQucB7X0Vj7/HDGHsBhniLlEbEw5HzUh+0QklEbkb3RiQPjLHlIx7y8ZvE4xI HgYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mAhikDCYsTVoykDfFXufN3qfUUCZU6VugouuIlfHJYM=; b=I9h/kIEtBokPR1AH3A0gHCa/6WsVIgINCczugqkNb9cyogKCt2azmrLIvnv/5aJms1 MhlZfC8bgVrDGJsyC+3np8r0GAVaqatspcWB03vvs7XiQ9h5JM9/mMmbdxu7n48gcujo S27pzJ9D3dOdDDTtbet+rdATIpqhSRmNw6O7KFb9sEESQ5T4oqainLYHedxW3WssgE4X aHkPqm5qjGl730lAYBgdi04Qli40Mur6YnuTXrvQHAXgSf7iHYEYvXpRkYT4O4o4azq7 q9A2wzag/l94J3aZeTZrbuAkKDF2jdPTzx1o9OBBOshPXHdeiEG4M5e9f8eUEsUQr9Jp Qi1w== X-Gm-Message-State: ACrzQf3fNa1kl4NNI+4tWDFNgqZwUoHWbe5X72rV06XE1HRNUV/N9CFB R6pzTSxvofnTRF11X4cnj71TP+cpNuy+IA== X-Google-Smtp-Source: AMsMyM6gmsYqn6MFSKfmtL+zAYsveJLsAOCIaiITrlN4k1b2ZFt3u6kD9owZab8CpHaJFViYLZZhVutwRx5xSA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a25:9b47:0:b0:6bd:1f01:774f with SMTP id u7-20020a259b47000000b006bd1f01774fmr1ybo.602.1666963849536; Fri, 28 Oct 2022 06:30:49 -0700 (PDT) Date: Fri, 28 Oct 2022 13:30:39 +0000 In-Reply-To: <20221028133043.2312984-1-edumazet@google.com> Mime-Version: 1.0 References: <20221028133043.2312984-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221028133043.2312984-2-edumazet@google.com> Subject: [PATCH net-next 1/5] net: dropreason: add SKB_CONSUMED reason From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This will allow to simply use in the future: kfree_skb_reason(skb, reason); Instead of repeating sequences like: if (dropped) kfree_skb_reason(skb, reason); else consume_skb(skb); For instance, following patch in the series is adding @reason to skb_release_data() and skb_release_all(), so that we can propagate a meaningful @reason whenever consume_skb()/kfree_skb() have to take care of a potential frag_list. Signed-off-by: Eric Dumazet --- include/net/dropreason.h | 2 ++ net/core/skbuff.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index c1cbcdbaf1492c6bd5a18b9af0a0e0beb071c674..0bd18c14dae0a570a150c31eeea99fe85bc734b0 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -80,6 +80,8 @@ enum skb_drop_reason { * @SKB_NOT_DROPPED_YET: skb is not dropped yet (used for no-drop case) */ SKB_NOT_DROPPED_YET = 0, + /** @SKB_CONSUMED: packet has been consumed */ + SKB_CONSUMED, /** @SKB_DROP_REASON_NOT_SPECIFIED: drop reason is not specified */ SKB_DROP_REASON_NOT_SPECIFIED, /** @SKB_DROP_REASON_NO_SOCKET: socket not found */ diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 1d84a17eada502cf0f650d261cc7de5f020afb63..7ce797cd121f395062b61b33371fb638f51e8c99 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -94,6 +94,7 @@ EXPORT_SYMBOL(sysctl_max_skb_frags); #undef FN #define FN(reason) [SKB_DROP_REASON_##reason] = #reason, const char * const drop_reasons[] = { + [SKB_CONSUMED] = "CONSUMED", DEFINE_DROP_REASON(FN, FN) }; EXPORT_SYMBOL(drop_reasons); @@ -894,7 +895,10 @@ kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) DEBUG_NET_WARN_ON_ONCE(reason <= 0 || reason >= SKB_DROP_REASON_MAX); - trace_kfree_skb(skb, __builtin_return_address(0), reason); + if (reason == SKB_CONSUMED) + trace_consume_skb(skb); + else + trace_kfree_skb(skb, __builtin_return_address(0), reason); __kfree_skb(skb); } EXPORT_SYMBOL(kfree_skb_reason); From patchwork Fri Oct 28 13:30:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13023623 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 7FCDEFA3741 for ; Fri, 28 Oct 2022 13:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbiJ1NbT (ORCPT ); Fri, 28 Oct 2022 09:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230502AbiJ1Nay (ORCPT ); Fri, 28 Oct 2022 09:30:54 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42EC106E16 for ; Fri, 28 Oct 2022 06:30:52 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-368e6c449f2so44048477b3.5 for ; Fri, 28 Oct 2022 06:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xf1IqAkHnBlgERzJ+GODqp6iHzNJM3F35pgHGdmZlvk=; b=qRiQu9W8EnDhl8bvngjDr1Gu6Lodccpbx+k94I9pHjNqgzTRiCmWDzoS5ksofOLL2a nkbq+HXMlbLQPdYu8Xbg4ebpEkzfL0zqW0CR6oD8rqZkFGppoCp7e8b9ejWPS2zs7zZt FxGEhj2KL97UfLqgUdmyQQhObF6UbYpvSxX3nmNnxWTHqakcCJ4K5iWj4KWqSlI8XWMM Qr9+TVShkj0LgPZhMGnhJchhBRZ3iGQvPWyn/BdVgUcRqtMhHEoM6wiOVj1fxv+OJnKP TNBPg8xTdICj+B/XI+cMr/R38eODxM+XcIY0n22BEf88gviTCvQnxOPQfn1X8IuhSIc1 3rjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xf1IqAkHnBlgERzJ+GODqp6iHzNJM3F35pgHGdmZlvk=; b=edYoxbtzYQu7c7XqngK6RsTSEoUwkkoLf4iDKL9vUwCnSrw3QTXNRv+El5TDHgwVR5 zFJd9FF+OJEBZYS3MqN6q07gGsTjmzdSPBUxlptCkLNzQkH2MnhM70elmukfR7v8N/Wg smgVUyq0RXEgyin+p3pcugb3H1ygT03c+ichWtX7v++PZUs3hjNVUS0JxlpDCgLL5+tE 6aii49d1Yw9TuSgm4CSx1Ej9dKUXLVkHXxPphLsOvyTb/fUH+U2nyxg8PewHH20FX/aD IQDPj8AByp7wZHEWyJSRxbYzBIIesNEDLCzEsEZ3MRe2HXpkN02OSzSYO09I3QBYYkYu U1bw== X-Gm-Message-State: ACrzQf2GA7elUqhpnyjqiGl38O4nUYU1+LRicOvIT4tDM8kbVicfFHS8 pj25v4zCn7UbeE5GlvQheKv5z0dlTVy9fQ== X-Google-Smtp-Source: AMsMyM7c/BI5fIYpdi5z9pes6uUeNH+HQkdV8rWOlaKlUOlmPKtmdW0MVscsTB2EQvKwWGmquzXjk16H7yoMYg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a81:6187:0:b0:357:2da6:50c2 with SMTP id v129-20020a816187000000b003572da650c2mr1ywb.242.1666963851536; Fri, 28 Oct 2022 06:30:51 -0700 (PDT) Date: Fri, 28 Oct 2022 13:30:40 +0000 In-Reply-To: <20221028133043.2312984-1-edumazet@google.com> Mime-Version: 1.0 References: <20221028133043.2312984-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221028133043.2312984-3-edumazet@google.com> Subject: [PATCH net-next 2/5] net: dropreason: propagate drop_reason to skb_release_data() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When an skb with a frag list is consumed, we currently pretend all skbs in the frag list were dropped. In order to fix this, add a @reason argument to skb_release_data() and skb_release_all(). Signed-off-by: Eric Dumazet --- net/core/skbuff.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 7ce797cd121f395062b61b33371fb638f51e8c99..42a35b59fb1e54e2e4c0ab58a6da016cef622653 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -769,7 +769,7 @@ static void skb_free_head(struct sk_buff *skb) } } -static void skb_release_data(struct sk_buff *skb) +static void skb_release_data(struct sk_buff *skb, enum skb_drop_reason reason) { struct skb_shared_info *shinfo = skb_shinfo(skb); int i; @@ -792,7 +792,7 @@ static void skb_release_data(struct sk_buff *skb) free_head: if (shinfo->frag_list) - kfree_skb_list(shinfo->frag_list); + kfree_skb_list_reason(shinfo->frag_list, reason); skb_free_head(skb); exit: @@ -855,11 +855,11 @@ void skb_release_head_state(struct sk_buff *skb) } /* Free everything but the sk_buff shell. */ -static void skb_release_all(struct sk_buff *skb) +static void skb_release_all(struct sk_buff *skb, enum skb_drop_reason reason) { skb_release_head_state(skb); if (likely(skb->head)) - skb_release_data(skb); + skb_release_data(skb, reason); } /** @@ -873,7 +873,7 @@ static void skb_release_all(struct sk_buff *skb) void __kfree_skb(struct sk_buff *skb) { - skb_release_all(skb); + skb_release_all(skb, SKB_DROP_REASON_NOT_SPECIFIED); kfree_skbmem(skb); } EXPORT_SYMBOL(__kfree_skb); @@ -1056,7 +1056,7 @@ EXPORT_SYMBOL(consume_skb); void __consume_stateless_skb(struct sk_buff *skb) { trace_consume_skb(skb); - skb_release_data(skb); + skb_release_data(skb, SKB_CONSUMED); kfree_skbmem(skb); } @@ -1081,7 +1081,7 @@ static void napi_skb_cache_put(struct sk_buff *skb) void __kfree_skb_defer(struct sk_buff *skb) { - skb_release_all(skb); + skb_release_all(skb, SKB_DROP_REASON_NOT_SPECIFIED); napi_skb_cache_put(skb); } @@ -1119,7 +1119,7 @@ void napi_consume_skb(struct sk_buff *skb, int budget) return; } - skb_release_all(skb); + skb_release_all(skb, SKB_CONSUMED); napi_skb_cache_put(skb); } EXPORT_SYMBOL(napi_consume_skb); @@ -1250,7 +1250,7 @@ EXPORT_SYMBOL_GPL(alloc_skb_for_msg); */ struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src) { - skb_release_all(dst); + skb_release_all(dst, SKB_CONSUMED); return __skb_clone(dst, src); } EXPORT_SYMBOL_GPL(skb_morph); @@ -1873,7 +1873,7 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, if (skb_has_frag_list(skb)) skb_clone_fraglist(skb); - skb_release_data(skb); + skb_release_data(skb, SKB_CONSUMED); } else { skb_free_head(skb); } @@ -6213,7 +6213,7 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off, skb_frag_ref(skb, i); if (skb_has_frag_list(skb)) skb_clone_fraglist(skb); - skb_release_data(skb); + skb_release_data(skb, SKB_CONSUMED); } else { /* we can reuse existing recount- all we did was * relocate values @@ -6356,7 +6356,7 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off, kfree(data); return -ENOMEM; } - skb_release_data(skb); + skb_release_data(skb, SKB_CONSUMED); skb->head = data; skb->head_frag = 0; From patchwork Fri Oct 28 13:30:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13023624 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 46FF6FA3742 for ; Fri, 28 Oct 2022 13:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229981AbiJ1NbU (ORCPT ); Fri, 28 Oct 2022 09:31:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbiJ1Na4 (ORCPT ); Fri, 28 Oct 2022 09:30:56 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A2D397EDD for ; Fri, 28 Oct 2022 06:30:54 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id h9-20020a25e209000000b006cbc4084f2eso4510610ybe.23 for ; Fri, 28 Oct 2022 06:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CmPTSo++eaqXQRu2DaBooqOa1NSBcQeByMRnjkGhnxU=; b=l13/AdoDp6ssM2m142NqPMEEysq9+OIvW0gT3TJly6FMeKe9YYans53Vgo9g1KLYVc NL53RShl8Wbni++bOFBijnumPfYOWQwY5XpzS3A6vM94FwWRlYR+/R4QjhIH1ux3KlLn tjwIRCaNdEUC9uPFxpbXK9xplZBF1JXbQN7Gx6F0TmvtSFNDZzNy3MgPxHXIyUfjtupd GOTxpuWhkMrpYgCQ6ZQBCseqm31/kWT5kAvxs68ZsiPPygRAGNAosPPKRmnnyzidgiZ/ gJxs5EozWlWiVqWV3gC7gVuJIa3fq0ANp/ORXd7XYEhQVFs7WqISFXi7+/nyWN26EKQq Yjlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CmPTSo++eaqXQRu2DaBooqOa1NSBcQeByMRnjkGhnxU=; b=tCGfg5m762XTDGwTnRtqYrVxmCNWV8T1DE++yBb0AKTrVFfqJNhIras8DbzJrl9Ipq X8/7yCZhH3/pfcWxeX/zk+F3o04XFZEd8xHb8JW4aSu05EUbu40sj18taASXEcwfCL0E j6zDZU/Pjp7fa4ANwzxbFdPPXrfzFWuV69mpKydfyYlDaRB+fGmj83bZHV/ves2x+VZz Sv8XUa+/c7RXTty+cv3qaAo+fCMm57oNrKAwxrmAZ2BJ447fLjX17pCXxWqzMibvJGpW ilr9SPkXVwNviBfnaL5P/pwvJHLo7ESWjcTwJw42MD2Q2uQdf+D1WotQ2Nt3jnb+QSY5 tHFw== X-Gm-Message-State: ACrzQf2fRPKjEIl3TDIAH76rdWnxHbVSyKCx3k2qNNJBkbKiwEF1lyAo hnJXpCXlEjvbm5Go1mNTe5sJaw+LQWTc8A== X-Google-Smtp-Source: AMsMyM4wbXdXoEKcwZ3Qd3Ni+MBbYRF+/ks3E3lOtzJ0izKsHhmvCM6Lu23F3yg/gdeq3Yr+JW53AHj6tlrErw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a81:4e87:0:b0:368:3422:a62d with SMTP id c129-20020a814e87000000b003683422a62dmr41247871ywb.277.1666963853427; Fri, 28 Oct 2022 06:30:53 -0700 (PDT) Date: Fri, 28 Oct 2022 13:30:41 +0000 In-Reply-To: <20221028133043.2312984-1-edumazet@google.com> Mime-Version: 1.0 References: <20221028133043.2312984-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221028133043.2312984-4-edumazet@google.com> Subject: [PATCH net-next 3/5] net: dropreason: add SKB_DROP_REASON_DUP_FRAG From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This is used to track when a duplicate segment received by various reassembly units is dropped. Signed-off-by: Eric Dumazet --- include/net/dropreason.h | 3 +++ net/ipv4/ip_fragment.c | 13 +++++++++---- net/ipv6/netfilter/nf_conntrack_reasm.c | 2 +- net/ipv6/reassembly.c | 13 +++++++++---- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index 0bd18c14dae0a570a150c31eeea99fe85bc734b0..602d555a5f8392715ec03f85418ecb98926d0481 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -68,6 +68,7 @@ FN(IP_INADDRERRORS) \ FN(IP_INNOROUTES) \ FN(PKT_TOO_BIG) \ + FN(DUP_FRAG) \ FNe(MAX) /** @@ -300,6 +301,8 @@ enum skb_drop_reason { * MTU) */ SKB_DROP_REASON_PKT_TOO_BIG, + /** @SKB_DROP_REASON_DUP_FRAG: duplicate fragment */ + SKB_DROP_REASON_DUP_FRAG, /** * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * used as a real 'reason' diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index fb153569889ecc8541640674880ff03e8c7bf24f..676bd8d259555448457dfd98ce4316c4b549a30a 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -278,10 +278,14 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) struct net_device *dev; unsigned int fragsize; int err = -ENOENT; + SKB_DR(reason); u8 ecn; - if (qp->q.flags & INET_FRAG_COMPLETE) + /* If reassembly is already done, @skb must be a duplicate frag. */ + if (qp->q.flags & INET_FRAG_COMPLETE) { + SKB_DR_SET(reason, DUP_FRAG); goto err; + } if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) && unlikely(ip_frag_too_far(qp)) && @@ -382,8 +386,9 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) insert_error: if (err == IPFRAG_DUP) { - kfree_skb(skb); - return -EINVAL; + SKB_DR_SET(reason, DUP_FRAG); + err = -EINVAL; + goto err; } err = -EINVAL; __IP_INC_STATS(net, IPSTATS_MIB_REASM_OVERLAPS); @@ -391,7 +396,7 @@ static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb) inet_frag_kill(&qp->q); __IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS); err: - kfree_skb(skb); + kfree_skb_reason(skb, reason); return err; } diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 38db0064d6613a8472ec2835afdbf80071c1fcc2..d13240f13607bae8833d4e53471c575280ff49dc 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -253,7 +253,7 @@ static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb, if (err) { if (err == IPFRAG_DUP) { /* No error for duplicates, pretend they got queued. */ - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_DUP_FRAG); return -EINPROGRESS; } goto insert_error; diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index ff866f2a879e00769b273c22b970740eaebb6d99..5bc8a28e67f944c9e7bead79afa8b80a34b92db9 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -112,10 +112,14 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, struct sk_buff *prev_tail; struct net_device *dev; int err = -ENOENT; + SKB_DR(reason); u8 ecn; - if (fq->q.flags & INET_FRAG_COMPLETE) + /* If reassembly is already done, @skb must be a duplicate frag. */ + if (fq->q.flags & INET_FRAG_COMPLETE) { + SKB_DR_SET(reason, DUP_FRAG); goto err; + } err = -EINVAL; offset = ntohs(fhdr->frag_off) & ~0x7; @@ -226,8 +230,9 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, insert_error: if (err == IPFRAG_DUP) { - kfree_skb(skb); - return -EINVAL; + SKB_DR_SET(reason, DUP_FRAG); + err = -EINVAL; + goto err; } err = -EINVAL; __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), @@ -237,7 +242,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, __IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMFAILS); err: - kfree_skb(skb); + kfree_skb_reason(skb, reason); return err; } From patchwork Fri Oct 28 13:30:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13023625 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 59AD6C38A02 for ; Fri, 28 Oct 2022 13:31:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230507AbiJ1NbX (ORCPT ); Fri, 28 Oct 2022 09:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230459AbiJ1Na5 (ORCPT ); Fri, 28 Oct 2022 09:30:57 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31DCC66A4A for ; Fri, 28 Oct 2022 06:30:55 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-360a7ff46c3so44195257b3.12 for ; Fri, 28 Oct 2022 06:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6owe1CKmgnllHzx6jMCrrerT6nNaoGtvOuoB0/Alm0s=; b=QWZcCKxasWwqJhaIbGAJxxFdukFKJuY9gvNRkUfGDKuENGvT8/+Gt9DYimjLRvPRzU CNWYLhV0bo89FDj4LH7rg5VT7qvhvVS/RzlVCqrPldFhQbJKIgoiuMyQf5ELINU7BGQm QW2HbbeVopdNjACihqa9jkONZgDL5eNuGrdbm9+/JVnOdPA3MwChr8oL1I9a04f0G+3/ S2TimP6rIjcyve2YnKMJ87R2nOdaTxRKSjEF+6M9O5us/2dW+tHvDI9dCqd/Vi0572p1 0DDBzuaGyd8jdAuPF/JWXQeO9IjTiOImHAFrtfHEaME/EZwA0lzU2i9hKEeseAajJNMB I8nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6owe1CKmgnllHzx6jMCrrerT6nNaoGtvOuoB0/Alm0s=; b=3OISwDO22oTjTuzU5xicdVy0nadl6h0ddGSvsyCOK20Tg7fW5XzeYvshMmeGSXWEEo zx9aHZ73Xan9SblCdmiwUFQD3i+TigztPMue9tyytPkiy2tE+aSwtpOPStrZmM5uKt+z 04ADaePAbjBrmiYOOGDoojOicFUxlYQULoDDNPBiS1bUIU+ftyYzHNJpkuJVWLDi59E1 xbcED0l8b+ZbVMPyINYTNDCxKjBEUyf4wNyZlTsOM3a2c1h4Ej59Ci6+N0H/+vZXN1GL mNe+n+eL1qdoPJT3wy3eEvW6nb2CEwa7OyGaEFi4d4rk99r30v/TtTroj0PNrsM8Rtbx xTMg== X-Gm-Message-State: ACrzQf3/TIXcqBkzyN9KRqSvgeeSv6/nJMx33HTL6+2t7g7Bz0VpqlQt w02HXdJev2HmdspGdpJ77rbtZGgduDwr5g== X-Google-Smtp-Source: AMsMyM4AOb6Rrg31VPaXRlRsbgUJSSIS/21Aj1L+JSqkyxxFDZ8GTflBeOQdziGZENlTzJDcFXOUh13W5Iz1nw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a25:9d83:0:b0:68f:a551:ec71 with SMTP id v3-20020a259d83000000b0068fa551ec71mr50810693ybp.212.1666963855107; Fri, 28 Oct 2022 06:30:55 -0700 (PDT) Date: Fri, 28 Oct 2022 13:30:42 +0000 In-Reply-To: <20221028133043.2312984-1-edumazet@google.com> Mime-Version: 1.0 References: <20221028133043.2312984-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221028133043.2312984-5-edumazet@google.com> Subject: [PATCH net-next 4/5] net: dropreason: add SKB_DROP_REASON_FRAG_REASM_TIMEOUT From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Used to track skbs freed after a timeout happened in a reassmbly unit. Passing a @reason argument to inet_frag_rbtree_purge() allows to use correct consumed status for frags that have been successfully re-assembled. Signed-off-by: Eric Dumazet --- include/net/dropreason.h | 3 +++ include/net/inet_frag.h | 6 +++++- include/net/ipv6_frag.h | 3 ++- net/ipv4/inet_fragment.c | 14 ++++++++++---- net/ipv4/ip_fragment.c | 6 ++++-- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index 602d555a5f8392715ec03f85418ecb98926d0481..d3d44da889e4f002ed1485a10fd081184956c911 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -69,6 +69,7 @@ FN(IP_INNOROUTES) \ FN(PKT_TOO_BIG) \ FN(DUP_FRAG) \ + FN(FRAG_REASM_TIMEOUT) \ FNe(MAX) /** @@ -303,6 +304,8 @@ enum skb_drop_reason { SKB_DROP_REASON_PKT_TOO_BIG, /** @SKB_DROP_REASON_DUP_FRAG: duplicate fragment */ SKB_DROP_REASON_DUP_FRAG, + /** @FRAG_REASM_TIMEOUT: fragment reassembly timeout */ + SKB_DROP_REASON_FRAG_REASM_TIMEOUT, /** * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * used as a real 'reason' diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 0b0876610553fca80ca1ce8d53026265b316d052..b23ddec3cd5cd8303bd7dc38714c274df8a63993 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -7,6 +7,7 @@ #include #include #include +#include /* Per netns frag queues directory */ struct fqdir { @@ -34,12 +35,14 @@ struct fqdir { * @INET_FRAG_LAST_IN: final fragment has arrived * @INET_FRAG_COMPLETE: frag queue has been processed and is due for destruction * @INET_FRAG_HASH_DEAD: inet_frag_kill() has not removed fq from rhashtable + * @INET_FRAG_DROP: if skbs must be dropped (instead of being consumed) */ enum { INET_FRAG_FIRST_IN = BIT(0), INET_FRAG_LAST_IN = BIT(1), INET_FRAG_COMPLETE = BIT(2), INET_FRAG_HASH_DEAD = BIT(3), + INET_FRAG_DROP = BIT(4), }; struct frag_v4_compare_key { @@ -139,7 +142,8 @@ void inet_frag_destroy(struct inet_frag_queue *q); struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key); /* Free all skbs in the queue; return the sum of their truesizes. */ -unsigned int inet_frag_rbtree_purge(struct rb_root *root); +unsigned int inet_frag_rbtree_purge(struct rb_root *root, + enum skb_drop_reason reason); static inline void inet_frag_put(struct inet_frag_queue *q) { diff --git a/include/net/ipv6_frag.h b/include/net/ipv6_frag.h index 5052c66e22d23604e698f93cf6328ca5863e4d07..7321ffe3a108c159490ae358b8c2cfca958055a4 100644 --- a/include/net/ipv6_frag.h +++ b/include/net/ipv6_frag.h @@ -76,6 +76,7 @@ ip6frag_expire_frag_queue(struct net *net, struct frag_queue *fq) if (fq->q.flags & INET_FRAG_COMPLETE) goto out; + fq->q.flags |= INET_FRAG_DROP; inet_frag_kill(&fq->q); dev = dev_get_by_index_rcu(net, fq->iif); @@ -101,7 +102,7 @@ ip6frag_expire_frag_queue(struct net *net, struct frag_queue *fq) spin_unlock(&fq->q.lock); icmpv6_send(head, ICMPV6_TIME_EXCEED, ICMPV6_EXC_FRAGTIME, 0); - kfree_skb(head); + kfree_skb_reason(head, SKB_DROP_REASON_FRAG_REASM_TIMEOUT); goto out_rcu_unlock; out: diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index c9f9ac5013a717ddbc403c7317aaa228b09f6a0c..7072fc0783ef56e59c886a2f2516e7db7d10c942 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -133,6 +133,7 @@ static void inet_frags_free_cb(void *ptr, void *arg) count = del_timer_sync(&fq->timer) ? 1 : 0; spin_lock_bh(&fq->lock); + fq->flags |= INET_FRAG_DROP; if (!(fq->flags & INET_FRAG_COMPLETE)) { fq->flags |= INET_FRAG_COMPLETE; count++; @@ -260,7 +261,8 @@ static void inet_frag_destroy_rcu(struct rcu_head *head) kmem_cache_free(f->frags_cachep, q); } -unsigned int inet_frag_rbtree_purge(struct rb_root *root) +unsigned int inet_frag_rbtree_purge(struct rb_root *root, + enum skb_drop_reason reason) { struct rb_node *p = rb_first(root); unsigned int sum = 0; @@ -274,7 +276,7 @@ unsigned int inet_frag_rbtree_purge(struct rb_root *root) struct sk_buff *next = FRAG_CB(skb)->next_frag; sum += skb->truesize; - kfree_skb(skb); + kfree_skb_reason(skb, reason); skb = next; } } @@ -284,17 +286,21 @@ EXPORT_SYMBOL(inet_frag_rbtree_purge); void inet_frag_destroy(struct inet_frag_queue *q) { - struct fqdir *fqdir; unsigned int sum, sum_truesize = 0; + enum skb_drop_reason reason; struct inet_frags *f; + struct fqdir *fqdir; WARN_ON(!(q->flags & INET_FRAG_COMPLETE)); + reason = (q->flags & INET_FRAG_DROP) ? + SKB_DROP_REASON_FRAG_REASM_TIMEOUT : + SKB_CONSUMED; WARN_ON(del_timer(&q->timer) != 0); /* Release all fragment data. */ fqdir = q->fqdir; f = fqdir->f; - sum_truesize = inet_frag_rbtree_purge(&q->rb_fragments); + sum_truesize = inet_frag_rbtree_purge(&q->rb_fragments, reason); sum = sum_truesize + f->qsize; call_rcu(&q->rcu, inet_frag_destroy_rcu); diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 676bd8d259555448457dfd98ce4316c4b549a30a..85e8113259c36881dd0153d9d68c818ebabccc0c 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -153,6 +153,7 @@ static void ip_expire(struct timer_list *t) if (qp->q.flags & INET_FRAG_COMPLETE) goto out; + qp->q.flags |= INET_FRAG_DROP; ipq_kill(qp); __IP_INC_STATS(net, IPSTATS_MIB_REASMFAILS); __IP_INC_STATS(net, IPSTATS_MIB_REASMTIMEOUT); @@ -194,7 +195,7 @@ static void ip_expire(struct timer_list *t) spin_unlock(&qp->q.lock); out_rcu_unlock: rcu_read_unlock(); - kfree_skb(head); + kfree_skb_reason(head, SKB_DROP_REASON_FRAG_REASM_TIMEOUT); ipq_put(qp); } @@ -254,7 +255,8 @@ static int ip_frag_reinit(struct ipq *qp) return -ETIMEDOUT; } - sum_truesize = inet_frag_rbtree_purge(&qp->q.rb_fragments); + sum_truesize = inet_frag_rbtree_purge(&qp->q.rb_fragments, + SKB_DROP_REASON_NOT_SPECIFIED); sub_frag_mem_limit(qp->q.fqdir, sum_truesize); qp->q.flags = 0; From patchwork Fri Oct 28 13:30:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13023626 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 4FCD1FA3742 for ; Fri, 28 Oct 2022 13:31:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbiJ1NbZ (ORCPT ); Fri, 28 Oct 2022 09:31:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230521AbiJ1NbA (ORCPT ); Fri, 28 Oct 2022 09:31:00 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1B281BB56E for ; Fri, 28 Oct 2022 06:30:59 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id i4-20020ac813c4000000b003a5044a818cso1676882qtj.11 for ; Fri, 28 Oct 2022 06:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=egV3NVpWdy5jA+rc7AFJDo41XjgjLknqSr2qnbG9W7s=; b=Mez6uEy/kGq9X94NxlTLdU5n0QEikZu6WomiCisw5rFZlg9Gg7cyfdHGYT5S//1b/g bIFP6CCBGSJ4eqq0M1eFOtsMuX0Vv5jBP1yhgdmkUOLDY9pd3soSWjV2MuaKi+aY9F0P 4SBRUnVGcN6xkGIAFirHHpvb4ah2LIGxabd6M6g4MZYp8In0R/dYj+t0u8KaaPnv1OA7 BOxnP9oFLtX7AmnFFRtOPfmQD3TUXHP86yKaO4S2LKZfHz7VbnukJffhOBFj7BNogFWV VEokZnDpgkSF1edLK+h9ctCyKbwFkSruY3NhUMQZWMFmbmf5r8p36mMAHOMZd94PSJwR /14g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=egV3NVpWdy5jA+rc7AFJDo41XjgjLknqSr2qnbG9W7s=; b=CxpWr19VqzRopMqZNdUQkfRpLMesvt1QsMAwEb6PigaWZUC+uvuEWac1Mz3t8ALdR5 GpfytLizvhMN5N8eCGaqblHMyDtOCP5VASlWZoMrY5eda4NQcjEHHcifJn4O8fYGd9jH sTDGQc6xNIXIocM4klsrNe42i88GtiwmqyoEwn937M8F2GIAkohQ1h642DGhCj5TIW4r rUZPX2rom9zq4EOLpUxaUyWNabkBpw1ccvvL5cd43IThed8Z31ygWzbl/ZvYsB+ttOvJ UxE9SVt25wNkMZ5Fa44N7E3mx+MaCPpp/MrVj+b8R1J6yX1kwZ79+8UyqcC2/4Z4ic+4 H0CA== X-Gm-Message-State: ACrzQf2ryaHoeaZckMkfaAIB6YXSOfLOCCvoBBm+PIA2bdVyCPJs6qgr jtHN5nESx6SIuhLdNW4I2AYta3WLEqFJ3Q== X-Google-Smtp-Source: AMsMyM6NLsVDQn4wABNcOndO1CZ6MAQ0z9J9Px4qT2Zaiy0FtWOsnHO2j9vwgy64srf2e/0eSazatkAzRXce5Q== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:620a:29c6:b0:6ee:cf89:40cb with SMTP id s6-20020a05620a29c600b006eecf8940cbmr38922140qkp.107.1666963858817; Fri, 28 Oct 2022 06:30:58 -0700 (PDT) Date: Fri, 28 Oct 2022 13:30:43 +0000 In-Reply-To: <20221028133043.2312984-1-edumazet@google.com> Mime-Version: 1.0 References: <20221028133043.2312984-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221028133043.2312984-6-edumazet@google.com> Subject: [PATCH net-next 5/5] net: dropreason: add SKB_DROP_REASON_FRAG_TOO_FAR From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org IPv4 reassembly unit can decide to drop frags based on /proc/sys/net/ipv4/ipfrag_max_dist sysctl. Add a specific drop reason to track this specific and weird case. Signed-off-by: Eric Dumazet --- include/net/dropreason.h | 6 ++++++ net/ipv4/ip_fragment.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/dropreason.h b/include/net/dropreason.h index d3d44da889e4f002ed1485a10fd081184956c911..d3df766c117bc1b0373d9e19d9baad944b5fb776 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -70,6 +70,7 @@ FN(PKT_TOO_BIG) \ FN(DUP_FRAG) \ FN(FRAG_REASM_TIMEOUT) \ + FN(FRAG_TOO_FAR) \ FNe(MAX) /** @@ -306,6 +307,11 @@ enum skb_drop_reason { SKB_DROP_REASON_DUP_FRAG, /** @FRAG_REASM_TIMEOUT: fragment reassembly timeout */ SKB_DROP_REASON_FRAG_REASM_TIMEOUT, + /** + * @SKB_DROP_REASON_FRAG_TOO_FAR: ipv4 fragment too far. + * (/proc/sys/net/ipv4/ipfrag_max_dist) + */ + SKB_DROP_REASON_FRAG_TOO_FAR, /** * @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be * used as a real 'reason' diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 85e8113259c36881dd0153d9d68c818ebabccc0c..69c00ffdcf3e6336cb920902a43f4ad046cc8438 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -256,7 +256,7 @@ static int ip_frag_reinit(struct ipq *qp) } sum_truesize = inet_frag_rbtree_purge(&qp->q.rb_fragments, - SKB_DROP_REASON_NOT_SPECIFIED); + SKB_DROP_REASON_FRAG_TOO_FAR); sub_frag_mem_limit(qp->q.fqdir, sum_truesize); qp->q.flags = 0;