Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1009789pxp; Thu, 17 Mar 2022 00:16:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5uaMZG+VEb2x6o+NLgxnewrXYAmvzMCGuJE0h8MhX1nWdqTCycasm0zYV3t0VS6BnCRDe X-Received: by 2002:a05:6a00:84b:b0:4f7:439b:64e6 with SMTP id q11-20020a056a00084b00b004f7439b64e6mr3008689pfk.51.1647501392161; Thu, 17 Mar 2022 00:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647501392; cv=none; d=google.com; s=arc-20160816; b=Q7+RFUVXLRwy58+u8EQ2/orSLrtyg56l97saRyNXvrj4oTLqKqKPqA5q06hVcUFx9D FAt8tsmqVd6Y2jY1+qk/ofxcQRpkM8uOoqPavj4g6BaAo4sqZ9zbIutCOhpEF0vt0nIy 1aM7AESPBdlasjQGVk7f5A9eI70HrPV4ULnL1ZgnNNcCqgLXkq4u4Xtwk7gI7rN4XBXj 4I2Ej2g1V3CHqV81WesvEDMWZ4rd8XMwHc7FLidqumGMw4g8W8+k2vB/agK8y22L5F9S E+fVL3hzhCobis1GSBy38xr4TGZ0tRv6G/zRdJAWZUI/UH8nlznSxaan4QUIbxSNtQNM 5mwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=M46+b6LrSwlI17F3i2XgwwHhummNRK4ZjijSW7M5eUw=; b=Irccd4PaLVxVnnUpI1QiVN5fwzuB0P4S4q1XizFcBLk+8yy30/mOhStVjEtF7FZANE WtamLaUOSNWeGbNrkkGgqJD3oC1VfxOd6d8tc2nRuRfkDjuZLRhORvHrfFDX2sNhOwlL WlEPbM1H6l+VotFnjLyLze+Frnq7nDaE7MH3ZYYEVeswvB4Z3vLkQLi/SZZ8p2dPbeN9 7b2RaU0xrrbS0xZ+/iLZdgorNPObwds6PZ/FX03KBZd8YUn1n4SZQkyKPJvmi0RlM8US neaglcXpouMZDknodnlPm4igOg8sHlfABrUnp+yu79ioUpuO1YLmkvnmyrP2GUMcUUhK 15Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MLTj4ZmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a63ee17000000b003816043f088si1207606pgi.637.2022.03.17.00.16.18; Thu, 17 Mar 2022 00:16:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MLTj4ZmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229717AbiCQGRC (ORCPT + 99 others); Thu, 17 Mar 2022 02:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbiCQGQz (ORCPT ); Thu, 17 Mar 2022 02:16:55 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFE86173F4F; Wed, 16 Mar 2022 22:58:00 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id b15so5265894edn.4; Wed, 16 Mar 2022 22:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=M46+b6LrSwlI17F3i2XgwwHhummNRK4ZjijSW7M5eUw=; b=MLTj4ZmHdyx25fg7w0lOrZpPwEk7fIl7wAVtHpvwbK6NEeUfcO5SVg0X1F/bXuT1Xb JW6S8Gw/HDvoRzKQN1LyGLjLXypdrZQtpGe7po37uu0Ssk4P8YqTr9+3qBW52vNNqN5T rVmrUAdSSTZPTKHfIq56U3PbaSPy267wvVJEEgeOcPojiYk/yrr6c6AOtE43FUZ87/B0 uIBs7yFagvX6GcGaF04hxyIwE4PxLEL+0X7LX2H0ACBNEiIqMJtVNFIBarxS+g6NpIx5 XJFu/4ylG+SOO+ni2HNYpnYhmjuHFl037esPjHzsKmvPj7dlNzMu4A//agoMYA7ZqodZ rzqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=M46+b6LrSwlI17F3i2XgwwHhummNRK4ZjijSW7M5eUw=; b=DnNfNZ228xG1NnIHIK2IYYr101JzweS1joWyPpwMV9+0L/BS0Iuhnaxf0YqkL1I/Ae 0M/u9CT2qublrnOVPnIMox6USiGV7cG5AxI0cX/FA55KwjWhPVj0tfaukCD2s/IqeVSJ qmwxkgwjWJh42vWrjSscMujJvu1IxwxIS+C0PiXU0L7x6H6GD5Xcitd8eN6jEx4sGcgR Fgdl1qZ0unleCHmrehoCKiDAywoxbIjmlkZ+4sSzInK8u0MpQ7yxqOvXqHc3+22Mjx3O 9mJoo9wBhtee7ebjUxX/tje6Nx5Ip3UsPJ3lLf0qBBxQo7rMJUQ1AxoSa0wpAxaKwMzI 753A== X-Gm-Message-State: AOAM531WQuoS9wOsjLSji1fr9qxg2PH3EUT8vHxo1kf87AmkZmm7TjLI SQCSMcIiIbCqvXgu0PkW8CmQyUlU/XrgeOD1R2E= X-Received: by 2002:a05:6402:486:b0:413:bd00:4f3f with SMTP id k6-20020a056402048600b00413bd004f3fmr2673050edv.103.1647496679362; Wed, 16 Mar 2022 22:57:59 -0700 (PDT) MIME-Version: 1.0 References: <20220316063148.700769-1-imagedong@tencent.com> <20220316063148.700769-4-imagedong@tencent.com> <20220316201853.0734280f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20220316201853.0734280f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Menglong Dong Date: Thu, 17 Mar 2022 13:57:47 +0800 Message-ID: Subject: Re: [PATCH net-next v3 3/3] net: icmp: add reasons of the skb drops to icmp protocol To: Jakub Kicinski Cc: David Ahern , Paolo Abeni , Steven Rostedt , Ingo Molnar , xeb@mail.ru, David Miller , Hideaki YOSHIFUJI , Menglong Dong , Eric Dumazet , Martin Lau , Talal Ahmad , Kees Cook , Alexander Lobakin , Hao Peng , Mengen Sun , dongli.zhang@oracle.com, LKML , netdev , Biao Jiang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 17, 2022 at 11:18 AM Jakub Kicinski wrote: > [......] > > -bool ping_rcv(struct sk_buff *skb) > > +enum skb_drop_reason ping_rcv(struct sk_buff *skb) > > { > > + enum skb_drop_reason reason = SKB_DROP_REASON_NO_SOCKET; > > struct sock *sk; > > struct net *net = dev_net(skb->dev); > > struct icmphdr *icmph = icmp_hdr(skb); > > - bool rc = false; > > > > /* We assume the packet has already been checked by icmp_rcv */ > > > > @@ -980,15 +980,17 @@ bool ping_rcv(struct sk_buff *skb) > > struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); > > > > pr_debug("rcv on socket %p\n", sk); > > - if (skb2 && !ping_queue_rcv_skb(sk, skb2)) > > - rc = true; > > + if (skb2) > > + reason = __ping_queue_rcv_skb(sk, skb2); > > + else > > + reason = SKB_DROP_REASON_NOMEM; > > sock_put(sk); > > } > > > > - if (!rc) > > + if (reason) > > pr_debug("no socket, dropping\n"); > > This is going to be printed on memory allocation failures now as well. Enn...This logic is not changed. In the previous, skb2==NULL means rc is false, and this message is printed too. Seems this can be optimized by the way? Printing the message only for no socket found.