Skip to content

Commit c6ae073

Browse files
gal-pressmandavem330
authored andcommitted
geneve: Fix incorrect inner network header offset when innerprotoinherit is set
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 <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d029ede commit c6ae073

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
@@ -815,6 +815,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
815815
struct geneve_dev *geneve,
816816
const struct ip_tunnel_info *info)
817817
{
818+
bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
818819
bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
819820
struct geneve_sock *gs4 = rcu_dereference(geneve->sock4);
820821
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,
826827
__be16 sport;
827828
int err;
828829

829-
if (!skb_vlan_inet_prepare(skb))
830+
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
830831
return -EINVAL;
831832

832833
if (!gs4)
@@ -908,7 +909,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
908909
}
909910

910911
err = geneve_build_skb(&rt->dst, skb, info, xnet, sizeof(struct iphdr),
911-
geneve->cfg.inner_proto_inherit);
912+
inner_proto_inherit);
912913
if (unlikely(err))
913914
return err;
914915

@@ -925,6 +926,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
925926
struct geneve_dev *geneve,
926927
const struct ip_tunnel_info *info)
927928
{
929+
bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
928930
bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
929931
struct geneve_sock *gs6 = rcu_dereference(geneve->sock6);
930932
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,
935937
__be16 sport;
936938
int err;
937939

938-
if (!skb_vlan_inet_prepare(skb))
940+
if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
939941
return -EINVAL;
940942

941943
if (!gs6)
@@ -997,7 +999,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
997999
ttl = ttl ? : ip6_dst_hoplimit(dst);
9981000
}
9991001
err = geneve_build_skb(dst, skb, info, xnet, sizeof(struct ipv6hdr),
1000-
geneve->cfg.inner_proto_inherit);
1002+
inner_proto_inherit);
10011003
if (unlikely(err))
10021004
return err;
10031005

include/net/ip_tunnels.h

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

462462
/* Variant of pskb_inet_may_pull().
463463
*/
464-
static inline bool skb_vlan_inet_prepare(struct sk_buff *skb)
464+
static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
465+
bool inner_proto_inherit)
465466
{
466-
int nhlen = 0, maclen = ETH_HLEN;
467+
int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
467468
__be16 type = skb->protocol;
468469

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

0 commit comments

Comments
 (0)