Skip to content

Commit fcfb55f

Browse files
author
Guillaume Nault
committed
geneve: fix TOS inheriting for ipv4
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2161351 Upstream Status: linux.git commit b4ab94d Author: Matthias May <matthias.may@westermo.com> Date: Fri Aug 5 21:00:06 2022 +0200 geneve: fix TOS inheriting for ipv4 The current code retrieves the TOS field after the lookup on the ipv4 routing table. The routing process currently only allows routing based on the original 3 TOS bits, and not on the full 6 DSCP bits. As a result the retrieved TOS is cut to the 3 bits. However for inheriting purposes the full 6 bits should be used. Extract the full 6 bits before the route lookup and use that instead of the cut off 3 TOS bits. Fixes: e305ac6 ("geneve: Add support to collect tunnel metadata.") Signed-off-by: Matthias May <matthias.may@westermo.com> Acked-by: Guillaume Nault <gnault@redhat.com> Link: https://lore.kernel.org/r/20220805190006.8078-1-matthias.may@westermo.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Guillaume Nault <gnault@redhat.com>
1 parent a70d62a commit fcfb55f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/net/geneve.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *skb,
775775
struct geneve_sock *gs4,
776776
struct flowi4 *fl4,
777777
const struct ip_tunnel_info *info,
778-
__be16 dport, __be16 sport)
778+
__be16 dport, __be16 sport,
779+
__u8 *full_tos)
779780
{
780781
bool use_cache = ip_tunnel_dst_cache_usable(skb, info);
781782
struct geneve_dev *geneve = netdev_priv(dev);
@@ -801,6 +802,8 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *skb,
801802
use_cache = false;
802803
}
803804
fl4->flowi4_tos = RT_TOS(tos);
805+
if (full_tos)
806+
*full_tos = tos;
804807

805808
dst_cache = (struct dst_cache *)&info->dst_cache;
806809
if (use_cache) {
@@ -889,6 +892,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
889892
const struct ip_tunnel_key *key = &info->key;
890893
struct rtable *rt;
891894
struct flowi4 fl4;
895+
__u8 full_tos;
892896
__u8 tos, ttl;
893897
__be16 df = 0;
894898
__be16 sport;
@@ -899,7 +903,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
899903

900904
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
901905
rt = geneve_get_v4_rt(skb, dev, gs4, &fl4, info,
902-
geneve->cfg.info.key.tp_dst, sport);
906+
geneve->cfg.info.key.tp_dst, sport, &full_tos);
903907
if (IS_ERR(rt))
904908
return PTR_ERR(rt);
905909

@@ -943,7 +947,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
943947

944948
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
945949
} else {
946-
tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb);
950+
tos = ip_tunnel_ecn_encap(full_tos, ip_hdr(skb), skb);
947951
if (geneve->cfg.ttl_inherit)
948952
ttl = ip_tunnel_get_ttl(ip_hdr(skb), skb);
949953
else
@@ -1125,7 +1129,7 @@ static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
11251129
1, USHRT_MAX, true);
11261130

11271131
rt = geneve_get_v4_rt(skb, dev, gs4, &fl4, info,
1128-
geneve->cfg.info.key.tp_dst, sport);
1132+
geneve->cfg.info.key.tp_dst, sport, NULL);
11291133
if (IS_ERR(rt))
11301134
return PTR_ERR(rt);
11311135

0 commit comments

Comments
 (0)