Skip to content

Commit eaa93bf

Browse files
borkmanndavem330
authored andcommitted
vxlan: fix populating tclass in vxlan6_get_route
Jiri mentioned that flowi6_tos of struct flowi6 is never used/read anywhere. In fact, rest of the kernel uses the flowi6's flowlabel, where the traffic class _and_ the flowlabel (aka flowinfo) is encoded. For example, for policy routing, fib6_rule_match() uses ip6_tclass() that is applied on the flowlabel member for matching on tclass. Similar fix is needed for geneve, where flowi6_tos is set as well. Installing a v6 blackhole rule that f.e. matches on tos is now working with vxlan. Fixes: 1400615 ("vxlan: allow setting ipv6 traffic class") Reported-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c78a85a commit eaa93bf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/net/vxlan.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,10 +1810,9 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan,
18101810

18111811
memset(&fl6, 0, sizeof(fl6));
18121812
fl6.flowi6_oif = oif;
1813-
fl6.flowi6_tos = RT_TOS(tos);
18141813
fl6.daddr = *daddr;
18151814
fl6.saddr = vxlan->cfg.saddr.sin6.sin6_addr;
1816-
fl6.flowlabel = label;
1815+
fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tos), label);
18171816
fl6.flowi6_mark = skb->mark;
18181817
fl6.flowi6_proto = IPPROTO_UDP;
18191818

include/net/ipv6.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,12 @@ static inline u8 ip6_tclass(__be32 flowinfo)
835835
{
836836
return ntohl(flowinfo & IPV6_TCLASS_MASK) >> IPV6_TCLASS_SHIFT;
837837
}
838+
839+
static inline __be32 ip6_make_flowinfo(unsigned int tclass, __be32 flowlabel)
840+
{
841+
return htonl(tclass << IPV6_TCLASS_SHIFT) | flowlabel;
842+
}
843+
838844
/*
839845
* Prototypes exported by ipv6
840846
*/

0 commit comments

Comments
 (0)