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.
Unified · Split
| @@ -1789,7 +1789,7 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, · 1788 unmodified lines | ||
| 1789 | 1789 | |
| 1790 | 1790 | #if IS_ENABLED(CONFIG_IPV6) |
| 1791 | 1791 | 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, | |
| 1793 | 1793 | const struct in6_addr *daddr, |
| 1794 | 1794 | struct in6_addr *saddr, |
| 1795 | 1795 | struct dst_cache *dst_cache, |
| @@ -1800,6 +1800,8 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, · 4 unmodified lines | ||
| 1800 | 1800 | struct flowi6 fl6; |
| 1801 | 1801 | int err; |
| 1802 | 1802 | |
| 1803 | + if (tos && !info) | |
| 1804 | + use_cache = false; | |
| 1803 | 1805 | if (use_cache) { |
| 1804 | 1806 | ndst = dst_cache_get_ip6(dst_cache, saddr); |
| 1805 | 1807 | if (ndst) |
| @@ -1808,6 +1810,7 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, · 2 unmodified lines | ||
| 1808 | 1810 | |
| 1809 | 1811 | memset(&fl6, 0, sizeof(fl6)); |
| 1810 | 1812 | fl6.flowi6_oif = oif; |
| 1813 | + fl6.flowi6_tos = RT_TOS(tos); | |
| 1811 | 1814 | fl6.daddr = *daddr; |
| 1812 | 1815 | fl6.saddr = vxlan->cfg.saddr.sin6.sin6_addr; |
| 1813 | 1816 | fl6.flowi6_mark = skb->mark; |
| @@ -2016,7 +2019,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, · 202 unmodified lines | ||
| 2016 | 2019 | sk = vxlan->vn6_sock->sock->sk; |
| 2017 | 2020 | |
| 2018 | 2021 | ndst = vxlan6_get_route(vxlan, skb, |
| 2019 | − rdst ? rdst->remote_ifindex : 0, | |
| 2022 | + rdst ? rdst->remote_ifindex : 0, tos, | |
| 2020 | 2023 | &dst->sin6.sin6_addr, &saddr, |
| 2021 | 2024 | dst_cache, info); |
| 2022 | 2025 | if (IS_ERR(ndst)) { |
| @@ -2053,6 +2056,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, · 30 unmodified lines | ||
| 2053 | 2056 | if (!info) |
| 2054 | 2057 | udp_sum = !(flags & VXLAN_F_UDP_ZERO_CSUM6_TX); |
| 2055 | 2058 | |
| 2059 | + tos = ip_tunnel_ecn_encap(tos, old_iph, skb); | |
| 2056 | 2060 | ttl = ttl ? : ip6_dst_hoplimit(ndst); |
| 2057 | 2061 | skb_scrub_packet(skb, xnet); |
| 2058 | 2062 | 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, · 3 unmodified lines | ||
| 2062 | 2066 | return; |
| 2063 | 2067 | } |
| 2064 | 2068 | 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); | |
| 2067 | 2071 | #endif |
| 2068 | 2072 | } |
| 2069 | 2073 | |
| @@ -2385,7 +2389,7 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) · 315 unmodified lines | ||
| 2385 | 2389 | |
| 2386 | 2390 | if (!vxlan->vn6_sock) |
| 2387 | 2391 | return -EINVAL; |
| 2388 | − ndst = vxlan6_get_route(vxlan, skb, 0, | |
| 2392 | + ndst = vxlan6_get_route(vxlan, skb, 0, info->key.tos, | |
| 2389 | 2393 | &info->key.u.ipv6.dst, |
| 2390 | 2394 | &info->key.u.ipv6.src, NULL, info); |
| 2391 | 2395 | if (IS_ERR(ndst)) |