netfilter: nft_fib: Unmask upper DSCP bits
authorIdo Schimmel <idosch@nvidia.com>
Wed, 21 Aug 2024 12:52:44 +0000 (15:52 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 22 Aug 2024 23:59:57 +0000 (16:59 -0700)
In a similar fashion to the iptables rpfilter match, unmask the upper
DSCP bits of the DS field of the currently tested packet so that in the
future the FIB lookup could be performed according to the full DSCP
value.

No functional changes intended since the upper DSCP bits are masked when
comparing against the TOS selectors in FIB rules and routes.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
Acked-by: Florian Westphal <fw@strlen.de>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20240821125251.1571445-6-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/netfilter/nft_fib_ipv4.c

index df94bc2..00da133 100644 (file)
@@ -10,6 +10,7 @@
 #include <net/netfilter/nf_tables.h>
 #include <net/netfilter/nft_fib.h>
 
+#include <net/inet_dscp.h>
 #include <net/ip_fib.h>
 #include <net/route.h>
 
@@ -108,7 +109,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
        if (priv->flags & NFTA_FIB_F_MARK)
                fl4.flowi4_mark = pkt->skb->mark;
 
-       fl4.flowi4_tos = iph->tos & IPTOS_RT_MASK;
+       fl4.flowi4_tos = iph->tos & INET_DSCP_MASK;
 
        if (priv->flags & NFTA_FIB_F_DADDR) {
                fl4.daddr = iph->daddr;