* [PATCH net-next] net-core: rx_otherhost_dropped to core_stats
@ 2022-04-06 17:26 Jeffrey Ji
2022-04-07 5:31 ` Jakub Kicinski
2022-04-08 4:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Jeffrey Ji @ 2022-04-06 17:26 UTC (permalink / raw)
To: Brian Vazquez
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Hideaki YOSHIFUJI,
David Ahern, Eric Dumazet, Sebastian Andrzej Siewior,
Toke Høiland-Jørgensen, Menglong Dong, Petr Machata,
Kumar Kartikeya Dwivedi, Arnd Bergmann, netdev, linux-kernel,
Jeffrey Ji
From: Jeffrey Ji <jeffreyji@google.com>
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: Jeffrey Ji <jeffreyji@google.com>
---
include/linux/netdevice.h | 2 ++
include/uapi/linux/if_link.h | 5 +++++
net/core/dev.c | 1 +
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 7b2a0b739684..9b2b9457e70f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -202,6 +202,7 @@ struct net_device_core_stats {
local_t rx_dropped;
local_t tx_dropped;
local_t rx_nohandler;
+ local_t rx_otherhost_dropped;
} __aligned(4 * sizeof(local_t));
#include <linux/cache.h>
@@ -3878,6 +3879,7 @@ static inline void dev_core_stats_##FIELD##_inc(struct net_device *dev) \
DEV_CORE_STATS_INC(rx_dropped)
DEV_CORE_STATS_INC(tx_dropped)
DEV_CORE_STATS_INC(rx_nohandler)
+DEV_CORE_STATS_INC(rx_otherhost_dropped)
static __always_inline int ____dev_forward_skb(struct net_device *dev,
struct sk_buff *skb,
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index cc284c048e69..d1e600816b82 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 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;
};
/* Subset of link stats useful for in-HW collection. Meaning of the fields is as
diff --git a/net/core/dev.c b/net/core/dev.c
index d5a362d53b34..68680d8474c7 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10363,6 +10363,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
storage->rx_dropped += local_read(&core_stats->rx_dropped);
storage->tx_dropped += local_read(&core_stats->tx_dropped);
storage->rx_nohandler += local_read(&core_stats->rx_nohandler);
+ storage->rx_otherhost_dropped += local_read(&core_stats->rx_otherhost_dropped);
}
}
return storage;
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 95f7bb052784..b1165f717cd1 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -451,6 +451,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) {
+ dev_core_stats_rx_otherhost_dropped_inc(skb->dev);
drop_reason = SKB_DROP_REASON_OTHERHOST;
goto drop;
}
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 5b5ea35635f9..b4880c7c84eb 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) {
+ dev_core_stats_rx_otherhost_dropped_inc(skb->dev);
kfree_skb(skb);
return NULL;
}
--
2.35.1.1094.g7c7d902a7c-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net-core: rx_otherhost_dropped to core_stats
2022-04-06 17:26 [PATCH net-next] net-core: rx_otherhost_dropped to core_stats Jeffrey Ji
@ 2022-04-07 5:31 ` Jakub Kicinski
2022-04-07 15:36 ` Brian Vazquez
2022-04-08 4:00 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2022-04-07 5:31 UTC (permalink / raw)
To: Jeffrey Ji
Cc: Brian Vazquez, David S . Miller, Paolo Abeni, Hideaki YOSHIFUJI,
David Ahern, Eric Dumazet, Sebastian Andrzej Siewior,
Toke Høiland-Jørgensen, Menglong Dong, Petr Machata,
Kumar Kartikeya Dwivedi, Arnd Bergmann, netdev, linux-kernel,
Jeffrey Ji
On Wed, 6 Apr 2022 17:26:00 +0000 Jeffrey Ji wrote:
> From: Jeffrey Ji <jeffreyji@google.com>
>
> 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: Jeffrey Ji <jeffreyji@google.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net-core: rx_otherhost_dropped to core_stats
2022-04-07 5:31 ` Jakub Kicinski
@ 2022-04-07 15:36 ` Brian Vazquez
2022-04-07 15:39 ` Eric Dumazet
0 siblings, 1 reply; 5+ messages in thread
From: Brian Vazquez @ 2022-04-07 15:36 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Jeffrey Ji, David S . Miller, Paolo Abeni, Hideaki YOSHIFUJI,
David Ahern, Eric Dumazet, Sebastian Andrzej Siewior,
Toke Høiland-Jørgensen, Menglong Dong, Petr Machata,
Kumar Kartikeya Dwivedi, Arnd Bergmann, netdev, linux-kernel,
Jeffrey Ji
Looks good to me, thanks Jeffrey.
Reviewed-by: Brian Vazquez <brianvv@google.com>
On Wed, Apr 6, 2022 at 10:31 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Wed, 6 Apr 2022 17:26:00 +0000 Jeffrey Ji wrote:
> > From: Jeffrey Ji <jeffreyji@google.com>
> >
> > 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: Jeffrey Ji <jeffreyji@google.com>
>
> Acked-by: Jakub Kicinski <kuba@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net-core: rx_otherhost_dropped to core_stats
2022-04-07 15:36 ` Brian Vazquez
@ 2022-04-07 15:39 ` Eric Dumazet
0 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2022-04-07 15:39 UTC (permalink / raw)
To: Brian Vazquez
Cc: Jakub Kicinski, Jeffrey Ji, David S . Miller, Paolo Abeni,
Hideaki YOSHIFUJI, David Ahern, Sebastian Andrzej Siewior,
Toke Høiland-Jørgensen, Menglong Dong, Petr Machata,
Kumar Kartikeya Dwivedi, Arnd Bergmann, netdev, LKML, Jeffrey Ji
On Thu, Apr 7, 2022 at 8:36 AM Brian Vazquez <brianvv@google.com> wrote:
>
> Looks good to me, thanks Jeffrey.
>
> Reviewed-by: Brian Vazquez <brianvv@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Thank you.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net-core: rx_otherhost_dropped to core_stats
2022-04-06 17:26 [PATCH net-next] net-core: rx_otherhost_dropped to core_stats Jeffrey Ji
2022-04-07 5:31 ` Jakub Kicinski
@ 2022-04-08 4:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-08 4:00 UTC (permalink / raw)
To: Jeffrey Ji
Cc: brianvv, davem, kuba, pabeni, yoshfuji, dsahern, edumazet,
bigeasy, toke, imagedong, petrm, memxor, arnd, netdev,
linux-kernel, jeffreyji
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 6 Apr 2022 17:26:00 +0000 you wrote:
> From: Jeffrey Ji <jeffreyji@google.com>
>
> 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
>
> [...]
Here is the summary with links:
- [net-next] net-core: rx_otherhost_dropped to core_stats
https://git.kernel.org/netdev/net-next/c/794c24e9921f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-08 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06 17:26 [PATCH net-next] net-core: rx_otherhost_dropped to core_stats Jeffrey Ji
2022-04-07 5:31 ` Jakub Kicinski
2022-04-07 15:36 ` Brian Vazquez
2022-04-07 15:39 ` Eric Dumazet
2022-04-08 4:00 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.