ipv4: Prepare ip_route_output() to future .flowi4_tos conversion.
authorGuillaume Nault <gnault@redhat.com>
Wed, 6 Nov 2024 21:37:32 +0000 (22:37 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 8 Nov 2024 04:33:19 +0000 (20:33 -0800)
Convert the "tos" parameter of ip_route_output() to dscp_t. This way
we'll have a dscp_t value directly available when .flowi4_tos will
eventually be converted to dscp_t.

All ip_route_output() callers but one set this "tos" parameter to 0 and
therefore don't need to be adapted to the new prototype.

Only br_nf_pre_routing_finish() needs conversion. It can just use
ip4h_dscp() to get the DSCP field from the IPv4 header.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/0f10d031dd44c70aae9bc6e19391cb30d5c2fe71.1730928699.git.gnault@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/route.h
net/bridge/br_netfilter_hooks.c

index 586e59f7ed8af1de74061cf81b301a86e5038435..0a690adfdff527262ab1f385bf76a16e1f63be07 100644 (file)
@@ -156,12 +156,12 @@ static inline struct rtable *ip_route_output_key(struct net *net, struct 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,
-                                            __u8 scope)
+                                            __be32 saddr, dscp_t dscp,
+                                            int oif, __u8 scope)
 {
        struct flowi4 fl4 = {
                .flowi4_oif = oif,
-               .flowi4_tos = tos,
+               .flowi4_tos = inet_dscp_to_dsfield(dscp),
                .flowi4_scope = scope,
                .daddr = daddr,
                .saddr = saddr,
index 17a5f5923d615d054e0d3f046c17cf449ba4f36f..7f2f40cef5fe206135c610d4a8b8169ac57b480b 100644 (file)
@@ -406,7 +406,7 @@ static int br_nf_pre_routing_finish(struct net *net, struct sock *sk, struct sk_
                                goto free_skb;
 
                        rt = ip_route_output(net, iph->daddr, 0,
-                                            iph->tos & INET_DSCP_MASK, 0,
+                                            ip4h_dscp(iph), 0,
                                             RT_SCOPE_UNIVERSE);
                        if (!IS_ERR(rt)) {
                                /* - Bridged-and-DNAT'ed traffic doesn't