* [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support
@ 2024-10-06 6:56 Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 01/12] net: skb: add pskb_network_may_pull_reason() helper Menglong Dong
` (11 more replies)
0 siblings, 12 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
In this series, we add skb drop reasons support to VXLAN, and following
new skb drop reasons are introduced:
SKB_DROP_REASON_VXLAN_INVALID_HDR
SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND
SKB_DROP_REASON_VXLAN_ENTRY_EXISTS
SKB_DROP_REASON_VXLAN_NO_REMOTE
SKB_DROP_REASON_MAC_INVALID_SOURCE
SKB_DROP_REASON_IP_TUNNEL_ECN
SKB_DROP_REASON_TUNNEL_TXINFO
SKB_DROP_REASON_LOCAL_MAC
We add some helper functions in this series, who will capture the drop
reasons from pskb_may_pull_reason and return them:
pskb_network_may_pull_reason()
pskb_inet_may_pull_reason()
And we also make the following functions return skb drop reasons:
skb_vlan_inet_prepare()
vxlan_remcsum()
vxlan_snoop()
vxlan_set_mac()
Changes since v4:
- make skb_vlan_inet_prepare() return drop reasons, instead of introduce
a wrapper for it in the 3rd patch.
- modify the document for SKB_DROP_REASON_LOCAL_MAC and
SKB_DROP_REASON_TUNNEL_TXINFO.
Changes since v3:
- rename SKB_DROP_REASON_VXLAN_INVALID_SMAC to
SKB_DROP_REASON_MAC_INVALID_SOURCE in the 6th patch
Changes since v2:
- move all the drop reasons of VXLAN to the "core", instead of introducing
the VXLAN drop reason subsystem
- add the 6th patch, which capture the drop reasons from vxlan_snoop()
- move the commits for vxlan_remcsum() and vxlan_set_mac() after
vxlan_rcv() to update the call of them accordingly
- fix some format problems
Changes since v1:
- document all the drop reasons that we introduce
- rename the drop reasons to make them more descriptive, as Ido advised
- remove the 2nd patch, which introduce the SKB_DR_RESET
- add the 4th patch, which adds skb_vlan_inet_prepare_reason() helper
- introduce the 6th patch, which make vxlan_set_mac return drop reasons
- introduce the 10th patch, which uses VXLAN_DROP_NO_REMOTE as the drop
reasons, as Ido advised
Menglong Dong (12):
net: skb: add pskb_network_may_pull_reason() helper
net: tunnel: add pskb_inet_may_pull_reason() helper
net: tunnel: make skb_vlan_inet_prepare() return drop reasons
net: vxlan: add skb drop reasons to vxlan_rcv()
net: vxlan: make vxlan_remcsum() return drop reasons
net: vxlan: make vxlan_snoop() return drop reasons
net: vxlan: make vxlan_set_mac() return drop reasons
net: vxlan: use kfree_skb_reason() in vxlan_xmit()
net: vxlan: add drop reasons support to vxlan_xmit_one()
net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit()
net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass()
net: vxlan: use kfree_skb_reason() in encap_bypass_if_local()
drivers/net/bareudp.c | 4 +-
drivers/net/geneve.c | 4 +-
drivers/net/vxlan/vxlan_core.c | 111 +++++++++++++++++++++------------
drivers/net/vxlan/vxlan_mdb.c | 2 +-
include/linux/skbuff.h | 8 ++-
include/net/dropreason-core.h | 39 ++++++++++++
include/net/ip_tunnels.h | 23 ++++---
7 files changed, 138 insertions(+), 53 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net-next v5 01/12] net: skb: add pskb_network_may_pull_reason() helper
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Menglong Dong
` (10 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Introduce the function pskb_network_may_pull_reason() and make
pskb_network_may_pull() a simple inline call to it. The drop reasons of
it just come from pskb_may_pull_reason.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
include/linux/skbuff.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 39f1d16f3628..48f1e0fa2a13 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3130,9 +3130,15 @@ static inline int skb_inner_network_offset(const struct sk_buff *skb)
return skb_inner_network_header(skb) - skb->data;
}
+static inline enum skb_drop_reason
+pskb_network_may_pull_reason(struct sk_buff *skb, unsigned int len)
+{
+ return pskb_may_pull_reason(skb, skb_network_offset(skb) + len);
+}
+
static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
{
- return pskb_may_pull(skb, skb_network_offset(skb) + len);
+ return pskb_network_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET;
}
/*
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 01/12] net: skb: add pskb_network_may_pull_reason() helper Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 03/12] net: tunnel: make skb_vlan_inet_prepare() return drop reasons Menglong Dong
` (9 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev,
Kalesh AP
Introduce the function pskb_inet_may_pull_reason() and make
pskb_inet_may_pull a simple inline call to it. The drop reasons of it just
come from pskb_may_pull_reason().
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
include/net/ip_tunnels.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 6194fbb564c6..7fc2f7bf837a 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -439,7 +439,8 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
int ip_tunnel_encap_setup(struct ip_tunnel *t,
struct ip_tunnel_encap *ipencap);
-static inline bool pskb_inet_may_pull(struct sk_buff *skb)
+static inline enum skb_drop_reason
+pskb_inet_may_pull_reason(struct sk_buff *skb)
{
int nhlen;
@@ -456,7 +457,12 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb)
nhlen = 0;
}
- return pskb_network_may_pull(skb, nhlen);
+ return pskb_network_may_pull_reason(skb, nhlen);
+}
+
+static inline bool pskb_inet_may_pull(struct sk_buff *skb)
+{
+ return pskb_inet_may_pull_reason(skb) == SKB_NOT_DROPPED_YET;
}
/* Variant of pskb_inet_may_pull().
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 03/12] net: tunnel: make skb_vlan_inet_prepare() return drop reasons
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 01/12] net: skb: add pskb_network_may_pull_reason() helper Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Menglong Dong
` (8 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Make skb_vlan_inet_prepare return the skb drop reasons, which is just
what pskb_may_pull_reason() returns. Meanwhile, adjust all the call of
it.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
---
v5:
- make skb_vlan_inet_prepare() return drop reasons, instead of introduce
a wrapper for it.
v3:
- fix some format problems, as Alexander advised
---
drivers/net/bareudp.c | 4 ++--
drivers/net/geneve.c | 4 ++--
drivers/net/vxlan/vxlan_core.c | 2 +-
include/net/ip_tunnels.h | 13 ++++++++-----
4 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c
index e057526448d7..fa2dd76ba3d9 100644
--- a/drivers/net/bareudp.c
+++ b/drivers/net/bareudp.c
@@ -317,7 +317,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,
__be32 saddr;
int err;
- if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
+ if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
return -EINVAL;
if (!sock)
@@ -387,7 +387,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
__be16 sport;
int err;
- if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
+ if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB)))
return -EINVAL;
if (!sock)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 7f611c74eb62..2f29b1386b1c 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -827,7 +827,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
__be16 sport;
int err;
- if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
+ if (skb_vlan_inet_prepare(skb, inner_proto_inherit))
return -EINVAL;
if (!gs4)
@@ -937,7 +937,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
__be16 sport;
int err;
- if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
+ if (skb_vlan_inet_prepare(skb, inner_proto_inherit))
return -EINVAL;
if (!gs6)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 53dcb9fffc04..0359c750d81e 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2356,7 +2356,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
__be32 vni = 0;
no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB);
- if (!skb_vlan_inet_prepare(skb, no_eth_encap))
+ if (skb_vlan_inet_prepare(skb, no_eth_encap))
goto drop;
old_iph = ip_hdr(skb);
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 7fc2f7bf837a..4e4f9e24c9c1 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -467,11 +467,12 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb)
/* Variant of pskb_inet_may_pull().
*/
-static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
- bool inner_proto_inherit)
+static inline enum skb_drop_reason
+skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit)
{
int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
__be16 type = skb->protocol;
+ enum skb_drop_reason reason;
/* Essentially this is skb_protocol(skb, true)
* And we get MAC len.
@@ -492,11 +493,13 @@ static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
/* For ETH_P_IPV6/ETH_P_IP we make sure to pull
* a base network header in skb->head.
*/
- if (!pskb_may_pull(skb, maclen + nhlen))
- return false;
+ reason = pskb_may_pull_reason(skb, maclen + nhlen);
+ if (reason)
+ return reason;
skb_set_network_header(skb, maclen);
- return true;
+
+ return SKB_NOT_DROPPED_YET;
}
static inline int ip_encap_hlen(struct ip_tunnel_encap *e)
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 04/12] net: vxlan: add skb drop reasons to vxlan_rcv()
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (2 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 03/12] net: tunnel: make skb_vlan_inet_prepare() return drop reasons Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Menglong Dong
` (7 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Introduce skb drop reasons to the function vxlan_rcv(). Following new
drop reasons are added:
SKB_DROP_REASON_VXLAN_INVALID_HDR
SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND
SKB_DROP_REASON_IP_TUNNEL_ECN
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v3:
- modify vxlan_set_mac() and vxlan_remcsum() after this patch
v2:
- rename the drop reasons, as Ido advised.
- document the drop reasons
---
drivers/net/vxlan/vxlan_core.c | 26 ++++++++++++++++++++------
include/net/dropreason-core.h | 16 ++++++++++++++++
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 0359c750d81e..4997a2c09c14 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1671,13 +1671,15 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
struct vxlan_metadata _md;
struct vxlan_metadata *md = &_md;
__be16 protocol = htons(ETH_P_TEB);
+ enum skb_drop_reason reason;
bool raw_proto = false;
void *oiph;
__be32 vni = 0;
int nh;
/* Need UDP and VXLAN header to be present */
- if (!pskb_may_pull(skb, VXLAN_HLEN))
+ reason = pskb_may_pull_reason(skb, VXLAN_HLEN);
+ if (reason)
goto drop;
unparsed = *vxlan_hdr(skb);
@@ -1686,6 +1688,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n",
ntohl(vxlan_hdr(skb)->vx_flags),
ntohl(vxlan_hdr(skb)->vx_vni));
+ reason = SKB_DROP_REASON_VXLAN_INVALID_HDR;
/* Return non vxlan pkt */
goto drop;
}
@@ -1699,8 +1702,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
vni = vxlan_vni(vxlan_hdr(skb)->vx_vni);
vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex, vni, &vninode);
- if (!vxlan)
+ if (!vxlan) {
+ reason = SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND;
goto drop;
+ }
/* For backwards compatibility, only allow reserved fields to be
* used by VXLAN extensions if explicitly requested.
@@ -1713,8 +1718,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
}
if (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,
- !net_eq(vxlan->net, dev_net(vxlan->dev))))
+ !net_eq(vxlan->net, dev_net(vxlan->dev)))) {
+ reason = SKB_DROP_REASON_NOMEM;
goto drop;
+ }
if (vs->flags & VXLAN_F_REMCSUM_RX)
if (unlikely(!vxlan_remcsum(&unparsed, skb, vs->flags)))
@@ -1728,8 +1735,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
tun_dst = udp_tun_rx_dst(skb, vxlan_get_sk_family(vs), flags,
key32_to_tunnel_id(vni), sizeof(*md));
- if (!tun_dst)
+ if (!tun_dst) {
+ reason = SKB_DROP_REASON_NOMEM;
goto drop;
+ }
md = ip_tunnel_info_opts(&tun_dst->u.tun_info);
@@ -1753,6 +1762,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
* is more robust and provides a little more security in
* adding extensions to VXLAN.
*/
+ reason = SKB_DROP_REASON_VXLAN_INVALID_HDR;
goto drop;
}
@@ -1773,7 +1783,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
skb_reset_network_header(skb);
- if (!pskb_inet_may_pull(skb)) {
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason) {
DEV_STATS_INC(vxlan->dev, rx_length_errors);
DEV_STATS_INC(vxlan->dev, rx_errors);
vxlan_vnifilter_count(vxlan, vni, vninode,
@@ -1785,6 +1796,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
oiph = skb->head + nh;
if (!vxlan_ecn_decapsulate(vs, oiph, skb)) {
+ reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
DEV_STATS_INC(vxlan->dev, rx_frame_errors);
DEV_STATS_INC(vxlan->dev, rx_errors);
vxlan_vnifilter_count(vxlan, vni, vninode,
@@ -1799,6 +1811,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
dev_core_stats_rx_dropped_inc(vxlan->dev);
vxlan_vnifilter_count(vxlan, vni, vninode,
VXLAN_VNI_STATS_RX_DROPS, 0);
+ reason = SKB_DROP_REASON_DEV_READY;
goto drop;
}
@@ -1811,8 +1824,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
return 0;
drop:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
/* Consume bad packet */
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 4748680e8c88..98259d2b3e92 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -92,6 +92,9 @@
FN(PACKET_SOCK_ERROR) \
FN(TC_CHAIN_NOTFOUND) \
FN(TC_RECLASSIFY_LOOP) \
+ FN(VXLAN_INVALID_HDR) \
+ FN(VXLAN_VNI_NOT_FOUND) \
+ FN(IP_TUNNEL_ECN) \
FNe(MAX)
/**
@@ -418,6 +421,19 @@ enum skb_drop_reason {
* iterations.
*/
SKB_DROP_REASON_TC_RECLASSIFY_LOOP,
+ /**
+ * @SKB_DROP_REASON_VXLAN_INVALID_HDR: VXLAN header is invalid. E.g.:
+ * 1) reserved fields are not zero
+ * 2) "I" flag is not set
+ */
+ SKB_DROP_REASON_VXLAN_INVALID_HDR,
+ /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */
+ SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND,
+ /**
+ * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to
+ * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
+ */
+ SKB_DROP_REASON_IP_TUNNEL_ECN,
/**
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
* shouldn't be used as a real 'reason' - only for tracing code gen
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 05/12] net: vxlan: make vxlan_remcsum() return drop reasons
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (3 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 06/12] net: vxlan: make vxlan_snoop() " Menglong Dong
` (6 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev,
Kalesh AP
Make vxlan_remcsum() support skb drop reasons by changing the return
value type of it from bool to enum skb_drop_reason.
The only drop reason in vxlan_remcsum() comes from pskb_may_pull_reason(),
so we just return it.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
v3:
- add a empty newline before return, as Alexander advised
- adjust the call of vxlan_remcsum()
---
drivers/net/vxlan/vxlan_core.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 4997a2c09c14..34b44755f663 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1551,9 +1551,11 @@ static void vxlan_sock_release(struct vxlan_dev *vxlan)
#endif
}
-static bool vxlan_remcsum(struct vxlanhdr *unparsed,
- struct sk_buff *skb, u32 vxflags)
+static enum skb_drop_reason vxlan_remcsum(struct vxlanhdr *unparsed,
+ struct sk_buff *skb,
+ u32 vxflags)
{
+ enum skb_drop_reason reason;
size_t start, offset;
if (!(unparsed->vx_flags & VXLAN_HF_RCO) || skb->remcsum_offload)
@@ -1562,15 +1564,17 @@ static bool vxlan_remcsum(struct vxlanhdr *unparsed,
start = vxlan_rco_start(unparsed->vx_vni);
offset = start + vxlan_rco_offset(unparsed->vx_vni);
- if (!pskb_may_pull(skb, offset + sizeof(u16)))
- return false;
+ reason = pskb_may_pull_reason(skb, offset + sizeof(u16));
+ if (reason)
+ return reason;
skb_remcsum_process(skb, (void *)(vxlan_hdr(skb) + 1), start, offset,
!!(vxflags & VXLAN_F_REMCSUM_NOPARTIAL));
out:
unparsed->vx_flags &= ~VXLAN_HF_RCO;
unparsed->vx_vni &= VXLAN_VNI_MASK;
- return true;
+
+ return SKB_NOT_DROPPED_YET;
}
static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed,
@@ -1723,9 +1727,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
goto drop;
}
- if (vs->flags & VXLAN_F_REMCSUM_RX)
- if (unlikely(!vxlan_remcsum(&unparsed, skb, vs->flags)))
+ if (vs->flags & VXLAN_F_REMCSUM_RX) {
+ reason = vxlan_remcsum(&unparsed, skb, vs->flags);
+ if (unlikely(reason))
goto drop;
+ }
if (vxlan_collect_metadata(vs)) {
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 06/12] net: vxlan: make vxlan_snoop() return drop reasons
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (4 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 07/12] net: vxlan: make vxlan_set_mac() " Menglong Dong
` (5 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Change the return type of vxlan_snoop() from bool to enum
skb_drop_reason. In this commit, two drop reasons are introduced:
SKB_DROP_REASON_MAC_INVALID_SOURCE
SKB_DROP_REASON_VXLAN_ENTRY_EXISTS
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v5:
- rename SKB_DROP_REASON_VXLAN_INVALID_SMAC to
SKB_DROP_REASON_MAC_INVALID_SOURCE in the commit log
v4:
- rename SKB_DROP_REASON_VXLAN_INVALID_SMAC to
SKB_DROP_REASON_MAC_INVALID_SOURCE
---
drivers/net/vxlan/vxlan_core.c | 17 +++++++++--------
include/net/dropreason-core.h | 9 +++++++++
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 34b44755f663..1a81a3957327 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1437,9 +1437,10 @@ static int vxlan_fdb_get(struct sk_buff *skb,
* and Tunnel endpoint.
* Return true if packet is bogus and should be dropped.
*/
-static bool vxlan_snoop(struct net_device *dev,
- union vxlan_addr *src_ip, const u8 *src_mac,
- u32 src_ifindex, __be32 vni)
+static enum skb_drop_reason vxlan_snoop(struct net_device *dev,
+ union vxlan_addr *src_ip,
+ const u8 *src_mac, u32 src_ifindex,
+ __be32 vni)
{
struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_fdb *f;
@@ -1447,7 +1448,7 @@ static bool vxlan_snoop(struct net_device *dev,
/* Ignore packets from invalid src-address */
if (!is_valid_ether_addr(src_mac))
- return true;
+ return SKB_DROP_REASON_MAC_INVALID_SOURCE;
#if IS_ENABLED(CONFIG_IPV6)
if (src_ip->sa.sa_family == AF_INET6 &&
@@ -1461,15 +1462,15 @@ static bool vxlan_snoop(struct net_device *dev,
if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) &&
rdst->remote_ifindex == ifindex))
- return false;
+ return SKB_NOT_DROPPED_YET;
/* Don't migrate static entries, drop packets */
if (f->state & (NUD_PERMANENT | NUD_NOARP))
- return true;
+ return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS;
/* Don't override an fdb with nexthop with a learnt entry */
if (rcu_access_pointer(f->nh))
- return true;
+ return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS;
if (net_ratelimit())
netdev_info(dev,
@@ -1497,7 +1498,7 @@ static bool vxlan_snoop(struct net_device *dev,
spin_unlock(&vxlan->hash_lock[hash_index]);
}
- return false;
+ return SKB_NOT_DROPPED_YET;
}
static bool __vxlan_sock_release_prep(struct vxlan_sock *vs)
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 98259d2b3e92..1cb8d7c953be 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -94,6 +94,8 @@
FN(TC_RECLASSIFY_LOOP) \
FN(VXLAN_INVALID_HDR) \
FN(VXLAN_VNI_NOT_FOUND) \
+ FN(MAC_INVALID_SOURCE) \
+ FN(VXLAN_ENTRY_EXISTS) \
FN(IP_TUNNEL_ECN) \
FNe(MAX)
@@ -429,6 +431,13 @@ enum skb_drop_reason {
SKB_DROP_REASON_VXLAN_INVALID_HDR,
/** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */
SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND,
+ /** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */
+ SKB_DROP_REASON_MAC_INVALID_SOURCE,
+ /**
+ * @SKB_DROP_REASON_VXLAN_ENTRY_EXISTS: trying to migrate a static
+ * entry or an entry pointing to a nexthop.
+ */
+ SKB_DROP_REASON_VXLAN_ENTRY_EXISTS,
/**
* @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to
* RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 07/12] net: vxlan: make vxlan_set_mac() return drop reasons
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (5 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 06/12] net: vxlan: make vxlan_snoop() " Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Menglong Dong
` (4 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Change the return type of vxlan_set_mac() from bool to enum
skb_drop_reason. In this commit, the drop reason
"SKB_DROP_REASON_LOCAL_MAC" is introduced for the case that the source
mac of the packet is a local mac.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v5:
- modify the document of SKB_DROP_REASON_LOCAL_MAC
v3:
- adjust the call of vxlan_set_mac()
- add SKB_DROP_REASON_LOCAL_MAC
---
drivers/net/vxlan/vxlan_core.c | 19 ++++++++++---------
include/net/dropreason-core.h | 6 ++++++
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 1a81a3957327..41191a28252a 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1609,9 +1609,9 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed,
unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS;
}
-static bool vxlan_set_mac(struct vxlan_dev *vxlan,
- struct vxlan_sock *vs,
- struct sk_buff *skb, __be32 vni)
+static enum skb_drop_reason vxlan_set_mac(struct vxlan_dev *vxlan,
+ struct vxlan_sock *vs,
+ struct sk_buff *skb, __be32 vni)
{
union vxlan_addr saddr;
u32 ifindex = skb->dev->ifindex;
@@ -1622,7 +1622,7 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
/* Ignore packet loops (and multicast echo) */
if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
- return false;
+ return SKB_DROP_REASON_LOCAL_MAC;
/* Get address from the outer IP header */
if (vxlan_get_sk_family(vs) == AF_INET) {
@@ -1635,11 +1635,11 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
#endif
}
- if ((vxlan->cfg.flags & VXLAN_F_LEARN) &&
- vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex, vni))
- return false;
+ if (!(vxlan->cfg.flags & VXLAN_F_LEARN))
+ return SKB_NOT_DROPPED_YET;
- return true;
+ return vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source,
+ ifindex, vni);
}
static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,
@@ -1774,7 +1774,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
}
if (!raw_proto) {
- if (!vxlan_set_mac(vxlan, vs, skb, vni))
+ reason = vxlan_set_mac(vxlan, vs, skb, vni);
+ if (reason)
goto drop;
} else {
skb_reset_mac_header(skb);
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 1cb8d7c953be..fbf92d442c1b 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -97,6 +97,7 @@
FN(MAC_INVALID_SOURCE) \
FN(VXLAN_ENTRY_EXISTS) \
FN(IP_TUNNEL_ECN) \
+ FN(LOCAL_MAC) \
FNe(MAX)
/**
@@ -443,6 +444,11 @@ enum skb_drop_reason {
* RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
*/
SKB_DROP_REASON_IP_TUNNEL_ECN,
+ /**
+ * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
+ * the MAC address of the local netdev.
+ */
+ SKB_DROP_REASON_LOCAL_MAC,
/**
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
* shouldn't be used as a real 'reason' - only for tracing code gen
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit()
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (6 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 07/12] net: vxlan: make vxlan_set_mac() " Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 8:53 ` Guillaume Nault
2024-10-08 12:28 ` Simon Horman
2024-10-06 6:56 ` [PATCH net-next v5 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Menglong Dong
` (3 subsequent siblings)
11 siblings, 2 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
new skb drop reasons are introduced for vxlan:
/* no remote found for xmit */
SKB_DROP_REASON_VXLAN_NO_REMOTE
/* packet without necessary metatdata reached a device is in "eternal"
* mode.
*/
SKB_DROP_REASON_TUNNEL_TXINFO
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
v5:
- modify the document for SKB_DROP_REASON_TUNNEL_TXINFO
v2:
- move the drop reason "TXINFO" from vxlan to core
- rename VXLAN_DROP_REMOTE to VXLAN_DROP_NO_REMOTE
---
drivers/net/vxlan/vxlan_core.c | 6 +++---
include/net/dropreason-core.h | 8 ++++++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 41191a28252a..b677ec901807 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2730,7 +2730,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
if (info && info->mode & IP_TUNNEL_INFO_TX)
vxlan_xmit_one(skb, dev, vni, NULL, false);
else
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_TUNNEL_TXINFO);
return NETDEV_TX_OK;
}
}
@@ -2793,7 +2793,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
dev_core_stats_tx_dropped_inc(dev);
vxlan_vnifilter_count(vxlan, vni, NULL,
VXLAN_VNI_STATS_TX_DROPS, 0);
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE);
return NETDEV_TX_OK;
}
}
@@ -2816,7 +2816,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
if (fdst)
vxlan_xmit_one(skb, dev, vni, fdst, did_rsc);
else
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE);
}
return NETDEV_TX_OK;
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index fbf92d442c1b..0a2407e7e93f 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -96,7 +96,9 @@
FN(VXLAN_VNI_NOT_FOUND) \
FN(MAC_INVALID_SOURCE) \
FN(VXLAN_ENTRY_EXISTS) \
+ FN(VXLAN_NO_REMOTE) \
FN(IP_TUNNEL_ECN) \
+ FN(TUNNEL_TXINFO) \
FN(LOCAL_MAC) \
FNe(MAX)
@@ -439,11 +441,17 @@ enum skb_drop_reason {
* entry or an entry pointing to a nexthop.
*/
SKB_DROP_REASON_VXLAN_ENTRY_EXISTS,
+ /** @SKB_DROP_REASON_VXLAN_NO_REMOTE: no remote found for xmit */
+ SKB_DROP_REASON_VXLAN_NO_REMOTE,
/**
* @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to
* RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
*/
SKB_DROP_REASON_IP_TUNNEL_ECN,
+ /** @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metatdata
+ * reached a device is in "eternal" mode.
+ */
+ SKB_DROP_REASON_TUNNEL_TXINFO,
/**
* @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
* the MAC address of the local netdev.
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one()
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (7 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Menglong Dong
` (2 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Replace kfree_skb/dev_kfree_skb with kfree_skb_reason in vxlan_xmit_one.
No drop reasons are introduced in this commit.
The only concern of mine is replacing dev_kfree_skb with
kfree_skb_reason. The dev_kfree_skb is equal to consume_skb, and I'm not
sure if we can change it to kfree_skb here. In my option, the skb is
"dropped" here, isn't it?
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/vxlan/vxlan_core.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index b677ec901807..508693fa4fd9 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2374,13 +2374,16 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
bool use_cache;
bool udp_sum = false;
bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev));
+ enum skb_drop_reason reason;
bool no_eth_encap;
__be32 vni = 0;
no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB);
- if (skb_vlan_inet_prepare(skb, no_eth_encap))
+ reason = skb_vlan_inet_prepare(skb, no_eth_encap);
+ if (reason)
goto drop;
+ reason = SKB_DROP_REASON_NOT_SPECIFIED;
old_iph = ip_hdr(skb);
info = skb_tunnel_info(skb);
@@ -2484,6 +2487,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
tos, use_cache ? dst_cache : NULL);
if (IS_ERR(rt)) {
err = PTR_ERR(rt);
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
@@ -2535,8 +2539,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
err = vxlan_build_skb(skb, ndst, sizeof(struct iphdr),
vni, md, flags, udp_sum);
- if (err < 0)
+ if (err < 0) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_error;
+ }
udp_tunnel_xmit_skb(rt, sock4->sock->sk, skb, saddr,
pkey->u.ipv4.dst, tos, ttl, df,
@@ -2556,6 +2562,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
if (IS_ERR(ndst)) {
err = PTR_ERR(ndst);
ndst = NULL;
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
@@ -2596,8 +2603,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
skb_scrub_packet(skb, xnet);
err = vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr),
vni, md, flags, udp_sum);
- if (err < 0)
+ if (err < 0) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_error;
+ }
udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev,
&saddr, &pkey->u.ipv6.dst, tos, ttl,
@@ -2612,7 +2621,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
drop:
dev_core_stats_tx_dropped_inc(dev);
vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0);
- dev_kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return;
tx_error:
@@ -2624,7 +2633,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
dst_release(ndst);
DEV_STATS_INC(dev, tx_errors);
vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_ERRORS, 0);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
}
static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev,
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit()
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (8 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Menglong Dong
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Replace kfree_skb() with kfree_skb_reason() in vxlan_mdb_xmit. No drop
reasons are introduced in this commit.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/vxlan/vxlan_mdb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/vxlan/vxlan_mdb.c b/drivers/net/vxlan/vxlan_mdb.c
index 60eb95a06d55..e1173ae13428 100644
--- a/drivers/net/vxlan/vxlan_mdb.c
+++ b/drivers/net/vxlan/vxlan_mdb.c
@@ -1712,7 +1712,7 @@ netdev_tx_t vxlan_mdb_xmit(struct vxlan_dev *vxlan,
vxlan_xmit_one(skb, vxlan->dev, src_vni,
rcu_dereference(fremote->rd), false);
else
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE);
return NETDEV_TX_OK;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass()
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (9 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Menglong Dong
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev
Replace kfree_skb with kfree_skb_reason in vxlan_encap_bypass, and no new
skb drop reason is added in this commit.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/vxlan/vxlan_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 508693fa4fd9..da4de19d0331 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2290,7 +2290,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan,
rcu_read_lock();
dev = skb->dev;
if (unlikely(!(dev->flags & IFF_UP))) {
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_DEV_READY);
goto drop;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next v5 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local()
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
` (10 preceding siblings ...)
2024-10-06 6:56 ` [PATCH net-next v5 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Menglong Dong
@ 2024-10-06 6:56 ` Menglong Dong
11 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-06 6:56 UTC (permalink / raw)
To: idosch, kuba, aleksander.lobakin, horms
Cc: davem, edumazet, pabeni, dsahern, dongml2, amcohen, gnault,
bpoirier, b.galvani, razor, petrm, linux-kernel, netdev,
Kalesh AP
Replace kfree_skb() with kfree_skb_reason() in encap_bypass_if_local, and
no new skb drop reason is added in this commit.
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
drivers/net/vxlan/vxlan_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index da4de19d0331..f7e94bb8e30e 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -2341,7 +2341,7 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,
DEV_STATS_INC(dev, tx_errors);
vxlan_vnifilter_count(vxlan, vni, NULL,
VXLAN_VNI_STATS_TX_ERRORS, 0);
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_INVALID_HDR);
return -ENOENT;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit()
2024-10-06 6:56 ` [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Menglong Dong
@ 2024-10-06 8:53 ` Guillaume Nault
2024-10-07 2:00 ` Menglong Dong
2024-10-08 12:28 ` Simon Horman
1 sibling, 1 reply; 17+ messages in thread
From: Guillaume Nault @ 2024-10-06 8:53 UTC (permalink / raw)
To: Menglong Dong
Cc: idosch, kuba, aleksander.lobakin, horms, davem, edumazet, pabeni,
dsahern, dongml2, amcohen, bpoirier, b.galvani, razor, petrm,
linux-kernel, netdev
On Sun, Oct 06, 2024 at 02:56:12PM +0800, Menglong Dong wrote:
> + /** @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metatdata
> + * reached a device is in "eternal" mode.
Maybe 'a device which is in "external" mode.' instead?
> + */
> + SKB_DROP_REASON_TUNNEL_TXINFO,
> /**
> * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
> * the MAC address of the local netdev.
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit()
2024-10-06 8:53 ` Guillaume Nault
@ 2024-10-07 2:00 ` Menglong Dong
0 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-07 2:00 UTC (permalink / raw)
To: Guillaume Nault
Cc: idosch, kuba, aleksander.lobakin, horms, davem, edumazet, pabeni,
dsahern, dongml2, amcohen, bpoirier, b.galvani, razor, petrm,
linux-kernel, netdev
On Sun, Oct 6, 2024 at 4:53 PM Guillaume Nault <gnault@redhat.com> wrote:
>
> On Sun, Oct 06, 2024 at 02:56:12PM +0800, Menglong Dong wrote:
> > + /** @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metatdata
> > + * reached a device is in "eternal" mode.
>
> Maybe 'a device which is in "external" mode.' instead?
Yeah, there are some typos in this document. I'll
fix it in the next version.
Thanks!
Menglong Dong
>
> > + */
> > + SKB_DROP_REASON_TUNNEL_TXINFO,
> > /**
> > * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
> > * the MAC address of the local netdev.
> > --
> > 2.39.5
> >
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit()
2024-10-06 6:56 ` [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Menglong Dong
2024-10-06 8:53 ` Guillaume Nault
@ 2024-10-08 12:28 ` Simon Horman
2024-10-08 14:06 ` Menglong Dong
1 sibling, 1 reply; 17+ messages in thread
From: Simon Horman @ 2024-10-08 12:28 UTC (permalink / raw)
To: Menglong Dong
Cc: idosch, kuba, aleksander.lobakin, davem, edumazet, pabeni,
dsahern, dongml2, amcohen, gnault, bpoirier, b.galvani, razor,
petrm, linux-kernel, netdev
On Sun, Oct 06, 2024 at 02:56:12PM +0800, Menglong Dong wrote:
> Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
> new skb drop reasons are introduced for vxlan:
>
> /* no remote found for xmit */
> SKB_DROP_REASON_VXLAN_NO_REMOTE
> /* packet without necessary metatdata reached a device is in "eternal"
> * mode.
> */
> SKB_DROP_REASON_TUNNEL_TXINFO
nit: metadata
Flagged by checkpatch.pl --codespell
>
> Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> Reviewed-by: Simon Horman <horms@kernel.org>
...
> diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
...
> @@ -439,11 +441,17 @@ enum skb_drop_reason {
> * entry or an entry pointing to a nexthop.
> */
> SKB_DROP_REASON_VXLAN_ENTRY_EXISTS,
> + /** @SKB_DROP_REASON_VXLAN_NO_REMOTE: no remote found for xmit */
> + SKB_DROP_REASON_VXLAN_NO_REMOTE,
> /**
> * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to
> * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
> */
> SKB_DROP_REASON_IP_TUNNEL_ECN,
> + /** @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metatdata
> + * reached a device is in "eternal" mode.
> + */
> + SKB_DROP_REASON_TUNNEL_TXINFO,
nit: ./scripts/kernel-doc would like this to be formatted as follows.
And metadata is misspelt.
/**
* @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metadata
* reached a device is in "eternal" mode.
*/
SKB_DROP_REASON_TUNNEL_TXINFO,
> /**
> * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
> * the MAC address of the local netdev.
> --
> 2.39.5
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit()
2024-10-08 12:28 ` Simon Horman
@ 2024-10-08 14:06 ` Menglong Dong
0 siblings, 0 replies; 17+ messages in thread
From: Menglong Dong @ 2024-10-08 14:06 UTC (permalink / raw)
To: Simon Horman
Cc: idosch, kuba, aleksander.lobakin, davem, edumazet, pabeni,
dsahern, dongml2, amcohen, gnault, bpoirier, b.galvani, razor,
petrm, linux-kernel, netdev
On Tue, Oct 8, 2024 at 8:28 PM Simon Horman <horms@kernel.org> wrote:
>
> On Sun, Oct 06, 2024 at 02:56:12PM +0800, Menglong Dong wrote:
> > Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following
> > new skb drop reasons are introduced for vxlan:
> >
> > /* no remote found for xmit */
> > SKB_DROP_REASON_VXLAN_NO_REMOTE
> > /* packet without necessary metatdata reached a device is in "eternal"
> > * mode.
> > */
> > SKB_DROP_REASON_TUNNEL_TXINFO
>
> nit: metadata
>
> Flagged by checkpatch.pl --codespell
>
> >
> > Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
> > Reviewed-by: Simon Horman <horms@kernel.org>
>
> ...
>
> > diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
>
> ...
>
> > @@ -439,11 +441,17 @@ enum skb_drop_reason {
> > * entry or an entry pointing to a nexthop.
> > */
> > SKB_DROP_REASON_VXLAN_ENTRY_EXISTS,
> > + /** @SKB_DROP_REASON_VXLAN_NO_REMOTE: no remote found for xmit */
> > + SKB_DROP_REASON_VXLAN_NO_REMOTE,
> > /**
> > * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to
> > * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail.
> > */
> > SKB_DROP_REASON_IP_TUNNEL_ECN,
> > + /** @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metatdata
> > + * reached a device is in "eternal" mode.
> > + */
> > + SKB_DROP_REASON_TUNNEL_TXINFO,
>
> nit: ./scripts/kernel-doc would like this to be formatted as follows.
> And metadata is misspelt.
>
Hello, thanks for reminding me. It seems that there is no
more comment on this series, and I'll send a V6 now to
fix this problem.
Thanks!
Menglong Dong
> /**
> * @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metadata
> * reached a device is in "eternal" mode.
> */
> SKB_DROP_REASON_TUNNEL_TXINFO,
>
> > /**
> > * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to
> > * the MAC address of the local netdev.
> > --
> > 2.39.5
> >
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2024-10-08 14:06 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-06 6:56 [PATCH net-next v5 00/12] net: vxlan: add skb drop reasons support Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 01/12] net: skb: add pskb_network_may_pull_reason() helper Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 03/12] net: tunnel: make skb_vlan_inet_prepare() return drop reasons Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 06/12] net: vxlan: make vxlan_snoop() " Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 07/12] net: vxlan: make vxlan_set_mac() " Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Menglong Dong
2024-10-06 8:53 ` Guillaume Nault
2024-10-07 2:00 ` Menglong Dong
2024-10-08 12:28 ` Simon Horman
2024-10-08 14:06 ` Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Menglong Dong
2024-10-06 6:56 ` [PATCH net-next v5 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Menglong Dong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).