Skip to content

Commit c123703

Browse files
committed
geneve: Fix incorrect inner network header offset when innerprotoinherit is set
jira LE-1733 bugfix geneve_fixes commit c6ae073 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: d8a6213 ("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> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit c6ae073) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 901d21f commit c123703

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

drivers/net/geneve.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
908908
struct geneve_dev *geneve,
909909
const struct ip_tunnel_info *info)
910910
{
911+
bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
911912
bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
912913
struct geneve_sock *gs4 = rcu_dereference(geneve->sock4);
913914
const struct ip_tunnel_key *key = &info->key;
@@ -919,7 +920,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
919920
__be16 sport;
920921
int err;
921922

922-
if (!skb_vlan_inet_prepare(skb))
923+
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
923924
return -EINVAL;
924925

925926
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
@@ -992,7 +993,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
992993
}
993994

994995
err = geneve_build_skb(&rt->dst, skb, info, xnet, sizeof(struct iphdr),
995-
geneve->cfg.inner_proto_inherit);
996+
inner_proto_inherit);
996997
if (unlikely(err))
997998
return err;
998999

@@ -1008,6 +1009,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
10081009
struct geneve_dev *geneve,
10091010
const struct ip_tunnel_info *info)
10101011
{
1012+
bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
10111013
bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
10121014
struct geneve_sock *gs6 = rcu_dereference(geneve->sock6);
10131015
const struct ip_tunnel_key *key = &info->key;
@@ -1017,7 +1019,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
10171019
__be16 sport;
10181020
int err;
10191021

1020-
if (!skb_vlan_inet_prepare(skb))
1022+
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
10211023
return -EINVAL;
10221024

10231025
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
@@ -1072,7 +1074,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
10721074
ttl = ttl ? : ip6_dst_hoplimit(dst);
10731075
}
10741076
err = geneve_build_skb(dst, skb, info, xnet, sizeof(struct ipv6hdr),
1075-
geneve->cfg.inner_proto_inherit);
1077+
inner_proto_inherit);
10761078
if (unlikely(err))
10771079
return err;
10781080

include/net/ip_tunnels.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,10 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb)
347347

348348
/* Variant of pskb_inet_may_pull().
349349
*/
350-
static inline bool skb_vlan_inet_prepare(struct sk_buff *skb)
350+
static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
351+
bool inner_proto_inherit)
351352
{
352-
int nhlen = 0, maclen = ETH_HLEN;
353+
int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
353354
__be16 type = skb->protocol;
354355

355356
/* Essentially this is skb_protocol(skb, true)

0 commit comments

Comments
 (0)