* [PATCH net 0/2] geneve fixes
@ 2024-06-06 20:32 Tariq Toukan
2024-06-06 20:32 ` [PATCH net 1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set Tariq Toukan
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Tariq Toukan @ 2024-06-06 20:32 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky,
Tariq Toukan
Hi,
This small patchset by Gal provides bug fixes to the geneve tunnels flows.
Patch 1 fixes an incorrect value returned by the inner network header
offset helper.
Patch 2 fixes an issue inside the mlx5e tunneling flow. It 'happened' to
be harmless so far, before applying patch 1.
Series generated against:
commit d30d0e49da71 ("Merge tag 'net-6.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
Regards,
Tariq
Gal Pressman (2):
geneve: Fix incorrect inner network header offset when
innerprotoinherit is set
net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN)
packets
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +--
drivers/net/geneve.c | 10 ++++++----
include/net/ip_tunnels.h | 5 +++--
3 files changed, 10 insertions(+), 8 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net 1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set
2024-06-06 20:32 [PATCH net 0/2] geneve fixes Tariq Toukan
@ 2024-06-06 20:32 ` Tariq Toukan
2024-06-07 11:10 ` Wojciech Drewek
2024-06-06 20:32 ` [PATCH net 2/2] net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN) packets Tariq Toukan
2024-06-10 12:20 ` [PATCH net 0/2] geneve fixes patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Tariq Toukan @ 2024-06-06 20:32 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky,
Tariq Toukan
From: Gal Pressman <gal@nvidia.com>
When innerprotoinherit is set, the tunneled packets do not have an inner
Ethernet header.
Change 'maclen' to not always assume the header length is ETH_HLEN, as
there might not be a MAC header.
This resolves issues with drivers (e.g. mlx5, in
mlx5e_tx_tunnel_accel()) who rely on the skb inner network header offset
to be correct, and use it for TX offloads.
Fixes: d8a6213d70ac ("geneve: fix header validation in geneve[6]_xmit_skb")
Signed-off-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/geneve.c | 10 ++++++----
include/net/ip_tunnels.h | 5 +++--
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 51495cb4b9be..838e85ddec67 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -815,6 +815,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
struct geneve_dev *geneve,
const struct ip_tunnel_info *info)
{
+ bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
struct geneve_sock *gs4 = rcu_dereference(geneve->sock4);
const struct ip_tunnel_key *key = &info->key;
@@ -826,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))
+ if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
return -EINVAL;
if (!gs4)
@@ -908,7 +909,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
}
err = geneve_build_skb(&rt->dst, skb, info, xnet, sizeof(struct iphdr),
- geneve->cfg.inner_proto_inherit);
+ inner_proto_inherit);
if (unlikely(err))
return err;
@@ -925,6 +926,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
struct geneve_dev *geneve,
const struct ip_tunnel_info *info)
{
+ bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
struct geneve_sock *gs6 = rcu_dereference(geneve->sock6);
const struct ip_tunnel_key *key = &info->key;
@@ -935,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))
+ if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
return -EINVAL;
if (!gs6)
@@ -997,7 +999,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
ttl = ttl ? : ip6_dst_hoplimit(dst);
}
err = geneve_build_skb(dst, skb, info, xnet, sizeof(struct ipv6hdr),
- geneve->cfg.inner_proto_inherit);
+ inner_proto_inherit);
if (unlikely(err))
return err;
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 9a6a08ec7713..1db2417b8ff5 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -461,9 +461,10 @@ 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)
+static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
+ bool inner_proto_inherit)
{
- int nhlen = 0, maclen = ETH_HLEN;
+ int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
__be16 type = skb->protocol;
/* Essentially this is skb_protocol(skb, true)
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net 2/2] net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN) packets
2024-06-06 20:32 [PATCH net 0/2] geneve fixes Tariq Toukan
2024-06-06 20:32 ` [PATCH net 1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set Tariq Toukan
@ 2024-06-06 20:32 ` Tariq Toukan
2024-06-07 11:13 ` Wojciech Drewek
2024-06-10 12:20 ` [PATCH net 0/2] geneve fixes patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Tariq Toukan @ 2024-06-06 20:32 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky,
Dragos Tatulea, Tariq Toukan
From: Gal Pressman <gal@nvidia.com>
Move the vxlan_features_check() call to after we verified the packet is
a tunneled VXLAN packet.
Without this, tunneled UDP non-VXLAN packets (for ex. GENENVE) might
wrongly not get offloaded.
In some cases, it worked by chance as GENEVE header is the same size as
VXLAN, but it is obviously incorrect.
Fixes: e3cfc7e6b7bd ("net/mlx5e: TX, Add geneve tunnel stateless offload support")
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index c53c99dde558..a605eae56685 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4875,7 +4875,7 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
/* Verify if UDP port is being offloaded by HW */
if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port))
- return features;
+ return vxlan_features_check(skb, features);
#if IS_ENABLED(CONFIG_GENEVE)
/* Support Geneve offload for default UDP port */
@@ -4901,7 +4901,6 @@ netdev_features_t mlx5e_features_check(struct sk_buff *skb,
struct mlx5e_priv *priv = netdev_priv(netdev);
features = vlan_features_check(skb, features);
- features = vxlan_features_check(skb, features);
/* Validate if the tunneled packet is being offloaded by HW */
if (skb->encapsulation &&
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net 1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set
2024-06-06 20:32 ` [PATCH net 1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set Tariq Toukan
@ 2024-06-07 11:10 ` Wojciech Drewek
0 siblings, 0 replies; 6+ messages in thread
From: Wojciech Drewek @ 2024-06-07 11:10 UTC (permalink / raw)
To: Tariq Toukan, David S. Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky
On 06.06.2024 22:32, Tariq Toukan wrote:
> From: Gal Pressman <gal@nvidia.com>
>
> When innerprotoinherit is set, the tunneled packets do not have an inner
> Ethernet header.
> Change 'maclen' to not always assume the header length is ETH_HLEN, as
> there might not be a MAC header.
>
> This resolves issues with drivers (e.g. mlx5, in
> mlx5e_tx_tunnel_accel()) who rely on the skb inner network header offset
> to be correct, and use it for TX offloads.
>
> Fixes: d8a6213d70ac ("geneve: fix header validation in geneve[6]_xmit_skb")
> Signed-off-by: Gal Pressman <gal@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
Thanks!
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> drivers/net/geneve.c | 10 ++++++----
> include/net/ip_tunnels.h | 5 +++--
> 2 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> index 51495cb4b9be..838e85ddec67 100644
> --- a/drivers/net/geneve.c
> +++ b/drivers/net/geneve.c
> @@ -815,6 +815,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> struct geneve_dev *geneve,
> const struct ip_tunnel_info *info)
> {
> + bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
> bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
> struct geneve_sock *gs4 = rcu_dereference(geneve->sock4);
> const struct ip_tunnel_key *key = &info->key;
> @@ -826,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))
> + if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
> return -EINVAL;
>
> if (!gs4)
> @@ -908,7 +909,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> }
>
> err = geneve_build_skb(&rt->dst, skb, info, xnet, sizeof(struct iphdr),
> - geneve->cfg.inner_proto_inherit);
> + inner_proto_inherit);
> if (unlikely(err))
> return err;
>
> @@ -925,6 +926,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> struct geneve_dev *geneve,
> const struct ip_tunnel_info *info)
> {
> + bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
> bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
> struct geneve_sock *gs6 = rcu_dereference(geneve->sock6);
> const struct ip_tunnel_key *key = &info->key;
> @@ -935,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))
> + if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
> return -EINVAL;
>
> if (!gs6)
> @@ -997,7 +999,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> ttl = ttl ? : ip6_dst_hoplimit(dst);
> }
> err = geneve_build_skb(dst, skb, info, xnet, sizeof(struct ipv6hdr),
> - geneve->cfg.inner_proto_inherit);
> + inner_proto_inherit);
> if (unlikely(err))
> return err;
>
> diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
> index 9a6a08ec7713..1db2417b8ff5 100644
> --- a/include/net/ip_tunnels.h
> +++ b/include/net/ip_tunnels.h
> @@ -461,9 +461,10 @@ 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)
> +static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
> + bool inner_proto_inherit)
> {
> - int nhlen = 0, maclen = ETH_HLEN;
> + int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
> __be16 type = skb->protocol;
>
> /* Essentially this is skb_protocol(skb, true)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 2/2] net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN) packets
2024-06-06 20:32 ` [PATCH net 2/2] net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN) packets Tariq Toukan
@ 2024-06-07 11:13 ` Wojciech Drewek
0 siblings, 0 replies; 6+ messages in thread
From: Wojciech Drewek @ 2024-06-07 11:13 UTC (permalink / raw)
To: Tariq Toukan, David S. Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: netdev, Saeed Mahameed, Gal Pressman, Leon Romanovsky,
Dragos Tatulea
On 06.06.2024 22:32, Tariq Toukan wrote:
> From: Gal Pressman <gal@nvidia.com>
>
> Move the vxlan_features_check() call to after we verified the packet is
> a tunneled VXLAN packet.
>
> Without this, tunneled UDP non-VXLAN packets (for ex. GENENVE) might
> wrongly not get offloaded.
> In some cases, it worked by chance as GENEVE header is the same size as
> VXLAN, but it is obviously incorrect.
>
> Fixes: e3cfc7e6b7bd ("net/mlx5e: TX, Add geneve tunnel stateless offload support")
> Signed-off-by: Gal Pressman <gal@nvidia.com>
> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
> Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
> ---
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index c53c99dde558..a605eae56685 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -4875,7 +4875,7 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
>
> /* Verify if UDP port is being offloaded by HW */
> if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port))
> - return features;
> + return vxlan_features_check(skb, features);
>
> #if IS_ENABLED(CONFIG_GENEVE)
> /* Support Geneve offload for default UDP port */
> @@ -4901,7 +4901,6 @@ netdev_features_t mlx5e_features_check(struct sk_buff *skb,
> struct mlx5e_priv *priv = netdev_priv(netdev);
>
> features = vlan_features_check(skb, features);
> - features = vxlan_features_check(skb, features);
>
> /* Validate if the tunneled packet is being offloaded by HW */
> if (skb->encapsulation &&
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net 0/2] geneve fixes
2024-06-06 20:32 [PATCH net 0/2] geneve fixes Tariq Toukan
2024-06-06 20:32 ` [PATCH net 1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set Tariq Toukan
2024-06-06 20:32 ` [PATCH net 2/2] net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN) packets Tariq Toukan
@ 2024-06-10 12:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-10 12:20 UTC (permalink / raw)
To: Tariq Toukan; +Cc: davem, kuba, pabeni, edumazet, netdev, saeedm, gal, leonro
Hello:
This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 6 Jun 2024 23:32:47 +0300 you wrote:
> Hi,
>
> This small patchset by Gal provides bug fixes to the geneve tunnels flows.
>
> Patch 1 fixes an incorrect value returned by the inner network header
> offset helper.
> Patch 2 fixes an issue inside the mlx5e tunneling flow. It 'happened' to
> be harmless so far, before applying patch 1.
>
> [...]
Here is the summary with links:
- [net,1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set
https://git.kernel.org/netdev/net/c/c6ae073f5903
- [net,2/2] net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN) packets
https://git.kernel.org/netdev/net/c/791b4089e326
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] 6+ messages in thread
end of thread, other threads:[~2024-06-10 12:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 20:32 [PATCH net 0/2] geneve fixes Tariq Toukan
2024-06-06 20:32 ` [PATCH net 1/2] geneve: Fix incorrect inner network header offset when innerprotoinherit is set Tariq Toukan
2024-06-07 11:10 ` Wojciech Drewek
2024-06-06 20:32 ` [PATCH net 2/2] net/mlx5e: Fix features validation check for tunneled UDP (non-VXLAN) packets Tariq Toukan
2024-06-07 11:13 ` Wojciech Drewek
2024-06-10 12:20 ` [PATCH net 0/2] geneve fixes patchwork-bot+netdevbpf
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).