Skip to content

Commit cc73bba

Browse files
idoschPaolo Abeni
authored andcommitted
ipv4: Fix incorrect source address in Record Route option
The Record Route IP option records the addresses of the routers that routed the packet. In the case of forwarded packets, the kernel performs a route lookup via fib_lookup() and fills in the preferred source address of the matched route. The lookup is performed with the DS field of the forwarded packet, but using the RT_TOS() macro which only masks one of the two ECN bits. If the packet is ECT(0) or CE, the matched route might be different than the route via which the packet was forwarded as the input path masks both of the ECN bits, resulting in the wrong address being filled in the Record Route option. Fix by masking both of the ECN bits. Fixes: 8e36360 ("ipv4: Remove route key identity dependencies in ip_rt_get_source().") Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Guillaume Nault <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent d7e7895 commit cc73bba

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ipv4/route.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt)
12631263
struct flowi4 fl4 = {
12641264
.daddr = iph->daddr,
12651265
.saddr = iph->saddr,
1266-
.flowi4_tos = RT_TOS(iph->tos),
1266+
.flowi4_tos = iph->tos & IPTOS_RT_MASK,
12671267
.flowi4_oif = rt->dst.dev->ifindex,
12681268
.flowi4_iif = skb->dev->ifindex,
12691269
.flowi4_mark = skb->mark,

0 commit comments

Comments
 (0)