Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp164043pxm; Tue, 1 Mar 2022 17:34:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsAwrS4O9z3bspZZlMJ4QYTPY9xW4tpk7bCJwnoucSLdKD8tJhKPgT9U9T4njWDZzq5oKY X-Received: by 2002:a63:4d8:0:b0:373:cf6d:40e3 with SMTP id 207-20020a6304d8000000b00373cf6d40e3mr24135199pge.590.1646184884520; Tue, 01 Mar 2022 17:34:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646184884; cv=none; d=google.com; s=arc-20160816; b=WL9WqxHLdOqSgjN3uAO5/HYuEnnqo+A4/otRODaeE9dLiDbqZS+JJjUOshxuBavADI pwBnhQtTyhwCf0hwkTk1y9Nv8gfb3OZQZAI5H8Q/ZstonFklzlCDIwcjkApNmD0mJ5cP Addd9F8UyPVh9VHCcLFSWOcAG8370Jtzw/sTHVKK4itP6iv8HBQanXl3oA9b7tsAh9Yj /BG0E95iUWdV0ylxIqIpm5mhfjqX+bttsGQksHxGPhBVvD+GRWk3J1Mb9hIA7qLp2OxW LuUCfsS7iymZmk9FgQmSdsG23WLsmo8i6+rjIH1eaJK1l5fVHgj35le8vk0llYW6u21b rC+w== 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=zT4QMG8d8ebgFHX32WWkf7Z5v9Q81C3atFiBsRon+LE=; b=d98a6fGIHPsRPPtY8lTBjEZN9lW9D+YKQtoy6r6wgd9Gh7VQJwZ/lDej686IEPHNAs 6GvRYtt1Z2CkG2wbXxgeCzCv63Y7LY8NBoiNks0GdPZ5aM3vo4cpSiR6Hmu+1naMnmkI OWmOy8I7YJw7fPnrwfP8foRM7bF/S0u0gxUHDSpyQgUc2h9DYjDXKoUPeWnc5fPPz9hG cuymiYu3xsfvGZTg2DLj7qSN4uFUM/SeiNi190yw4ZGtMJ4Xf4DbXwd/6s/+ni+A3yDu H8/5OBR85N04Hb25h63dIhQq2+Sjm3iqlqpD0oOVd/qPfQXJqL7UPMgPjQ8LJXurbD+Y mLXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DJ5q5nwE; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a13-20020a634d0d000000b0037345bef58dsi13126374pgb.642.2022.03.01.17.34.27; Tue, 01 Mar 2022 17:34:44 -0800 (PST) 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=@google.com header.s=20210112 header.b=DJ5q5nwE; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230369AbiCAP30 (ORCPT + 99 others); Tue, 1 Mar 2022 10:29:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231971AbiCAP3Z (ORCPT ); Tue, 1 Mar 2022 10:29:25 -0500 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A223D13F5F for ; Tue, 1 Mar 2022 07:28:43 -0800 (PST) Received: by mail-lj1-x22c.google.com with SMTP id e8so22363670ljj.2 for ; Tue, 01 Mar 2022 07:28:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zT4QMG8d8ebgFHX32WWkf7Z5v9Q81C3atFiBsRon+LE=; b=DJ5q5nwEABjmE6en9CaJDJUXyfHwIzfOMRLeQ8Z44R1SDvHlSAM3pWMWNG0X+V2/2Y yZK0q1Qi8RV3rGiyRdAxqttttYziAk9rYCK1VPcrUmicJcERUJeILVTqiItwrHHbv0zO u7nlk33F0a7S7boyLEZcN8WZwQQCTtTSIPArvdfVDK2mN8Vg8HfT8/M7t6LpADOEJMA8 qo10Td70BoiiyAn6co/F3szLyfCutgo687lyMrhJ2NzyZ4HNTCdz65HWNqOQc2HpPM3T hi9UP23d9V0j9Jvf6NDzwhiydSon//MCg0FPCnI3VpNzbcxmC8E0tNe14kma655lvk9l vo/Q== 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=zT4QMG8d8ebgFHX32WWkf7Z5v9Q81C3atFiBsRon+LE=; b=lLtu2kHQsUCLzcGGoqnqLLAysImNWzlfEtLikIk09m+fhD00i1VvJEKsY7EapeFOh2 re6Il8HTxTJLg58ZZNYb3E7c5XTA7GKCMKX8eexWETJm6C/JMChGw/LLPWuPVdgZrb9U QvZtkSHh5NXMTQSDd6KZguY+ltNpUT3P2lZP9io6oAlJuM22CZ97F3AAVoObnqKDGydV jRd+6UPFuYQkRCt7YrWbuVWbm7QmvRCsVwhBgqHrE0AaSCK2INAZmZW9TJYhItEpn+jz l1/sBXHCJdjHO3xpnXB2MaSpbER0TREfHuhwhf0gNgkv7/nW0EnPfgmEhzhLgxBISoyE 1wtA== X-Gm-Message-State: AOAM5305bcPJqoLnH8GDEaTdsxSvfHQhrfZI3QfnrcR0AyBl2VdwMqEx n6r2HnNyxz7q+CCdfW1EvQqZOtlMF8gTCugGT1jxsA== X-Received: by 2002:a2e:b52f:0:b0:23e:2fe6:af10 with SMTP id z15-20020a2eb52f000000b0023e2fe6af10mr16966817ljm.46.1646148520398; Tue, 01 Mar 2022 07:28:40 -0800 (PST) MIME-Version: 1.0 References: <20220301001153.1608374-1-jeffreyjilinux@gmail.com> In-Reply-To: <20220301001153.1608374-1-jeffreyjilinux@gmail.com> From: Brian Vazquez Date: Tue, 1 Mar 2022 07:28:28 -0800 Message-ID: Subject: Re: [PATCH net-next] net-core: add rx_otherhost_dropped counter To: Jeffrey Ji Cc: Jakub Kicinski , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Antoine Tenart , Sebastian Andrzej Siewior , Alexander Lobakin , Kumar Kartikeya Dwivedi , Arnd Bergmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, jeffreyji Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Hey Jeffrey, Looking at it in patchwork (https://patchwork.kernel.org/project/netdevbpf/patch/20220301001153.1608374-1-jeffreyjilinux@gmail.com/), it is complaining about kdoc. Seems that you're missing the kdoc comment about rx_otherhost_dropped in the include/linux/netdevice.h file, other than that LGTM. On Mon, Feb 28, 2022 at 4:12 PM Jeffrey Ji wrote: > > From: jeffreyji > > Increment rx_otherhost_dropped counter when packet dropped due to > mismatched dest MAC addr. > > An example when this drop can occur is when manually crafting raw > packets that will be consumed by a user space application via a tap > device. For testing purposes local traffic was generated using trafgen > for the client and netcat to start a server > > Tested: Created 2 netns, sent 1 packet using trafgen from 1 to the other > with "{eth(daddr=$INCORRECT_MAC...}", verified that iproute2 showed the > counter was incremented. (Also had to modify iproute2 to show the stat, > additional patch for that coming next.) > > Signed-off-by: jeffreyji > --- > include/linux/netdevice.h | 1 + > include/uapi/linux/if_link.h | 5 +++++ > net/core/dev.c | 2 ++ > net/ipv4/ip_input.c | 1 + > net/ipv6/ip6_input.c | 1 + > 5 files changed, 10 insertions(+) > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index c79ee2296296..96c2030f4c1f 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -2025,6 +2025,7 @@ struct net_device { > atomic_long_t rx_dropped; > atomic_long_t tx_dropped; > atomic_long_t rx_nohandler; > + atomic_long_t rx_otherhost_dropped; > > /* Stats to monitor link on/off, flapping */ > atomic_t carrier_up_count; > diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h > index be09d2ad4b5d..834382317889 100644 > --- a/include/uapi/linux/if_link.h > +++ b/include/uapi/linux/if_link.h > @@ -211,6 +211,9 @@ struct rtnl_link_stats { > * @rx_nohandler: Number of packets received on the interface > * but dropped by the networking stack because the device is > * not designated to receive packets (e.g. backup link in a bond). > + * > + * @rx_otherhost_dropped: Number of packets dropped due to mismatch in > + * packet's destination MAC address. > */ > struct rtnl_link_stats64 { > __u64 rx_packets; > @@ -243,6 +246,8 @@ struct rtnl_link_stats64 { > __u64 rx_compressed; > __u64 tx_compressed; > __u64 rx_nohandler; > + > + __u64 rx_otherhost_dropped; > }; > > /* The struct should be in sync with struct ifmap */ > diff --git a/net/core/dev.c b/net/core/dev.c > index 2d6771075720..d039d8fdc16a 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -10037,6 +10037,8 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, > storage->rx_dropped += (unsigned long)atomic_long_read(&dev->rx_dropped); > storage->tx_dropped += (unsigned long)atomic_long_read(&dev->tx_dropped); > storage->rx_nohandler += (unsigned long)atomic_long_read(&dev->rx_nohandler); > + storage->rx_otherhost_dropped += > + (unsigned long)atomic_long_read(&dev->rx_otherhost_dropped); > return storage; > } > EXPORT_SYMBOL(dev_get_stats); > diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c > index d94f9f7e60c3..ef97b0a4c77f 100644 > --- a/net/ipv4/ip_input.c > +++ b/net/ipv4/ip_input.c > @@ -450,6 +450,7 @@ static struct sk_buff *ip_rcv_core(struct sk_buff *skb, struct net *net) > * that it receives, do not try to analyse it. > */ > if (skb->pkt_type == PACKET_OTHERHOST) { > + atomic_long_inc(&skb->dev->rx_otherhost_dropped); > drop_reason = SKB_DROP_REASON_OTHERHOST; > goto drop; > } > diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c > index d4b1e2c5aa76..3f0cbe126d82 100644 > --- a/net/ipv6/ip6_input.c > +++ b/net/ipv6/ip6_input.c > @@ -150,6 +150,7 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev, > struct inet6_dev *idev; > > if (skb->pkt_type == PACKET_OTHERHOST) { > + atomic_long_inc(&skb->dev->rx_otherhost_dropped); > kfree_skb(skb); > return NULL; > } > -- > 2.35.1.574.g5d30c73bfb-goog >