Skip to content

Commit c951a29

Browse files
idoschkuba-moo
authored andcommitted
net: fib_rules: Add DSCP selector attribute
The FIB rule TOS selector is implemented differently between IPv4 and IPv6. In IPv4 it is used to match on the three "Type of Services" bits specified in RFC 791, while in IPv6 is it is used to match on the six DSCP bits specified in RFC 2474. Add a new FIB rule attribute to allow matching on DSCP. The attribute will be used to implement a 'dscp' selector in ip-rule with a consistent behavior between IPv4 and IPv6. For now, set the type of the attribute to 'NLA_REJECT' so that user space will not be able to configure it. This restriction will be lifted once both IPv4 and IPv6 support the new attribute. Signed-off-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Guillaume Nault <gnault@redhat.com> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://patch.msgid.link/20240911093748.3662015-2-idosch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 716425d commit c951a29

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

include/uapi/linux/fib_rules.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum {
6767
FRA_IP_PROTO, /* ip proto */
6868
FRA_SPORT_RANGE, /* sport */
6969
FRA_DPORT_RANGE, /* dport */
70+
FRA_DSCP, /* dscp */
7071
__FRA_MAX
7172
};
7273

net/core/fib_rules.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,8 @@ static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = {
766766
[FRA_PROTOCOL] = { .type = NLA_U8 },
767767
[FRA_IP_PROTO] = { .type = NLA_U8 },
768768
[FRA_SPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) },
769-
[FRA_DPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) }
769+
[FRA_DPORT_RANGE] = { .len = sizeof(struct fib_rule_port_range) },
770+
[FRA_DSCP] = { .type = NLA_REJECT },
770771
};
771772

772773
int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh,

0 commit comments

Comments
 (0)