ipv4: Fix incorrect source address in Record Route option
Subsystems (3)
Ido Schimmel
maintainerPATCH 1/1 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.
--- net/ipv4/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
@@ -1263,7 +1263,7 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt)struct flowi4 fl4 = { .daddr = iph->daddr, .saddr = iph->saddr, - .flowi4_tos =RT_TOS (iph->tos), + .flowi4_tos = iph->tos &IPTOS_RT_MASK , .flowi4_oif = rt->dst.dev->ifindex, .flowi4_iif = skb->dev->ifindex, .flowi4_mark = skb->mark,
Signature · 1 line
2.45.1
Quoted 5 lines · Ido Schimmel
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.
Quoted 8 lines
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.
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 5 lines · On Thu, 18 Jul 2024 15:34:07 +0300 you wrote:
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.
Quoted 8 lines
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.[...]
Here is the summary with links:
- [net] ipv4: Fix incorrect source address in Record Route option
https://git.kernel.org/netdev/net/c/cc73bbab4b1f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html