Skip to content

Commit 6faaad5

Browse files
author
Hangbin Liu
committed
ipv4: Don't reset ->flowi4_scope in ip_rt_fix_tos().
JIRA: https://issues.redhat.com/browse/RHEL-59754 Upstream Status: net.git commit 16a2826 commit 16a2826 Author: Guillaume Nault <gnault@redhat.com> Date: Thu Apr 21 01:21:24 2022 +0200 ipv4: Don't reset ->flowi4_scope in ip_rt_fix_tos(). All callers already initialise ->flowi4_scope with RT_SCOPE_UNIVERSE, either by manual field assignment, memset(0) of the whole structure or implicit structure initialisation of on-stack variables (RT_SCOPE_UNIVERSE actually equals 0). Therefore, we don't need to always initialise ->flowi4_scope in ip_rt_fix_tos(). We only need to reduce the scope to RT_SCOPE_LINK when the special RTO_ONLINK flag is present in the tos. This will allow some code simplification, like removing ip_rt_fix_tos(). Also, the long term idea is to remove RTO_ONLINK entirely by properly initialising ->flowi4_scope, instead of overloading ->flowi4_tos with a special flag. Eventually, this will allow to convert ->flowi4_tos to dscp_t. Signed-off-by: Guillaume Nault <gnault@redhat.com> Reviewed-by: David Ahern <dsahern@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Hangbin Liu <haliu@redhat.com>
1 parent 30bcf5d commit 6faaad5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/route.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ static void ip_rt_fix_tos(struct flowi4 *fl4)
512512
__u8 tos = RT_FL_TOS(fl4);
513513

514514
fl4->flowi4_tos = tos & IPTOS_RT_MASK;
515-
fl4->flowi4_scope = tos & RTO_ONLINK ?
516-
RT_SCOPE_LINK : RT_SCOPE_UNIVERSE;
515+
if (tos & RTO_ONLINK)
516+
fl4->flowi4_scope = RT_SCOPE_LINK;
517517
}
518518

519519
static void __build_flow_key(const struct net *net, struct flowi4 *fl4,

0 commit comments

Comments
 (0)