Skip to content

Commit

Permalink
netfilter: nft_fib: Convert nft_fib4_eval() to dscp_t.
Browse files Browse the repository at this point in the history
Use ip4h_dscp() instead of reading iph->tos directly.

ip4h_dscp() returns a dscp_t value which is temporarily converted back
to __u8 with inet_dscp_to_dsfield(). When converting ->flowi4_tos to
dscp_t in the future, we'll only have to remove that
inet_dscp_to_dsfield() call.

Signed-off-by: Guillaume Nault <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Guillaume Nault authored and ummakynes committed Nov 15, 2024
1 parent f694ce6 commit f12b67c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/ipv4/netfilter/nft_fib_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <net/netfilter/nft_fib.h>

#include <net/inet_dscp.h>
#include <net/ip.h>
#include <net/ip_fib.h>
#include <net/route.h>

Expand Down Expand Up @@ -107,7 +108,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 & INET_DSCP_MASK;
fl4.flowi4_tos = inet_dscp_to_dsfield(ip4h_dscp(iph));

if (priv->flags & NFTA_FIB_F_DADDR) {
fl4.daddr = iph->daddr;
Expand Down

0 comments on commit f12b67c

Please sign in to comment.