Skip to content

Commit 1400615

Browse files
borkmanndavem330
authored andcommitted
vxlan: allow setting ipv6 traffic class
We can already do that for IPv4, but IPv6 support was missing. Add it for vxlan, so it can be used with collect metadata frontends. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent db3c613 commit 1400615

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/net/vxlan.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,7 +1789,7 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan,
17891789

17901790
#if IS_ENABLED(CONFIG_IPV6)
17911791
static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
1792-
struct sk_buff *skb, int oif,
1792+
struct sk_buff *skb, int oif, u8 tos,
17931793
const struct in6_addr *daddr,
17941794
struct in6_addr *saddr,
17951795
struct dst_cache *dst_cache,
@@ -1800,6 +1800,8 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
18001800
struct flowi6 fl6;
18011801
int err;
18021802

1803+
if (tos && !info)
1804+
use_cache = false;
18031805
if (use_cache) {
18041806
ndst = dst_cache_get_ip6(dst_cache, saddr);
18051807
if (ndst)
@@ -1808,6 +1810,7 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
18081810

18091811
memset(&fl6, 0, sizeof(fl6));
18101812
fl6.flowi6_oif = oif;
1813+
fl6.flowi6_tos = RT_TOS(tos);
18111814
fl6.daddr = *daddr;
18121815
fl6.saddr = vxlan->cfg.saddr.sin6.sin6_addr;
18131816
fl6.flowi6_mark = skb->mark;
@@ -2016,7 +2019,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
20162019
sk = vxlan->vn6_sock->sock->sk;
20172020

20182021
ndst = vxlan6_get_route(vxlan, skb,
2019-
rdst ? rdst->remote_ifindex : 0,
2022+
rdst ? rdst->remote_ifindex : 0, tos,
20202023
&dst->sin6.sin6_addr, &saddr,
20212024
dst_cache, info);
20222025
if (IS_ERR(ndst)) {
@@ -2053,6 +2056,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
20532056
if (!info)
20542057
udp_sum = !(flags & VXLAN_F_UDP_ZERO_CSUM6_TX);
20552058

2059+
tos = ip_tunnel_ecn_encap(tos, old_iph, skb);
20562060
ttl = ttl ? : ip6_dst_hoplimit(ndst);
20572061
skb_scrub_packet(skb, xnet);
20582062
err = vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr),
@@ -2062,8 +2066,8 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
20622066
return;
20632067
}
20642068
udp_tunnel6_xmit_skb(ndst, sk, skb, dev,
2065-
&saddr, &dst->sin6.sin6_addr,
2066-
0, ttl, src_port, dst_port, !udp_sum);
2069+
&saddr, &dst->sin6.sin6_addr, tos, ttl,
2070+
src_port, dst_port, !udp_sum);
20672071
#endif
20682072
}
20692073

@@ -2385,7 +2389,7 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
23852389

23862390
if (!vxlan->vn6_sock)
23872391
return -EINVAL;
2388-
ndst = vxlan6_get_route(vxlan, skb, 0,
2392+
ndst = vxlan6_get_route(vxlan, skb, 0, info->key.tos,
23892393
&info->key.u.ipv6.dst,
23902394
&info->key.u.ipv6.src, NULL, info);
23912395
if (IS_ERR(ndst))

0 commit comments

Comments
 (0)