diff options
author | Guillaume Nault <gnault@redhat.com> | 2024-04-05 23:05:00 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2024-04-08 15:20:51 +0300 |
commit | ec20b283009346adc66d5a460b1f8fb5adafbcfe (patch) | |
tree | 36b9dfa207e7d4d663dd41d84f8aae36da254627 /include | |
parent | 229783970838887e72083820efb9270b7f276a11 (diff) | |
download | linux-ec20b283009346adc66d5a460b1f8fb5adafbcfe.tar.xz |
ipv4: Set scope explicitly in ip_route_output().
Add a "scope" parameter to ip_route_output() so that callers don't have
to override the tos parameter with the RTO_ONLINK flag if they want a
local scope.
This will allow converting flowi4_tos to dscp_t in the future, thus
allowing static analysers to flag invalid interactions between
"tos" (the DSCP bits) and ECN.
Only three users ask for local scope (bonding, arp and atm). The others
continue to use RT_SCOPE_UNIVERSE. While there, add a comment to warn
users about the limitations of ip_route_output().
Signed-off-by: Guillaume Nault <gnault@redhat.com>
Acked-by: Leon Romanovsky <leonro@nvidia.com> # infiniband
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/route.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/net/route.h b/include/net/route.h index d4a0147942f1..315a8acee6c6 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -141,15 +141,22 @@ static inline struct rtable *ip_route_output_key(struct net *net, struct flowi4 return ip_route_output_flow(net, flp, NULL); } +/* Simplistic IPv4 route lookup function. + * This is only suitable for some particular use cases: since the flowi4 + * structure is only partially set, it may bypass some fib-rules. + */ static inline struct rtable *ip_route_output(struct net *net, __be32 daddr, - __be32 saddr, u8 tos, int oif) + __be32 saddr, u8 tos, int oif, + __u8 scope) { struct flowi4 fl4 = { .flowi4_oif = oif, .flowi4_tos = tos, + .flowi4_scope = scope, .daddr = daddr, .saddr = saddr, }; + return ip_route_output_key(net, &fl4); } |