Skip to content

Commit eb79bbb

Browse files
author
Herton R. Krzesinski
committed
Merge: ip tunnels: Fix erroneous calls to RT_TOS().
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1895 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2161351 Upstream Status: linux.git Backport upstream merge commit 996237d ("Merge branch 'do-not-use-rt_tos-for-ipv6-flowlabel'") to fix some invalid uses of the RT_TOS() macro (RT_TOS() clears high order DSCP bits which doesn't make sense for IPv6 and isn't appropriate when inheriting the DSCP value from the inner IP packet). Upstream commit ab7e2e0 ("ipv6: do not use RT_TOS for IPv6 flowlabel") isn't part of this series since it has already been backported by Centos Stream commit 090d473. Also, there's a selftest upstream, which was introduced by commit b690842 ("selftests/net: test l2 tunnel TOS/TTL inheriting"). This selftest isn't part of this series because it also tests inheritance from VLAN tagged frames, which Centos Stream doesn't currently support. Signed-off-by: Guillaume Nault <gnault@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Approved-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents a5187f5 + 68e59ed commit eb79bbb

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
506506
int err;
507507

508508
attr.ttl = tun_key->ttl;
509-
attr.fl.fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tun_key->tos), tun_key->label);
509+
attr.fl.fl6.flowlabel = ip6_make_flowinfo(tun_key->tos, tun_key->label);
510510
attr.fl.fl6.daddr = tun_key->u.ipv6.dst;
511511
attr.fl.fl6.saddr = tun_key->u.ipv6.src;
512512

@@ -620,7 +620,7 @@ int mlx5e_tc_tun_update_header_ipv6(struct mlx5e_priv *priv,
620620

621621
attr.ttl = tun_key->ttl;
622622

623-
attr.fl.fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tun_key->tos), tun_key->label);
623+
attr.fl.fl6.flowlabel = ip6_make_flowinfo(tun_key->tos, tun_key->label);
624624
attr.fl.fl6.daddr = tun_key->u.ipv6.dst;
625625
attr.fl.fl6.saddr = tun_key->u.ipv6.src;
626626

drivers/net/geneve.c

Lines changed: 9 additions & 6 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) {
@@ -854,8 +857,7 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb,
854857
use_cache = false;
855858
}
856859

857-
fl6->flowlabel = ip6_make_flowinfo(RT_TOS(prio),
858-
info->key.label);
860+
fl6->flowlabel = ip6_make_flowinfo(prio, info->key.label);
859861
dst_cache = (struct dst_cache *)&info->dst_cache;
860862
if (use_cache) {
861863
dst = dst_cache_get_ip6(dst_cache, &fl6->saddr);
@@ -889,6 +891,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
889891
const struct ip_tunnel_key *key = &info->key;
890892
struct rtable *rt;
891893
struct flowi4 fl4;
894+
__u8 full_tos;
892895
__u8 tos, ttl;
893896
__be16 df = 0;
894897
__be16 sport;
@@ -899,7 +902,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
899902

900903
sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
901904
rt = geneve_get_v4_rt(skb, dev, gs4, &fl4, info,
902-
geneve->cfg.info.key.tp_dst, sport);
905+
geneve->cfg.info.key.tp_dst, sport, &full_tos);
903906
if (IS_ERR(rt))
904907
return PTR_ERR(rt);
905908

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

944947
df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
945948
} else {
946-
tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb);
949+
tos = ip_tunnel_ecn_encap(full_tos, ip_hdr(skb), skb);
947950
if (geneve->cfg.ttl_inherit)
948951
ttl = ip_tunnel_get_ttl(ip_hdr(skb), skb);
949952
else
@@ -1125,7 +1128,7 @@ static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
11251128
1, USHRT_MAX, true);
11261129

11271130
rt = geneve_get_v4_rt(skb, dev, gs4, &fl4, info,
1128-
geneve->cfg.info.key.tp_dst, sport);
1131+
geneve->cfg.info.key.tp_dst, sport, NULL);
11291132
if (IS_ERR(rt))
11301133
return PTR_ERR(rt);
11311134

drivers/net/vxlan/vxlan_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
22792279
fl6.flowi6_oif = oif;
22802280
fl6.daddr = *daddr;
22812281
fl6.saddr = *saddr;
2282-
fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tos), label);
2282+
fl6.flowlabel = ip6_make_flowinfo(tos, label);
22832283
fl6.flowi6_mark = skb->mark;
22842284
fl6.flowi6_proto = IPPROTO_UDP;
22852285
fl6.fl6_dport = dport;

0 commit comments

Comments
 (0)