From patchwork Sat Oct 29 15:45:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13024703 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 4DC1BC38A02 for ; Sat, 29 Oct 2022 15:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229610AbiJ2Pp2 (ORCPT ); Sat, 29 Oct 2022 11:45:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbiJ2Pp1 (ORCPT ); Sat, 29 Oct 2022 11:45:27 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84B5362A8F for ; Sat, 29 Oct 2022 08:45:26 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id h9-20020a25e209000000b006cbc4084f2eso6954956ybe.23 for ; Sat, 29 Oct 2022 08:45:26 -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=mI56OTqtJ6BYMK8ASTZDj9XQcqo67qGoByoUPLpbCYy0b+Juu2WHZRlBKfIP/OR9VG FfmdxNfa8upy9d9J2Nfv0wtU+sPq2vmwlhTQx0p0gKVwROoxwViwNECapOGpn8Io0YoL +hZkePOfQOE15/rHYloPvwlM2NsXlX+kherqYX+BOv3KcpHrKKdz8R7n5/MKVU4jfNrw Kiu9f4qLDdHVr6OPh1kfSq37qbgyyzXn3tex/+fkNanp9EOFD7pGxhMR9kvcRV/yAc0j j3ax9YgAADUt9xvJyjcvQG48kxF/je+zGWdZCBEMrCdZbRHjtc7sYsLQQZET5GLlaez9 PzUA== 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=0MkvFLtM/WajbPQawHHBdK4qOk4X9HZD2MPftKAznrYVa1FPDTmNRsAm122awJRtvK glwnsg/BxCTm7yEa975wRG9p0OkfZirfrwo7VlqUjkIVcHzjQ7ydZEHjuaJW1g6BVBrM YtbkfSD790lQx6d2FpIqSyZ5ueOUfErL+Nj4emKO+FjEHSBqe2uICXcgiVYwqlRWul9T rFzsd4Ce5x/SMmIChWtlYh3bYIYlGP1h3jmP5GOFZqnNtPhyhh45VujI7DjDvEepyPpu 5mN7JYRZAzIA99AfXUT5lQOwZh0DGYteeklh4S6EmIQILC58PPot5BB4obLGl5VhL27L fPpA== X-Gm-Message-State: ACrzQf1wtZ5Zz/GEY0IoiCOsn1UDPI1H16p7SG2NSW/aDlhq38pxbIOz QEieYXa0OC5jCz6AzkKmV4WF9FcpbcZ5hQ== X-Google-Smtp-Source: AMsMyM7iO3/YkFWasJ6QqFeDF8dw5lxy/jvrKkRYkYX9bimpJdO8JKUlYYYBthZ39xr77j7AIxfe1wzjgqdstA== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a81:8309:0:b0:36a:6aa5:bfbd with SMTP id t9-20020a818309000000b0036a6aa5bfbdmr8ywf.15.1667058325350; Sat, 29 Oct 2022 08:45:25 -0700 (PDT) Date: Sat, 29 Oct 2022 15:45:16 +0000 In-Reply-To: <20221029154520.2747444-1-edumazet@google.com> Mime-Version: 1.0 References: <20221029154520.2747444-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221029154520.2747444-2-edumazet@google.com> Subject: [PATCH v2 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 Sat Oct 29 15:45:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13024704 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 A5279C433FE for ; Sat, 29 Oct 2022 15:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229580AbiJ2Ppd (ORCPT ); Sat, 29 Oct 2022 11:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbiJ2Ppa (ORCPT ); Sat, 29 Oct 2022 11:45:30 -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 7A64C631F5 for ; Sat, 29 Oct 2022 08:45:29 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id bq21-20020a05622a1c1500b0039cdae506e6so5087889qtb.10 for ; Sat, 29 Oct 2022 08:45:29 -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=khZE/voogYTeuW5/F1Y2cyifckcJVjPd9EfFw1cghSvY1ZffOhfgXVmejAEDIF6zmY RbN7OsK9EHAQo3jP2BG4eHKWTUB7KkWXToF43ddSN6M42F7Kroe4kJd5Mnjycq8Vi6HI /hqbRRGq6LLtT66zDqIcB9yOooQp0SjnXmKCCaHfUfKlnARptcLFvqus8KXTEsqsMOFH Kf9AJ9dpasFm0TRwigxn5/eJArYSHdXX7Zxnb0Py0AmLFOKWyPqrDtRVlBmklN9yfwim s+F588HhsEUhiRopIeWwKJbk23iclXeYHAX1YruPpYorcdCIK+FNGRpSEUEanuPeCvof 66vw== 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=fg25crMmvHaQEVR6lcLsah2/1rhNBcDO15aqf44oc+o3yucTBwVmXWhbHDXrFnj4CH h7aU3XSyBlLsR8x2dC+QZBwYYpLLfo3zS0WgOkcorRfjgYUr8AW7WDPUcr00vWg66W/y iODz6rpmZGWkpFS4h649We9zfFUhzDmwxiSzUSwITTC+QRi5O2tO3NPagWzO8B4lhSIi b1LNES3CHzUIIA4tMEbRQecap/XmNTSDOIttmgw3WTOPh8qyDK0co5/HdO+QBAvbA5Tc uhk4/gf7CegLYKKkoFfNhgVFUh7aAbwEFJTo6f+rokbA4kBcoUiruqrxYYOeagcfTZft zwVA== X-Gm-Message-State: ACrzQf1RsLMe3BjMB5DTt0OWsIBQChsoPGdkRjQLvgUVgT//0Jn8CLYk geijW2dS/m3LiQmnO+ikU5x9dt6WWF3sZQ== X-Google-Smtp-Source: AMsMyM6HMLESl1ywgbWs7UXG4J3o6QTz0A89W4gfWAH6P40z0Gftkv2kIRY3vJmR3s6ikJ4lOwNWZ0gupg1hGQ== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a0c:f193:0:b0:4bb:92f5:bc20 with SMTP id m19-20020a0cf193000000b004bb92f5bc20mr4287057qvl.52.1667058328643; Sat, 29 Oct 2022 08:45:28 -0700 (PDT) Date: Sat, 29 Oct 2022 15:45:17 +0000 In-Reply-To: <20221029154520.2747444-1-edumazet@google.com> Mime-Version: 1.0 References: <20221029154520.2747444-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221029154520.2747444-3-edumazet@google.com> Subject: [PATCH v2 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 Sat Oct 29 15:45:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13024705 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 1535FFA3740 for ; Sat, 29 Oct 2022 15:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbiJ2Ppe (ORCPT ); Sat, 29 Oct 2022 11:45:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbiJ2Ppc (ORCPT ); Sat, 29 Oct 2022 11:45:32 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71F9163371 for ; Sat, 29 Oct 2022 08:45:31 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b14-20020a056902030e00b006a827d81fd8so6930998ybs.17 for ; Sat, 29 Oct 2022 08:45:31 -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=I39KgPnWoKSRP97lyTbujjpGVwNy/tHpFonzO7Hqv3LNCZko9QcY1hiqiUuGYTkA9j NtfENquWx0geWnbqsWVllUWNnkX4WnobxvMfVS3ih/Er24DKG/TT/Hj4KS/qG0Ekccxo x4wttQ9nWVrBtHjUb4JtvccyAKhJHSWcaGD3ZUKzbueFrBe+Yw758rP95mNriyiCsX/T dMxQqRDoEi83KT5M6+I84vcDDgojlIbgwuclHhr2jbcPnwUV575VFSqoY07yB2Jyek5j b2QxeeIyZP44QVLpwjXC8szbI00RogSkQVg0NriYmW/nlZmWIlkZMPQddF4KyM4OmS+t hy1A== 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=PrQ+jwDBuTcgcwDplMXAJGMy3CakpxnRS4oAIMmc/X+VugcAl1btnvy5imoZoiuvOB mEsTMFHO3VqKZ4URn2CQQdPNgMyMCdKnKID4nZd5woh04N54NH1DE2InmSlHq3U+5lLc ilmvejIG719DKBlRGj8ewXCMb6n1YDsmukYHJOPuk+aTP8DDR63vKLnRZrDWp2VkmIPs IvAMvOIpfQxUukHegUg5wvzS0zB/HjC3W43Fl13LIaCQ35r9iwSeTrhYGcLDn/Y0xl69 Y8GMEfVmRQFIJGgX6NclASILkL2y7SSR7KfuXdzcPoKApoYjWLmOxL1w/++RKN1o6wpn Xuww== X-Gm-Message-State: ACrzQf30EVWmJ/JGKqUr7j/tEz9GFMvTa6iRINOlbTS9l8Ts5Bwf3KT0 S9QBZddTUM4pG7ewwiVzbEVIPidwuEwvxw== X-Google-Smtp-Source: AMsMyM5eqLhWGSy52YId3YaZk5DStCQyHYPahO0meCnaTvJiAzIt+GG1QLTeWmpL/jxWH3jlb5981iTn7+zrUw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:690c:c05:b0:367:c61b:d9bb with SMTP id cl5-20020a05690c0c0500b00367c61bd9bbmr8ywb.163.1667058330298; Sat, 29 Oct 2022 08:45:30 -0700 (PDT) Date: Sat, 29 Oct 2022 15:45:18 +0000 In-Reply-To: <20221029154520.2747444-1-edumazet@google.com> Mime-Version: 1.0 References: <20221029154520.2747444-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221029154520.2747444-4-edumazet@google.com> Subject: [PATCH v2 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 Sat Oct 29 15:45:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13024706 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 E48CDC433FE for ; Sat, 29 Oct 2022 15:45:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbiJ2Ppp (ORCPT ); Sat, 29 Oct 2022 11:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbiJ2Ppg (ORCPT ); Sat, 29 Oct 2022 11:45:36 -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 70A0E631F5 for ; Sat, 29 Oct 2022 08:45:33 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-368994f4bc0so68307017b3.14 for ; Sat, 29 Oct 2022 08:45:33 -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=g0AHcgeJMgNZ4n3AdqfRTyyatB/vb8dq3xY6apxYZtw=; b=Moume5WSxPCoXDv6vMh84saZJFh9im6u3KfhBuwrFJvRNP/9xEFjccDQg9+hVqPXWh dmRyogCz9djvB7X002POcX8E/Nkcx371iwsuQlV7+khuOr15Yk3LQZP/9kj9sF5hsPFZ lUMsz6PVPeT9B2wdcHN/jqK5QvJ/GssLxpv0UJPCx4OzJqPnDSkkrXe22NoiygzYg/E0 3vy7gNkGnpl+d1AOzU+Nn/eGFpXw5qB7rfHsbPRYnXeLb7906BNSB1dWK6xkg7uaFeMk eQV7D5tl3pJrnNkptkBmjNzIIFaxsbsrPOBO2VzzWQwkk9HhnIitGaufxBL1/KRQDlSc +X+w== 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=g0AHcgeJMgNZ4n3AdqfRTyyatB/vb8dq3xY6apxYZtw=; b=TT/+WUsnoRNxFxciDdhGyrjAI/4SZ0wny/OO6jamPaoWdqL6lGsfkU5nf/YQIpMMKq aHLrRQJ0hm/ytOsEo5WZTvzmzMaKNbCrdG62IMMK7JbVqdZXaS27vnOk9c3XeUIsTeKM Qnfr/OGXfD8JsNKWplzGEuioQfNSochWMsXU9pSxxDRnwMowMe06bPVTT6zOzVc25Kwx ZzEPfcXSh3XboiVMzeEDT6hBWaujBJ/W2m0fEmk1sbKy7qNq1NoY87wkzYRzyqUUu3M6 TQrMbirXgSzBV7pR+gqXmUxFy1oZjwfZ0h8cYBkWfT695IbrPSivOs7yDevsAd3mTWbo TXiQ== X-Gm-Message-State: ACrzQf1IT8klaydQiCo8Zx9ALNJHe7c1MVvcnkdqhogPIhDjen+2NWH2 cRGws1ny/NACKt6Qje+5FUHuslJEz3TQbQ== X-Google-Smtp-Source: AMsMyM6CHbbpPRWjgfxARGXZ1UPn433IMVq/TRo0ITnyhGEb+GHG1LqM0TnejmGX0gDHY2gVNOq24KE/lhHKXQ== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a25:d93:0:b0:6c3:b9a9:c9c1 with SMTP id 141-20020a250d93000000b006c3b9a9c9c1mr2ybn.103.1667058332262; Sat, 29 Oct 2022 08:45:32 -0700 (PDT) Date: Sat, 29 Oct 2022 15:45:19 +0000 In-Reply-To: <20221029154520.2747444-1-edumazet@google.com> Mime-Version: 1.0 References: <20221029154520.2747444-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221029154520.2747444-5-edumazet@google.com> Subject: [PATCH v2 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..1d45a74148c305c6dd60408b98d3bf896dfcd599 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, + /** @SKB_DROP_REASON_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 Sat Oct 29 15:45:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13024707 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 2A1B2C38A02 for ; Sat, 29 Oct 2022 15:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229802AbiJ2Ppq (ORCPT ); Sat, 29 Oct 2022 11:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbiJ2Ppo (ORCPT ); Sat, 29 Oct 2022 11:45:44 -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 ECB9D63371 for ; Sat, 29 Oct 2022 08:45:34 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id w190-20020a257bc7000000b006c0d1b19526so6970616ybc.12 for ; Sat, 29 Oct 2022 08:45:34 -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=WCyffB4MSniqUYkonUIKsEsqK+rJqfdThOXNzyUknc8=; b=lZL59mF/wEpb41k+c39lqkSOaUxPEEyZTnq/6oVZC1F6BvtSC2A2uVtYm+82rtMgPC GKSxYOsXxdoO0fsWULG1Z13tw6dFdQX+0wNtVYaC0YyGotx8c5UCq3hQzm4TfoFLhJqi qaSv3Gw0Ko7ZUrSTkWsvp2IEvYRUOfACcb2r6gMfVqynimENwBq9Jl7Gf7OMsDIstxGP wVmachv2eyJjs950D2kxvKBoKGTdGVweTF0aKOAjcvJ0IhwCbN/rqYbSedbOeQ2SZjhq 909+CqAaHopcz4z18p3QOaScCSVXoC/kjtVZGsydUFFaNdWZMstToicxaeZEwLvODSkL FMcg== 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=WCyffB4MSniqUYkonUIKsEsqK+rJqfdThOXNzyUknc8=; b=GOm/s9cFYWu9IcQ3jp/C6g7fW8/pFjKmlCVQbeJbuVogLOEHNiQskk44KgN7TWgbz/ j77qIxczl6hEuXiNgEkuF4JIzwblPPRLFa15OxBkzT48HFDjVE/Xu7g5ZUfeUZtmt5D9 kW/YXa0sPpZmEQLPlv4a103s8pdWYVwUCxgoHlTuq4S4YPxvSgPNnDF38ZT63qrSrscY JCHlsPNcpIo4dx/KeUcNt1/LVSjclahTJRuqCY1bP62pmCQmXkuPVwdGdgsQR6Q0Nzgi 5rPvnAUD3bWDDt4xQrjDDt2isCVyVp9fK0cCmhJxS3fkz0qJJtDPDSR6pQuUHDuQ0lzv iNjg== X-Gm-Message-State: ACrzQf118MpcsRsuSgQtNH0mRSLyD/9rD15FxlX55FXaSHMPpUBwuvEn lkdAmCbVSb9s765XiAYMX5Hjr0i4ffQMkA== X-Google-Smtp-Source: AMsMyM7SfcBVMUHfY+zU/hCwGlrj/+/svCMaX2kmrUjLHB157RDyZPFN7bAmnSz0JhH4d+/eHII10XJySgPY+A== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a25:b805:0:b0:6bc:ff7:b3ee with SMTP id v5-20020a25b805000000b006bc0ff7b3eemr4665204ybj.616.1667058334248; Sat, 29 Oct 2022 08:45:34 -0700 (PDT) Date: Sat, 29 Oct 2022 15:45:20 +0000 In-Reply-To: <20221029154520.2747444-1-edumazet@google.com> Mime-Version: 1.0 References: <20221029154520.2747444-1-edumazet@google.com> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog Message-ID: <20221029154520.2747444-6-edumazet@google.com> Subject: [PATCH v2 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 1d45a74148c305c6dd60408b98d3bf896dfcd599..70539288f9958716f9164cac3435cce34bd21f51 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, /** @SKB_DROP_REASON_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;