summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@nvidia.com>2024-07-18 15:34:07 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-08-19 05:32:07 +0200
commit5c65e55e41e1300c4ebf4dda22a704b2beed2423 (patch)
tree5b5529d9a4f9980c85fb9074d946062b8bdc3b01 /net
parent0e8712254b48a7c6ebb76dce414a9539e772d406 (diff)
downloadlinux-stable-5c65e55e41e1300c4ebf4dda22a704b2beed2423.tar.gz
linux-stable-5c65e55e41e1300c4ebf4dda22a704b2beed2423.tar.bz2
linux-stable-5c65e55e41e1300c4ebf4dda22a704b2beed2423.zip
ipv4: Fix incorrect source address in Record Route option
[ Upstream commit cc73bbab4b1fb8a4f53a24645871dafa5f81266a ] 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: 8e36360ae876 ("ipv4: Remove route key identity dependencies in ip_rt_get_source().") Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Link: https://patch.msgid.link/20240718123407.434778-1-idosch@nvidia.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/route.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 1aac0d77a3aa..437960825ec2 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1277,7 +1277,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,