Skip to content

Commit c1ae5ca

Browse files
idoschkuba-moo
authored andcommitted
netfilter: rpfilter: Unmask upper DSCP bits
The rpfilter match performs a reverse path filter test on a packet by performing a FIB lookup with the source and destination addresses swapped. Unmask the upper DSCP bits of the DS field of the 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 <[email protected]> Reviewed-by: Guillaume Nault <[email protected]> Acked-by: Florian Westphal <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent be2e908 commit c1ae5ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/ipv4/netfilter/ipt_rpfilter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/module.h>
99
#include <linux/skbuff.h>
1010
#include <linux/netdevice.h>
11+
#include <net/inet_dscp.h>
1112
#include <linux/ip.h>
1213
#include <net/ip.h>
1314
#include <net/ip_fib.h>
@@ -75,7 +76,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
7576
flow.daddr = iph->saddr;
7677
flow.saddr = rpfilter_get_saddr(iph->daddr);
7778
flow.flowi4_mark = info->flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0;
78-
flow.flowi4_tos = iph->tos & IPTOS_RT_MASK;
79+
flow.flowi4_tos = iph->tos & INET_DSCP_MASK;
7980
flow.flowi4_scope = RT_SCOPE_UNIVERSE;
8081
flow.flowi4_l3mdev = l3mdev_master_ifindex_rcu(xt_in(par));
8182
flow.flowi4_uid = sock_net_uid(xt_net(par), NULL);

0 commit comments

Comments
 (0)