From nobody Fri Jun 19 06:14:00 2026 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 29E9AC433EF for ; Thu, 7 Apr 2022 06:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241011AbiDGGYI (ORCPT ); Thu, 7 Apr 2022 02:24:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241020AbiDGGYA (ORCPT ); Thu, 7 Apr 2022 02:24:00 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 479F21F6237; Wed, 6 Apr 2022 23:21:56 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a16-20020a17090a6d9000b001c7d6c1bb13so5216167pjk.4; Wed, 06 Apr 2022 23:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qIQAXIraFBo7pp9F+UKiJewbp52XCbv0LyD3lJdVZ6Q=; b=gEedZBPxVf7D2He4oUQ7Kmh59QVd9sD/7AU5O55/vRm09Px+34OduFUK8lUZ0NkEUg Z50Q6EjWk4SD+YUnCJdE3bTvgUrvExZRRn+/mxcLTb3DGA57t8NYTYEj5ptePHAZuhn/ bNOfsOwFH7BkcbIQbea1+FZVIQi65sqAhHg2/0A6nOCySWli1zJ9Bxgo7z2dSAfEUDLo U7xi5Qdz/oXoKqUZVcgHChtOH04RUYhnb8NisDc3Wb7fOSjHZzXKbvWB3+XMcKeRUWRi WFb/IScqFFqfsHhCnisQSEDfxNioQ6wAdKiDvpjtm2ExDLLwTVe7CPwD0TZn/R2+Ba9z AQ0A== 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=qIQAXIraFBo7pp9F+UKiJewbp52XCbv0LyD3lJdVZ6Q=; b=qYV5AuDSF/EOF4Iur1YLcdwfra+MrfY/kP6MFijdBgJMFt7anQlUskNZNt4tzCsIcn Ho4xjbkua/HyEDHlW27mPxOei9nQgdb+mqLiVDcZBybX5jXmmvvhExLPuALKacjVVHTJ AFrieLlN8nYmY8wl3MZPV5BWUentExaRfhv0MKMCZ8EHyHRh8w1aB2tcuFT52Si30t31 UpgBVeR7DEoaTDAYSdrGW1Gm6e9po86jxw/GZsxkiyEgRP8SaMUI499FOahwhdp/iPdn u2KTDqxN0tSqZJMM+tkpj1YE+NKMV2eF0BZwwaEZF4qdtx+lVdEr0z9eqUyf5AFhm0VN f9lg== X-Gm-Message-State: AOAM531C5LUJNMsRkwytSvd1OwjX+LWQppdIJ4bn59LCiJQKqCo/rg4y A162sb3sQSmpcMmzuWj3Uc4= X-Google-Smtp-Source: ABdhPJxRK9fYIDIA1/razN1poHLxz5XFZ0QtPpUUs7d3rBRM8YFikT09NIFIUC850TYNhWapRJ4E+Q== X-Received: by 2002:a17:902:c94a:b0:156:ae43:4023 with SMTP id i10-20020a170902c94a00b00156ae434023mr12143321pla.115.1649312516054; Wed, 06 Apr 2022 23:21:56 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.118]) by smtp.gmail.com with ESMTPSA id k92-20020a17090a4ce500b001ca69b5c034sm7522829pjh.46.2022.04.06.23.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 23:21:55 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: rostedt@goodmis.org, mingo@redhat.com, xeb@mail.ru, davem@davemloft.net, yoshfuji@linux-ipv6.org, imagedong@tencent.com, edumazet@google.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, dongli.zhang@oracle.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, benbjiang@tencent.com Subject: [PATCH RESEND net-next v5 1/4] net: sock: introduce sock_queue_rcv_skb_reason() Date: Thu, 7 Apr 2022 14:20:49 +0800 Message-Id: <20220407062052.15907-2-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407062052.15907-1-imagedong@tencent.com> References: <20220407062052.15907-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong In order to report the reasons of skb drops in 'sock_queue_rcv_skb()', introduce the function 'sock_queue_rcv_skb_reason()'. As the return value of 'sock_queue_rcv_skb()' is used as the error code, we can't make it as drop reason and have to pass extra output argument. 'sock_queue_rcv_skb()' is used in many places, so we can't change it directly. Introduce the new function 'sock_queue_rcv_skb_reason()' and make 'sock_queue_rcv_skb()' an inline call to it. Reviewed-by: Hao Peng Reviewed-by: Jiang Biao Signed-off-by: Menglong Dong Reviewed-by: David Ahern --- include/net/sock.h | 9 ++++++++- net/core/sock.c | 30 ++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index c4b91fc19b9c..1a988e605f09 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2392,7 +2392,14 @@ int __sk_queue_drop_skb(struct sock *sk, struct sk_b= uff_head *sk_queue, void (*destructor)(struct sock *sk, struct sk_buff *skb)); int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); -int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); + +int sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb, + enum skb_drop_reason *reason); + +static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +{ + return sock_queue_rcv_skb_reason(sk, skb, NULL); +} =20 int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb); struct sk_buff *sock_dequeue_err_skb(struct sock *sk); diff --git a/net/core/sock.c b/net/core/sock.c index 1180a0cb0110..2cae991f817e 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -503,17 +503,35 @@ int __sock_queue_rcv_skb(struct sock *sk, struct sk_b= uff *skb) } EXPORT_SYMBOL(__sock_queue_rcv_skb); =20 -int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +int sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb, + enum skb_drop_reason *reason) { + enum skb_drop_reason drop_reason; int err; =20 err =3D sk_filter(sk, skb); - if (err) - return err; - - return __sock_queue_rcv_skb(sk, skb); + if (err) { + drop_reason =3D SKB_DROP_REASON_SOCKET_FILTER; + goto out; + } + err =3D __sock_queue_rcv_skb(sk, skb); + switch (err) { + case -ENOMEM: + drop_reason =3D SKB_DROP_REASON_SOCKET_RCVBUFF; + break; + case -ENOBUFS: + drop_reason =3D SKB_DROP_REASON_PROTO_MEM; + break; + default: + drop_reason =3D SKB_NOT_DROPPED_YET; + break; + } +out: + if (reason) + *reason =3D drop_reason; + return err; } -EXPORT_SYMBOL(sock_queue_rcv_skb); +EXPORT_SYMBOL(sock_queue_rcv_skb_reason); =20 int __sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested, unsigned int trim_cap, bool refcounted) --=20 2.35.1 From nobody Fri Jun 19 06:14:00 2026 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 7BE6BC433EF for ; Thu, 7 Apr 2022 06:22:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241009AbiDGGYO (ORCPT ); Thu, 7 Apr 2022 02:24:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241006AbiDGGYF (ORCPT ); Thu, 7 Apr 2022 02:24:05 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CEF817335C; Wed, 6 Apr 2022 23:22:06 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id gt4so4678468pjb.4; Wed, 06 Apr 2022 23:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=//KZ6YHhys1mLVWKPMFh1+e7V9mc1xx+r9/4L0Awq3M=; b=JCzxspGLnoO/gWqkguN6ckSzcjztc5fY16WYZoRzyWFIzDhL8KXlOFWDM9MR42vo7/ RJbAlNWFPg4ema/EFN29NAn4CWgYNmBkaIemdYU+IgnyyqNdj/pDuK9f6DOD10GpX6JY YBs70AZekvg1GEY1CC8MN1nXz3uAWTc1XnG1Mu2aVRqoxCM5O3Nom5ZTX+Qo9wSGVAhJ itxWLNyXP8uJ1T1XJUNGvHj52Kai6wHlVAMbfgQY0ylfNr7D/1PU8Gc1uLR0/OTm/thq HZd/y9gIxdxKc50M/dRXUUBx/vLf0IeOATfKwH/tgGzTraVaawElhBOk8erC4RdwL7ha fLug== 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=//KZ6YHhys1mLVWKPMFh1+e7V9mc1xx+r9/4L0Awq3M=; b=q2VjfOlgNjaYUoml4V2MJ0VSj4EhGsyMeGiDsxR1cq+pRN3J7L8wnT4XGrSqQMiTPc bNht+VH5WlDqYOp324akygWS4fEhSfyzPnx6jgO7j9yo3MPkUMJab358pfxslBoiQPRU 8el8LK+FOfh+8WsqhJis4M0aD+LHZjqba6mpfeDZUlMweiDobQOxcaTzIZM2bNDlMM4B JiqPtD4hR35BOYNTwDngP+eDRKOErKdhA9fBMcPoEb2tToRpL/idruQ9sJTJS1lAArrO z4r5rd0dQh4rVYrtr0zQGGrv+TO0++gjfc2Mt12ISLmfzNAa8pb8f6Im5ExoHGqqQVym h29w== X-Gm-Message-State: AOAM532USsXkcGL7wkRQZGC1UsnD7eR3HBZeEwolvhHfabLCexcINAV6 d1vVMRALGGOO1VxPKOCO0bM= X-Google-Smtp-Source: ABdhPJx2bs5VWR00T+NLUxXxO3g8V338nWdiIp9YK8U6oNn5LdkhOw84v3lt0p7hlZMlwFYDSnm4HA== X-Received: by 2002:a17:903:244b:b0:154:2cb2:86d with SMTP id l11-20020a170903244b00b001542cb2086dmr12160340pls.123.1649312526024; Wed, 06 Apr 2022 23:22:06 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.118]) by smtp.gmail.com with ESMTPSA id k92-20020a17090a4ce500b001ca69b5c034sm7522829pjh.46.2022.04.06.23.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 23:22:05 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: rostedt@goodmis.org, mingo@redhat.com, xeb@mail.ru, davem@davemloft.net, yoshfuji@linux-ipv6.org, imagedong@tencent.com, edumazet@google.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, dongli.zhang@oracle.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, benbjiang@tencent.com Subject: [PATCH RESEND net-next v5 2/4] net: skb: rename SKB_DROP_REASON_PTYPE_ABSENT Date: Thu, 7 Apr 2022 14:20:50 +0800 Message-Id: <20220407062052.15907-3-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407062052.15907-1-imagedong@tencent.com> References: <20220407062052.15907-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong As David Ahern suggested, the reasons for skb drops should be more general and not be code based. Therefore, rename SKB_DROP_REASON_PTYPE_ABSENT to SKB_DROP_REASON_UNHANDLED_PROTO, which is used for the cases of no L3 protocol handler, no L4 protocol handler, version extensions, etc. From previous discussion, now we have the aim to make these reasons more abstract and users based, avoiding code based. Signed-off-by: Menglong Dong Reviewed-by: David Ahern --- include/linux/skbuff.h | 8 +++----- include/trace/events/skb.h | 2 +- net/core/dev.c | 8 +++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 26538ceb4b01..10ba07892c46 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -408,11 +408,9 @@ enum skb_drop_reason { */ SKB_DROP_REASON_XDP, /* dropped by XDP in input path */ SKB_DROP_REASON_TC_INGRESS, /* dropped in TC ingress HOOK */ - SKB_DROP_REASON_PTYPE_ABSENT, /* not packet_type found to handle - * the skb. For an etner packet, - * this means that L3 protocol is - * not supported - */ + SKB_DROP_REASON_UNHANDLED_PROTO, /* protocol not implemented + * or not supported + */ SKB_DROP_REASON_SKB_CSUM, /* sk_buff checksum computation * error */ diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index e1670e1e4934..85abd7cbd221 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -50,7 +50,7 @@ EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ EM(SKB_DROP_REASON_XDP, XDP) \ EM(SKB_DROP_REASON_TC_INGRESS, TC_INGRESS) \ - EM(SKB_DROP_REASON_PTYPE_ABSENT, PTYPE_ABSENT) \ + EM(SKB_DROP_REASON_UNHANDLED_PROTO, UNHANDLED_PROTO) \ EM(SKB_DROP_REASON_SKB_CSUM, SKB_CSUM) \ EM(SKB_DROP_REASON_SKB_GSO_SEG, SKB_GSO_SEG) \ EM(SKB_DROP_REASON_SKB_UCOPY_FAULT, SKB_UCOPY_FAULT) \ diff --git a/net/core/dev.c b/net/core/dev.c index 75bab5b0dbae..d73b35e6aae4 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5359,13 +5359,11 @@ static int __netif_receive_skb_core(struct sk_buff = **pskb, bool pfmemalloc, *ppt_prev =3D pt_prev; } else { drop: - if (!deliver_exact) { + if (!deliver_exact) dev_core_stats_rx_dropped_inc(skb->dev); - kfree_skb_reason(skb, SKB_DROP_REASON_PTYPE_ABSENT); - } else { + else dev_core_stats_rx_nohandler_inc(skb->dev); - kfree_skb(skb); - } + kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO); /* Jamal, now you will not able to escape explaining * me how you were going to use this. :-) */ --=20 2.35.1 From nobody Fri Jun 19 06:14:00 2026 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 BCCF7C433F5 for ; Thu, 7 Apr 2022 06:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbiDGGYa (ORCPT ); Thu, 7 Apr 2022 02:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241019AbiDGGYP (ORCPT ); Thu, 7 Apr 2022 02:24:15 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B3111F623E; Wed, 6 Apr 2022 23:22:16 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id bx5so4677094pjb.3; Wed, 06 Apr 2022 23:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uzLwDH0T/7R2uuxPhLk/uyD8x3vzGxN4sd3r2UIM55o=; b=NaOWB6pVjsjbky4yJCzPQGeziW+NG3COxtix+JXAv1Gl5rb69xc3hwPCsuMPajp2v9 MF2f05aBa753Jvp9MYaV8j4nmoofE7l0hSfFsj4NjSwpOARaJCm4OQT7ysNWbmTwaQqi kz1/BFyjHT3UqCFiCyDmSwB0ysUPbeCmmw2H6krzvFE4erS/rrD/lXu4enQUbSShWDis rpgIMhDmFkU0jB5uvZ0nTpYM3spanhvBMvacDkFRPMR0rsDMP4Qy2v218PRc61YoZdOD 4A8CVCARUxFeE1kwKrqvLwOcZoLfBdVABjgF8VTHT0kEOV8bKA4CfZKx0u23xG4d/J5Y /vBQ== 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=uzLwDH0T/7R2uuxPhLk/uyD8x3vzGxN4sd3r2UIM55o=; b=nSNGYU0J++Ulu0mgujQOkVu0Rg9ekanxNmVNyPMOZgIXLkCvgmD+ygw/mok7C1S2gK Ukdk4I8zifn6jkxx4WkAJVquw8BrdUlvQ7KFViScqT8jr9bSrJZlXVkMhThXxCxhP0sX tw210V1qCfL2i9s0tZJpaC9HBowjTNzsaePKM4bd4lrCJmOenbhk/T/MLKpJCjZbJUV/ bZX+KQZ/Mh2/MsHwSy9W92sVjjYkMWa4wSdZtP46cDinI+Jima4i0KaCOeaXLuqXxqo4 K5pa0XrWb/H/3g1pfV5k5OIgGjq1WuY8dpNQXyQJW/3QK3GuldPF7etc7bDiDFiDSgr+ ZUkg== X-Gm-Message-State: AOAM532h4JmZ6Tjhf2i5c8ZuQwLh7J40S2FokiEA6NohEsHgzyDTboTX 11hJ06cigF6jpXOJqG45CsM= X-Google-Smtp-Source: ABdhPJxjkTYgFCAZvPLSfTLd2yvZsCPY6wR5kWrHJuOpWuISobqUrCLwSSikzVB7NUTsg4IZgoF/hA== X-Received: by 2002:a17:902:d888:b0:151:6fe8:6e68 with SMTP id b8-20020a170902d88800b001516fe86e68mr12193394plz.158.1649312535428; Wed, 06 Apr 2022 23:22:15 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.118]) by smtp.gmail.com with ESMTPSA id k92-20020a17090a4ce500b001ca69b5c034sm7522829pjh.46.2022.04.06.23.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 23:22:14 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: rostedt@goodmis.org, mingo@redhat.com, xeb@mail.ru, davem@davemloft.net, yoshfuji@linux-ipv6.org, imagedong@tencent.com, edumazet@google.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, dongli.zhang@oracle.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, benbjiang@tencent.com Subject: [PATCH RESEND net-next v5 3/4] net: icmp: introduce __ping_queue_rcv_skb() to report drop reasons Date: Thu, 7 Apr 2022 14:20:51 +0800 Message-Id: <20220407062052.15907-4-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407062052.15907-1-imagedong@tencent.com> References: <20220407062052.15907-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong In order to avoid to change the return value of ping_queue_rcv_skb(), introduce the function __ping_queue_rcv_skb(), which is able to report the reasons of skb drop as its return value, as Paolo suggested. Meanwhile, make ping_queue_rcv_skb() a simple call to __ping_queue_rcv_skb(). The kfree_skb() and sock_queue_rcv_skb() used in ping_queue_rcv_skb() are replaced with kfree_skb_reason() and sock_queue_rcv_skb_reason() now. Reviewed-by: Hao Peng Reviewed-by: Jiang Biao Signed-off-by: Menglong Dong Reviewed-by: David Ahern --- v4: - fix the return value problem of ping_queue_rcv_skb() v3: - fix aligenment problem v2: - introduce __ping_queue_rcv_skb() instead of change the return value of ping_queue_rcv_skb() --- net/ipv4/ping.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 3ee947557b88..877270ad17c9 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -934,16 +934,24 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg,= size_t len, int noblock, } EXPORT_SYMBOL_GPL(ping_recvmsg); =20 -int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +static enum skb_drop_reason __ping_queue_rcv_skb(struct sock *sk, + struct sk_buff *skb) { + enum skb_drop_reason reason; + pr_debug("ping_queue_rcv_skb(sk=3D%p,sk->num=3D%d,skb=3D%p)\n", inet_sk(sk), inet_sk(sk)->inet_num, skb); - if (sock_queue_rcv_skb(sk, skb) < 0) { - kfree_skb(skb); + if (sock_queue_rcv_skb_reason(sk, skb, &reason) < 0) { + kfree_skb_reason(skb, reason); pr_debug("ping_queue_rcv_skb -> failed\n"); - return -1; + return reason; } - return 0; + return SKB_NOT_DROPPED_YET; +} + +int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) +{ + return __ping_queue_rcv_skb(sk, skb) ? -1 : 0; } EXPORT_SYMBOL_GPL(ping_queue_rcv_skb); =20 --=20 2.35.1 From nobody Fri Jun 19 06:14:00 2026 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 BC076C433F5 for ; Thu, 7 Apr 2022 06:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241028AbiDGGYi (ORCPT ); Thu, 7 Apr 2022 02:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241057AbiDGGYY (ORCPT ); Thu, 7 Apr 2022 02:24:24 -0400 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 19DEA1F622F; Wed, 6 Apr 2022 23:22:25 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id s2so4574709pfh.6; Wed, 06 Apr 2022 23:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kHpIqwHUOiHtY4NBo/hXOV1Enmw9fot8Ao21/zKsXT8=; b=ZU5c7yXdEvgtKowVB/ueRPVH6VmgosLnYS9+2S10DxWgfCqtZKUgtpG5IZrT/okHu/ Gp/V7G5zxttq9KUjOrFq15TqenuzlgzwHmZdXqtXyVkEFr0ZDcJotLyhDIYU68EahC9O WqaXEfFjhvVe7AgJrI6EpajB50e3TTEnzYjfyLH0OMOEH0KyBiHmkkVnnFnsULVf/7DL QysxgcpiYvIpqwZ9OFQfs38zo+ulhOf1Qzu70PTN9wi/wzHxe6JVveEbDUvjSPtp+7Xb +0dcbw7yTWDE8t61TrFYnlPrMj8ubpOLNDiET4F3cqXSbsbBD2Hw/LV+ioQjuJdapvsw DhZA== 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=kHpIqwHUOiHtY4NBo/hXOV1Enmw9fot8Ao21/zKsXT8=; b=mghOwascXoQYo7YtpgVt4pIzeBI845Z3CsyTnI8Hvyy/k/vR7Q1pk2UqAiClbgdHry CdOuNEW/1YFGUP8RBFkTEOx4F0UlQ098F1UE2LDmWP/Ezb89TNnC7zUR6QuicM51oONw 0nS6VGGUPeGE1xGHwbCq2/VCICiu4FZqIXkL00jd1Et6lvxznY1jZXizIU1r91YLm+SC jjrFXOLSkZjoeBpsibE0LcxXyyqD4ZEYKqNZ4aYriu2GyrfEHdmLg599+9mr/Cpr2aM0 yrX5VPD/N/MPerWT2Iit6TXexVkMAtxIWdUz5LuGzUdEQ4VrDH2Ui7BBzavti6xBDoUC pPog== X-Gm-Message-State: AOAM5304JHt+GG/+Wz7rbpK3V9Tgj1fRf5qA3QCKRtuIutzAqIqp7xH7 t60R5FlBgpxEuh9VtgnyiXE= X-Google-Smtp-Source: ABdhPJyK44TM3UAcZTeL0f4dm2wmOmpnvWcO2KjzZdL2YmP7TnoXs+0HKQsyZjSg1wQIEbh4Tze4og== X-Received: by 2002:a05:6a00:2450:b0:4f7:bf07:c063 with SMTP id d16-20020a056a00245000b004f7bf07c063mr12676690pfj.51.1649312544461; Wed, 06 Apr 2022 23:22:24 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.118]) by smtp.gmail.com with ESMTPSA id k92-20020a17090a4ce500b001ca69b5c034sm7522829pjh.46.2022.04.06.23.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 23:22:23 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org, pabeni@redhat.com Cc: rostedt@goodmis.org, mingo@redhat.com, xeb@mail.ru, davem@davemloft.net, yoshfuji@linux-ipv6.org, imagedong@tencent.com, edumazet@google.com, kafai@fb.com, talalahmad@google.com, keescook@chromium.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, dongli.zhang@oracle.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, benbjiang@tencent.com Subject: [PATCH RESEND net-next v5 4/4] net: icmp: add skb drop reasons to icmp protocol Date: Thu, 7 Apr 2022 14:20:52 +0800 Message-Id: <20220407062052.15907-5-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220407062052.15907-1-imagedong@tencent.com> References: <20220407062052.15907-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong Replace kfree_skb() used in icmp_rcv() and icmpv6_rcv() with kfree_skb_reason(). In order to get the reasons of the skb drops after icmp message handle, we change the return type of 'handler()' in 'struct icmp_control' from 'bool' to 'enum skb_drop_reason'. This may change its original intention, as 'false' means failure, but 'SKB_NOT_DROPPED_YET' means success now. Therefore, all 'handler' and the call of them need to be handled. Following 'handler' functions are involved: icmp_unreach() icmp_redirect() icmp_echo() icmp_timestamp() icmp_discard() And following new drop reasons are added: SKB_DROP_REASON_ICMP_CSUM SKB_DROP_REASON_INVALID_PROTO The reason 'INVALID_PROTO' is introduced for the case that the packet doesn't follow rfc 1122 and is dropped. This is not a common case, and I believe we can locate the problem from the data in the packet. For now, this 'INVALID_PROTO' is used for the icmp broadcasts with wrong types. Maybe there should be a document file for these reasons. For example, list all the case that causes the 'UNHANDLED_PROTO' and 'INVALID_PROTO' drop reason. Therefore, users can locate their problems according to the document. Reviewed-by: Hao Peng Reviewed-by: Jiang Biao Signed-off-by: Menglong Dong Reviewed-by: David Ahern --- v5: - rename SKB_DROP_REASON_RFC_1122 to SKB_DROP_REASON_INVALID_PROTO v4: - remove SKB_DROP_REASON_ICMP_TYPE and SKB_DROP_REASON_ICMP_BROADCAST and introduce the SKB_DROP_REASON_RFC_1122 --- include/linux/skbuff.h | 5 +++ include/net/ping.h | 2 +- include/trace/events/skb.h | 2 + net/ipv4/icmp.c | 75 ++++++++++++++++++++++---------------- net/ipv4/ping.c | 14 ++++--- net/ipv6/icmp.c | 24 +++++++----- 6 files changed, 75 insertions(+), 47 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 10ba07892c46..92e8c8d7410e 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -442,6 +442,11 @@ enum skb_drop_reason { SKB_DROP_REASON_TAP_TXFILTER, /* dropped by tx filter implemented * at tun/tap, e.g., check_filter() */ + SKB_DROP_REASON_ICMP_CSUM, /* ICMP checksum error */ + SKB_DROP_REASON_INVALID_PROTO, /* the packet doesn't follow RFC + * 2211, such as a broadcasts + * ICMP_TIMESTAMP + */ SKB_DROP_REASON_MAX, }; =20 diff --git a/include/net/ping.h b/include/net/ping.h index 2fe78874318c..b68fbfdb606f 100644 --- a/include/net/ping.h +++ b/include/net/ping.h @@ -76,7 +76,7 @@ int ping_recvmsg(struct sock *sk, struct msghdr *msg, si= ze_t len, int noblock, int ping_common_sendmsg(int family, struct msghdr *msg, size_t len, void *user_icmph, size_t icmph_len); int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); -bool ping_rcv(struct sk_buff *skb); +enum skb_drop_reason ping_rcv(struct sk_buff *skb); =20 #ifdef CONFIG_PROC_FS void *ping_seq_start(struct seq_file *seq, loff_t *pos, sa_family_t family= ); diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 85abd7cbd221..42647114fffe 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -61,6 +61,8 @@ EM(SKB_DROP_REASON_HDR_TRUNC, HDR_TRUNC) \ EM(SKB_DROP_REASON_TAP_FILTER, TAP_FILTER) \ EM(SKB_DROP_REASON_TAP_TXFILTER, TAP_TXFILTER) \ + EM(SKB_DROP_REASON_ICMP_CSUM, ICMP_CSUM) \ + EM(SKB_DROP_REASON_INVALID_PROTO, INVALID_PROTO) \ EMe(SKB_DROP_REASON_MAX, MAX) =20 #undef EM diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 72a375c7f417..236debd9fded 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -186,7 +186,7 @@ EXPORT_SYMBOL(icmp_err_convert); */ =20 struct icmp_control { - bool (*handler)(struct sk_buff *skb); + enum skb_drop_reason (*handler)(struct sk_buff *skb); short error; /* This ICMP is classed as an error message */ }; =20 @@ -839,8 +839,9 @@ static bool icmp_tag_validation(int proto) * ICMP_PARAMETERPROB. */ =20 -static bool icmp_unreach(struct sk_buff *skb) +static enum skb_drop_reason icmp_unreach(struct sk_buff *skb) { + enum skb_drop_reason reason =3D SKB_NOT_DROPPED_YET; const struct iphdr *iph; struct icmphdr *icmph; struct net *net; @@ -860,8 +861,10 @@ static bool icmp_unreach(struct sk_buff *skb) icmph =3D icmp_hdr(skb); iph =3D (const struct iphdr *)skb->data; =20 - if (iph->ihl < 5) /* Mangled header, drop. */ + if (iph->ihl < 5) { /* Mangled header, drop. */ + reason =3D SKB_DROP_REASON_IP_INHDR; goto out_err; + } =20 switch (icmph->type) { case ICMP_DEST_UNREACH: @@ -941,10 +944,10 @@ static bool icmp_unreach(struct sk_buff *skb) icmp_socket_deliver(skb, info); =20 out: - return true; + return reason; out_err: __ICMP_INC_STATS(net, ICMP_MIB_INERRORS); - return false; + return reason ?: SKB_DROP_REASON_NOT_SPECIFIED; } =20 =20 @@ -952,20 +955,20 @@ static bool icmp_unreach(struct sk_buff *skb) * Handle ICMP_REDIRECT. */ =20 -static bool icmp_redirect(struct sk_buff *skb) +static enum skb_drop_reason icmp_redirect(struct sk_buff *skb) { if (skb->len < sizeof(struct iphdr)) { __ICMP_INC_STATS(dev_net(skb->dev), ICMP_MIB_INERRORS); - return false; + return SKB_DROP_REASON_PKT_TOO_SMALL; } =20 if (!pskb_may_pull(skb, sizeof(struct iphdr))) { /* there aught to be a stat */ - return false; + return SKB_DROP_REASON_NOMEM; } =20 icmp_socket_deliver(skb, ntohl(icmp_hdr(skb)->un.gateway)); - return true; + return SKB_NOT_DROPPED_YET; } =20 /* @@ -982,7 +985,7 @@ static bool icmp_redirect(struct sk_buff *skb) * See also WRT handling of options once they are done and working. */ =20 -static bool icmp_echo(struct sk_buff *skb) +static enum skb_drop_reason icmp_echo(struct sk_buff *skb) { struct icmp_bxm icmp_param; struct net *net; @@ -990,7 +993,7 @@ static bool icmp_echo(struct sk_buff *skb) net =3D dev_net(skb_dst(skb)->dev); /* should there be an ICMP stat for ignored echos? */ if (net->ipv4.sysctl_icmp_echo_ignore_all) - return true; + return SKB_NOT_DROPPED_YET; =20 icmp_param.data.icmph =3D *icmp_hdr(skb); icmp_param.skb =3D skb; @@ -1001,10 +1004,10 @@ static bool icmp_echo(struct sk_buff *skb) if (icmp_param.data.icmph.type =3D=3D ICMP_ECHO) icmp_param.data.icmph.type =3D ICMP_ECHOREPLY; else if (!icmp_build_probe(skb, &icmp_param.data.icmph)) - return true; + return SKB_NOT_DROPPED_YET; =20 icmp_reply(&icmp_param, skb); - return true; + return SKB_NOT_DROPPED_YET; } =20 /* Helper for icmp_echo and icmpv6_echo_reply. @@ -1122,7 +1125,7 @@ EXPORT_SYMBOL_GPL(icmp_build_probe); * MUST be accurate to a few minutes. * MUST be updated at least at 15Hz. */ -static bool icmp_timestamp(struct sk_buff *skb) +static enum skb_drop_reason icmp_timestamp(struct sk_buff *skb) { struct icmp_bxm icmp_param; /* @@ -1147,17 +1150,17 @@ static bool icmp_timestamp(struct sk_buff *skb) icmp_param.data_len =3D 0; icmp_param.head_len =3D sizeof(struct icmphdr) + 12; icmp_reply(&icmp_param, skb); - return true; + return SKB_NOT_DROPPED_YET; =20 out_err: __ICMP_INC_STATS(dev_net(skb_dst(skb)->dev), ICMP_MIB_INERRORS); - return false; + return SKB_DROP_REASON_PKT_TOO_SMALL; } =20 -static bool icmp_discard(struct sk_buff *skb) +static enum skb_drop_reason icmp_discard(struct sk_buff *skb) { /* pretend it was a success */ - return true; + return SKB_NOT_DROPPED_YET; } =20 /* @@ -1165,18 +1168,20 @@ static bool icmp_discard(struct sk_buff *skb) */ int icmp_rcv(struct sk_buff *skb) { - struct icmphdr *icmph; + enum skb_drop_reason reason =3D SKB_DROP_REASON_NOT_SPECIFIED; struct rtable *rt =3D skb_rtable(skb); struct net *net =3D dev_net(rt->dst.dev); - bool success; + struct icmphdr *icmph; =20 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { struct sec_path *sp =3D skb_sec_path(skb); int nh; =20 if (!(sp && sp->xvec[sp->len - 1]->props.flags & - XFRM_STATE_ICMP)) + XFRM_STATE_ICMP)) { + reason =3D SKB_DROP_REASON_XFRM_POLICY; goto drop; + } =20 if (!pskb_may_pull(skb, sizeof(*icmph) + sizeof(struct iphdr))) goto drop; @@ -1184,8 +1189,11 @@ int icmp_rcv(struct sk_buff *skb) nh =3D skb_network_offset(skb); skb_set_network_header(skb, sizeof(*icmph)); =20 - if (!xfrm4_policy_check_reverse(NULL, XFRM_POLICY_IN, skb)) + if (!xfrm4_policy_check_reverse(NULL, XFRM_POLICY_IN, + skb)) { + reason =3D SKB_DROP_REASON_XFRM_POLICY; goto drop; + } =20 skb_set_network_header(skb, nh); } @@ -1207,13 +1215,13 @@ int icmp_rcv(struct sk_buff *skb) /* We can't use icmp_pointers[].handler() because it is an array of * size NR_ICMP_TYPES + 1 (19 elements) and PROBE has code 42. */ - success =3D icmp_echo(skb); - goto success_check; + reason =3D icmp_echo(skb); + goto reason_check; } =20 if (icmph->type =3D=3D ICMP_EXT_ECHOREPLY) { - success =3D ping_rcv(skb); - goto success_check; + reason =3D ping_rcv(skb); + goto reason_check; } =20 /* @@ -1222,8 +1230,10 @@ int icmp_rcv(struct sk_buff *skb) * RFC 1122: 3.2.2 Unknown ICMP messages types MUST be silently * discarded. */ - if (icmph->type > NR_ICMP_TYPES) + if (icmph->type > NR_ICMP_TYPES) { + reason =3D SKB_DROP_REASON_UNHANDLED_PROTO; goto error; + } =20 /* * Parse the ICMP message @@ -1239,27 +1249,30 @@ int icmp_rcv(struct sk_buff *skb) if ((icmph->type =3D=3D ICMP_ECHO || icmph->type =3D=3D ICMP_TIMESTAMP) && net->ipv4.sysctl_icmp_echo_ignore_broadcasts) { + reason =3D SKB_DROP_REASON_INVALID_PROTO; goto error; } if (icmph->type !=3D ICMP_ECHO && icmph->type !=3D ICMP_TIMESTAMP && icmph->type !=3D ICMP_ADDRESS && icmph->type !=3D ICMP_ADDRESSREPLY) { + reason =3D SKB_DROP_REASON_INVALID_PROTO; goto error; } } =20 - success =3D icmp_pointers[icmph->type].handler(skb); -success_check: - if (success) { + reason =3D icmp_pointers[icmph->type].handler(skb); +reason_check: + if (!reason) { consume_skb(skb); return NET_RX_SUCCESS; } =20 drop: - kfree_skb(skb); + kfree_skb_reason(skb, reason); return NET_RX_DROP; csum_error: + reason =3D SKB_DROP_REASON_ICMP_CSUM; __ICMP_INC_STATS(net, ICMP_MIB_CSUMERRORS); error: __ICMP_INC_STATS(net, ICMP_MIB_INERRORS); diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 877270ad17c9..b383e0393206 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -960,12 +960,12 @@ EXPORT_SYMBOL_GPL(ping_queue_rcv_skb); * All we need to do is get the socket. */ =20 -bool ping_rcv(struct sk_buff *skb) +enum skb_drop_reason ping_rcv(struct sk_buff *skb) { + enum skb_drop_reason reason =3D SKB_DROP_REASON_NO_SOCKET; struct sock *sk; struct net *net =3D dev_net(skb->dev); struct icmphdr *icmph =3D icmp_hdr(skb); - bool rc =3D false; =20 /* We assume the packet has already been checked by icmp_rcv */ =20 @@ -980,15 +980,17 @@ bool ping_rcv(struct sk_buff *skb) struct sk_buff *skb2 =3D skb_clone(skb, GFP_ATOMIC); =20 pr_debug("rcv on socket %p\n", sk); - if (skb2 && !ping_queue_rcv_skb(sk, skb2)) - rc =3D true; + if (skb2) + reason =3D __ping_queue_rcv_skb(sk, skb2); + else + reason =3D SKB_DROP_REASON_NOMEM; sock_put(sk); } =20 - if (!rc) + if (reason) pr_debug("no socket, dropping\n"); =20 - return rc; + return reason; } EXPORT_SYMBOL_GPL(ping_rcv); =20 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index e6b978ea0e87..01c8003c9fc9 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -864,21 +864,23 @@ void icmpv6_notify(struct sk_buff *skb, u8 type, u8 c= ode, __be32 info) =20 static int icmpv6_rcv(struct sk_buff *skb) { + enum skb_drop_reason reason =3D SKB_DROP_REASON_NOT_SPECIFIED; struct net *net =3D dev_net(skb->dev); struct net_device *dev =3D icmp6_dev(skb); struct inet6_dev *idev =3D __in6_dev_get(dev); const struct in6_addr *saddr, *daddr; struct icmp6hdr *hdr; u8 type; - bool success =3D false; =20 if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) { struct sec_path *sp =3D skb_sec_path(skb); int nh; =20 if (!(sp && sp->xvec[sp->len - 1]->props.flags & - XFRM_STATE_ICMP)) + XFRM_STATE_ICMP)) { + reason =3D SKB_DROP_REASON_XFRM_POLICY; goto drop_no_count; + } =20 if (!pskb_may_pull(skb, sizeof(*hdr) + sizeof(struct ipv6hdr))) goto drop_no_count; @@ -886,8 +888,11 @@ static int icmpv6_rcv(struct sk_buff *skb) nh =3D skb_network_offset(skb); skb_set_network_header(skb, sizeof(*hdr)); =20 - if (!xfrm6_policy_check_reverse(NULL, XFRM_POLICY_IN, skb)) + if (!xfrm6_policy_check_reverse(NULL, XFRM_POLICY_IN, + skb)) { + reason =3D SKB_DROP_REASON_XFRM_POLICY; goto drop_no_count; + } =20 skb_set_network_header(skb, nh); } @@ -924,11 +929,11 @@ static int icmpv6_rcv(struct sk_buff *skb) break; =20 case ICMPV6_ECHO_REPLY: - success =3D ping_rcv(skb); + reason =3D ping_rcv(skb); break; =20 case ICMPV6_EXT_ECHO_REPLY: - success =3D ping_rcv(skb); + reason =3D ping_rcv(skb); break; =20 case ICMPV6_PKT_TOOBIG: @@ -994,19 +999,20 @@ static int icmpv6_rcv(struct sk_buff *skb) /* until the v6 path can be better sorted assume failure and * preserve the status quo behaviour for the rest of the paths to here */ - if (success) - consume_skb(skb); + if (reason) + kfree_skb_reason(skb, reason); else - kfree_skb(skb); + consume_skb(skb); =20 return 0; =20 csum_error: + reason =3D SKB_DROP_REASON_ICMP_CSUM; __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_CSUMERRORS); discard_it: __ICMP6_INC_STATS(dev_net(dev), idev, ICMP6_MIB_INERRORS); drop_no_count: - kfree_skb(skb); + kfree_skb_reason(skb, reason); return 0; } =20 --=20 2.35.1