* [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support
@ 2025-02-20 8:05 Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 1/6] net: fib_rules: Add DSCP mask attribute Ido Schimmel
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Ido Schimmel @ 2025-02-20 8:05 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, horms, donald.hunter, dsahern,
petrm, gnault, Ido Schimmel
In some deployments users would like to encode path information into
certain bits of the IPv6 flow label, the UDP source port and the DSCP
field and use this information to route packets accordingly.
Redirecting traffic to a routing table based on specific bits in the
DSCP field is not currently possible. Only exact match is currently
supported by FIB rules.
This patchset extends FIB rules to match on the DSCP field with an
optional mask.
Patches #1-#5 gradually extend FIB rules to match on the DSCP field with
an optional mask.
Patch #6 adds test cases for the new functionality.
iproute2 support can be found here [1].
[1] https://github.com/idosch/iproute2/tree/submit/fib_rule_mask_v1
Ido Schimmel (6):
net: fib_rules: Add DSCP mask attribute
ipv4: fib_rules: Add DSCP mask matching
ipv6: fib_rules: Add DSCP mask matching
net: fib_rules: Enable DSCP mask usage
netlink: specs: Add FIB rule DSCP mask attribute
selftests: fib_rule_tests: Add DSCP mask match tests
Documentation/netlink/specs/rt_rule.yaml | 5 ++
include/uapi/linux/fib_rules.h | 1 +
net/core/fib_rules.c | 1 +
net/ipv4/fib_rules.c | 47 +++++++++++++++++--
net/ipv6/fib6_rules.c | 45 +++++++++++++++++-
tools/testing/selftests/net/fib_rule_tests.sh | 38 +++++++++++++++
6 files changed, 132 insertions(+), 5 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net-next 1/6] net: fib_rules: Add DSCP mask attribute
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
@ 2025-02-20 8:05 ` Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 2/6] ipv4: fib_rules: Add DSCP mask matching Ido Schimmel
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2025-02-20 8:05 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, horms, donald.hunter, dsahern,
petrm, gnault, Ido Schimmel
Add an attribute that allows matching on DSCP with a mask. Matching on
DSCP with a mask is needed in deployments where users encode path
information into certain bits of the DSCP field.
Temporarily set the type of the attribute to 'NLA_REJECT' while support
is being added.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
include/uapi/linux/fib_rules.h | 1 +
net/core/fib_rules.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/include/uapi/linux/fib_rules.h b/include/uapi/linux/fib_rules.h
index 95ec01b15c65..2df6e4035d50 100644
--- a/include/uapi/linux/fib_rules.h
+++ b/include/uapi/linux/fib_rules.h
@@ -72,6 +72,7 @@ enum {
FRA_FLOWLABEL_MASK, /* flowlabel mask */
FRA_SPORT_MASK, /* sport mask */
FRA_DPORT_MASK, /* dport mask */
+ FRA_DSCP_MASK, /* dscp mask */
__FRA_MAX
};
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 5ddd34cbe7f6..00e6fe79ecba 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -845,6 +845,7 @@ static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = {
[FRA_FLOWLABEL_MASK] = { .type = NLA_BE32 },
[FRA_SPORT_MASK] = { .type = NLA_U16 },
[FRA_DPORT_MASK] = { .type = NLA_U16 },
+ [FRA_DSCP_MASK] = { .type = NLA_REJECT },
};
int fib_newrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 2/6] ipv4: fib_rules: Add DSCP mask matching
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 1/6] net: fib_rules: Add DSCP mask attribute Ido Schimmel
@ 2025-02-20 8:05 ` Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 3/6] ipv6: " Ido Schimmel
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2025-02-20 8:05 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, horms, donald.hunter, dsahern,
petrm, gnault, Ido Schimmel
Extend IPv4 FIB rules to match on DSCP using a mask. The mask is only
set in rules that match on DSCP (not TOS) and initialized to cover the
entire DSCP field if the mask attribute is not specified.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
net/ipv4/fib_rules.c | 47 +++++++++++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 6b3d6a957822..fa58d6620ed6 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -37,6 +37,7 @@ struct fib4_rule {
u8 dst_len;
u8 src_len;
dscp_t dscp;
+ dscp_t dscp_mask;
u8 dscp_full:1; /* DSCP or TOS selector */
__be32 src;
__be32 srcmask;
@@ -192,7 +193,8 @@ INDIRECT_CALLABLE_SCOPE int fib4_rule_match(struct fib_rule *rule,
* to mask the upper three DSCP bits prior to matching to maintain
* legacy behavior.
*/
- if (r->dscp_full && r->dscp != inet_dsfield_to_dscp(fl4->flowi4_tos))
+ if (r->dscp_full &&
+ (r->dscp ^ inet_dsfield_to_dscp(fl4->flowi4_tos)) & r->dscp_mask)
return 0;
else if (!r->dscp_full && r->dscp &&
!fib_dscp_masked_match(r->dscp, fl4))
@@ -235,11 +237,35 @@ static int fib4_nl2rule_dscp(const struct nlattr *nla, struct fib4_rule *rule4,
}
rule4->dscp = inet_dsfield_to_dscp(nla_get_u8(nla) << 2);
+ rule4->dscp_mask = inet_dsfield_to_dscp(INET_DSCP_MASK);
rule4->dscp_full = true;
return 0;
}
+static int fib4_nl2rule_dscp_mask(const struct nlattr *nla,
+ struct fib4_rule *rule4,
+ struct netlink_ext_ack *extack)
+{
+ dscp_t dscp_mask;
+
+ if (!rule4->dscp_full) {
+ NL_SET_ERR_MSG_ATTR(extack, nla,
+ "Cannot specify DSCP mask without DSCP value");
+ return -EINVAL;
+ }
+
+ dscp_mask = inet_dsfield_to_dscp(nla_get_u8(nla) << 2);
+ if (rule4->dscp & ~dscp_mask) {
+ NL_SET_ERR_MSG_ATTR(extack, nla, "Invalid DSCP mask");
+ return -EINVAL;
+ }
+
+ rule4->dscp_mask = dscp_mask;
+
+ return 0;
+}
+
static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
struct fib_rule_hdr *frh,
struct nlattr **tb,
@@ -271,6 +297,10 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
fib4_nl2rule_dscp(tb[FRA_DSCP], rule4, extack) < 0)
goto errout;
+ if (tb[FRA_DSCP_MASK] &&
+ fib4_nl2rule_dscp_mask(tb[FRA_DSCP_MASK], rule4, extack) < 0)
+ goto errout;
+
/* split local/main if they are not already split */
err = fib_unmerge(net);
if (err)
@@ -366,6 +396,14 @@ static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
return 0;
}
+ if (tb[FRA_DSCP_MASK]) {
+ dscp_t dscp_mask;
+
+ dscp_mask = inet_dsfield_to_dscp(nla_get_u8(tb[FRA_DSCP_MASK]) << 2);
+ if (!rule4->dscp_full || rule4->dscp_mask != dscp_mask)
+ return 0;
+ }
+
#ifdef CONFIG_IP_ROUTE_CLASSID
if (tb[FRA_FLOW] && (rule4->tclassid != nla_get_u32(tb[FRA_FLOW])))
return 0;
@@ -391,7 +429,9 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
if (rule4->dscp_full) {
frh->tos = 0;
if (nla_put_u8(skb, FRA_DSCP,
- inet_dscp_to_dsfield(rule4->dscp) >> 2))
+ inet_dscp_to_dsfield(rule4->dscp) >> 2) ||
+ nla_put_u8(skb, FRA_DSCP_MASK,
+ inet_dscp_to_dsfield(rule4->dscp_mask) >> 2))
goto nla_put_failure;
} else {
frh->tos = inet_dscp_to_dsfield(rule4->dscp);
@@ -418,7 +458,8 @@ static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule)
return nla_total_size(4) /* dst */
+ nla_total_size(4) /* src */
+ nla_total_size(4) /* flow */
- + nla_total_size(1); /* dscp */
+ + nla_total_size(1) /* dscp */
+ + nla_total_size(1); /* dscp mask */
}
static void fib4_rule_flush_cache(struct fib_rules_ops *ops)
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 3/6] ipv6: fib_rules: Add DSCP mask matching
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 1/6] net: fib_rules: Add DSCP mask attribute Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 2/6] ipv4: fib_rules: Add DSCP mask matching Ido Schimmel
@ 2025-02-20 8:05 ` Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 4/6] net: fib_rules: Enable DSCP mask usage Ido Schimmel
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2025-02-20 8:05 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, horms, donald.hunter, dsahern,
petrm, gnault, Ido Schimmel
Extend IPv6 FIB rules to match on DSCP using a mask. Unlike IPv4, also
initialize the DSCP mask when a non-zero 'tos' is specified as there is
no difference in matching between 'tos' and 'dscp'. As a side effect,
this makes it possible to match on 'dscp 0', like in IPv4.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
net/ipv6/fib6_rules.c | 45 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 0144d01417d9..fd5f7112a51f 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -29,6 +29,7 @@ struct fib6_rule {
__be32 flowlabel;
__be32 flowlabel_mask;
dscp_t dscp;
+ dscp_t dscp_mask;
u8 dscp_full:1; /* DSCP or TOS selector */
};
@@ -331,7 +332,7 @@ INDIRECT_CALLABLE_SCOPE int fib6_rule_match(struct fib_rule *rule,
return 0;
}
- if (r->dscp && r->dscp != ip6_dscp(fl6->flowlabel))
+ if ((r->dscp ^ ip6_dscp(fl6->flowlabel)) & r->dscp_mask)
return 0;
if ((r->flowlabel ^ flowi6_get_flowlabel(fl6)) & r->flowlabel_mask)
@@ -360,11 +361,35 @@ static int fib6_nl2rule_dscp(const struct nlattr *nla, struct fib6_rule *rule6,
}
rule6->dscp = inet_dsfield_to_dscp(nla_get_u8(nla) << 2);
+ rule6->dscp_mask = inet_dsfield_to_dscp(INET_DSCP_MASK);
rule6->dscp_full = true;
return 0;
}
+static int fib6_nl2rule_dscp_mask(const struct nlattr *nla,
+ struct fib6_rule *rule6,
+ struct netlink_ext_ack *extack)
+{
+ dscp_t dscp_mask;
+
+ if (!rule6->dscp_full) {
+ NL_SET_ERR_MSG_ATTR(extack, nla,
+ "Cannot specify DSCP mask without DSCP value");
+ return -EINVAL;
+ }
+
+ dscp_mask = inet_dsfield_to_dscp(nla_get_u8(nla) << 2);
+ if (rule6->dscp & ~dscp_mask) {
+ NL_SET_ERR_MSG_ATTR(extack, nla, "Invalid DSCP mask");
+ return -EINVAL;
+ }
+
+ rule6->dscp_mask = dscp_mask;
+
+ return 0;
+}
+
static int fib6_nl2rule_flowlabel(struct nlattr **tb, struct fib6_rule *rule6,
struct netlink_ext_ack *extack)
{
@@ -409,10 +434,15 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
goto errout;
}
rule6->dscp = inet_dsfield_to_dscp(frh->tos);
+ rule6->dscp_mask = frh->tos ? inet_dsfield_to_dscp(INET_DSCP_MASK) : 0;
if (tb[FRA_DSCP] && fib6_nl2rule_dscp(tb[FRA_DSCP], rule6, extack) < 0)
goto errout;
+ if (tb[FRA_DSCP_MASK] &&
+ fib6_nl2rule_dscp_mask(tb[FRA_DSCP_MASK], rule6, extack) < 0)
+ goto errout;
+
if ((tb[FRA_FLOWLABEL] || tb[FRA_FLOWLABEL_MASK]) &&
fib6_nl2rule_flowlabel(tb, rule6, extack) < 0)
goto errout;
@@ -482,6 +512,14 @@ static int fib6_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
return 0;
}
+ if (tb[FRA_DSCP_MASK]) {
+ dscp_t dscp_mask;
+
+ dscp_mask = inet_dsfield_to_dscp(nla_get_u8(tb[FRA_DSCP_MASK]) << 2);
+ if (!rule6->dscp_full || rule6->dscp_mask != dscp_mask)
+ return 0;
+ }
+
if (tb[FRA_FLOWLABEL] &&
nla_get_be32(tb[FRA_FLOWLABEL]) != rule6->flowlabel)
return 0;
@@ -512,7 +550,9 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
if (rule6->dscp_full) {
frh->tos = 0;
if (nla_put_u8(skb, FRA_DSCP,
- inet_dscp_to_dsfield(rule6->dscp) >> 2))
+ inet_dscp_to_dsfield(rule6->dscp) >> 2) ||
+ nla_put_u8(skb, FRA_DSCP_MASK,
+ inet_dscp_to_dsfield(rule6->dscp_mask) >> 2))
goto nla_put_failure;
} else {
frh->tos = inet_dscp_to_dsfield(rule6->dscp);
@@ -539,6 +579,7 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule)
return nla_total_size(16) /* dst */
+ nla_total_size(16) /* src */
+ nla_total_size(1) /* dscp */
+ + nla_total_size(1) /* dscp mask */
+ nla_total_size(4) /* flowlabel */
+ nla_total_size(4); /* flowlabel mask */
}
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 4/6] net: fib_rules: Enable DSCP mask usage
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
` (2 preceding siblings ...)
2025-02-20 8:05 ` [PATCH net-next 3/6] ipv6: " Ido Schimmel
@ 2025-02-20 8:05 ` Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 5/6] netlink: specs: Add FIB rule DSCP mask attribute Ido Schimmel
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2025-02-20 8:05 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, horms, donald.hunter, dsahern,
petrm, gnault, Ido Schimmel
Allow user space to configure FIB rules that match on DSCP with a mask,
now that support has been added to the IPv4 and IPv6 address families.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
net/core/fib_rules.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 00e6fe79ecba..4bc64d912a1c 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -845,7 +845,7 @@ static const struct nla_policy fib_rule_policy[FRA_MAX + 1] = {
[FRA_FLOWLABEL_MASK] = { .type = NLA_BE32 },
[FRA_SPORT_MASK] = { .type = NLA_U16 },
[FRA_DPORT_MASK] = { .type = NLA_U16 },
- [FRA_DSCP_MASK] = { .type = NLA_REJECT },
+ [FRA_DSCP_MASK] = NLA_POLICY_MASK(NLA_U8, INET_DSCP_MASK >> 2),
};
int fib_newrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 5/6] netlink: specs: Add FIB rule DSCP mask attribute
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
` (3 preceding siblings ...)
2025-02-20 8:05 ` [PATCH net-next 4/6] net: fib_rules: Enable DSCP mask usage Ido Schimmel
@ 2025-02-20 8:05 ` Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 6/6] selftests: fib_rule_tests: Add DSCP mask match tests Ido Schimmel
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2025-02-20 8:05 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, horms, donald.hunter, dsahern,
petrm, gnault, Ido Schimmel
Add new DSCP mask attribute to the spec. Example:
# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/rt_rule.yaml \
--do newrule \
--json '{"family": 2, "dscp": 10, "dscp-mask": 63, "action": 1, "table": 1}'
None
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/rt_rule.yaml \
--dump getrule --json '{"family": 2}' --output-json | jq '.[]'
[...]
{
"table": 1,
"suppress-prefixlen": "0xffffffff",
"protocol": 0,
"priority": 32765,
"dscp": 10,
"dscp-mask": "0x3f",
"family": 2,
"dst-len": 0,
"src-len": 0,
"tos": 0,
"action": "to-tbl",
"flags": 0
}
[...]
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Documentation/netlink/specs/rt_rule.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/netlink/specs/rt_rule.yaml b/Documentation/netlink/specs/rt_rule.yaml
index b30c924087fa..de0938d36541 100644
--- a/Documentation/netlink/specs/rt_rule.yaml
+++ b/Documentation/netlink/specs/rt_rule.yaml
@@ -190,6 +190,10 @@ attribute-sets:
name: dport-mask
type: u16
display-hint: hex
+ -
+ name: dscp-mask
+ type: u8
+ display-hint: hex
operations:
enum-model: directional
@@ -225,6 +229,7 @@ operations:
- flowlabel-mask
- sport-mask
- dport-mask
+ - dscp-mask
-
name: newrule-ntf
doc: Notify a rule creation
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net-next 6/6] selftests: fib_rule_tests: Add DSCP mask match tests
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
` (4 preceding siblings ...)
2025-02-20 8:05 ` [PATCH net-next 5/6] netlink: specs: Add FIB rule DSCP mask attribute Ido Schimmel
@ 2025-02-20 8:05 ` Ido Schimmel
2025-02-21 15:29 ` [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Guillaume Nault
2025-02-22 0:30 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: Ido Schimmel @ 2025-02-20 8:05 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, pabeni, edumazet, horms, donald.hunter, dsahern,
petrm, gnault, Ido Schimmel
Add tests for FIB rules that match on DSCP with a mask. Test both good
and bad flows and both the input and output paths.
# ./fib_rule_tests.sh
IPv6 FIB rule tests
[...]
TEST: rule6 check: dscp redirect to table [ OK ]
TEST: rule6 check: dscp no redirect to table [ OK ]
TEST: rule6 del by pref: dscp redirect to table [ OK ]
TEST: rule6 check: iif dscp redirect to table [ OK ]
TEST: rule6 check: iif dscp no redirect to table [ OK ]
TEST: rule6 del by pref: iif dscp redirect to table [ OK ]
TEST: rule6 check: dscp masked redirect to table [ OK ]
TEST: rule6 check: dscp masked no redirect to table [ OK ]
TEST: rule6 del by pref: dscp masked redirect to table [ OK ]
TEST: rule6 check: iif dscp masked redirect to table [ OK ]
TEST: rule6 check: iif dscp masked no redirect to table [ OK ]
TEST: rule6 del by pref: iif dscp masked redirect to table [ OK ]
[...]
Tests passed: 316
Tests failed: 0
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
tools/testing/selftests/net/fib_rule_tests.sh | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tools/testing/selftests/net/fib_rule_tests.sh b/tools/testing/selftests/net/fib_rule_tests.sh
index 06c51d7ceb4a..b866bab1d92a 100755
--- a/tools/testing/selftests/net/fib_rule_tests.sh
+++ b/tools/testing/selftests/net/fib_rule_tests.sh
@@ -310,6 +310,25 @@ fib_rule6_test()
"iif dscp no redirect to table"
fi
+ ip rule help 2>&1 | grep -q "DSCP\[/MASK\]"
+ if [ $? -eq 0 ]; then
+ match="dscp 0x0f/0x0f"
+ tosmatch=$(printf 0x"%x" $((0x1f << 2)))
+ tosnomatch=$(printf 0x"%x" $((0x1e << 2)))
+ getmatch="tos $tosmatch"
+ getnomatch="tos $tosnomatch"
+ fib_rule6_test_match_n_redirect "$match" "$getmatch" \
+ "$getnomatch" "dscp masked redirect to table" \
+ "dscp masked no redirect to table"
+
+ match="dscp 0x0f/0x0f"
+ getmatch="from $SRC_IP6 iif $DEV tos $tosmatch"
+ getnomatch="from $SRC_IP6 iif $DEV tos $tosnomatch"
+ fib_rule6_test_match_n_redirect "$match" "$getmatch" \
+ "$getnomatch" "iif dscp masked redirect to table" \
+ "iif dscp masked no redirect to table"
+ fi
+
fib_check_iproute_support "flowlabel" "flowlabel"
if [ $? -eq 0 ]; then
match="flowlabel 0xfffff"
@@ -597,6 +616,25 @@ fib_rule4_test()
"$getnomatch" "iif dscp redirect to table" \
"iif dscp no redirect to table"
fi
+
+ ip rule help 2>&1 | grep -q "DSCP\[/MASK\]"
+ if [ $? -eq 0 ]; then
+ match="dscp 0x0f/0x0f"
+ tosmatch=$(printf 0x"%x" $((0x1f << 2)))
+ tosnomatch=$(printf 0x"%x" $((0x1e << 2)))
+ getmatch="tos $tosmatch"
+ getnomatch="tos $tosnomatch"
+ fib_rule4_test_match_n_redirect "$match" "$getmatch" \
+ "$getnomatch" "dscp masked redirect to table" \
+ "dscp masked no redirect to table"
+
+ match="dscp 0x0f/0x0f"
+ getmatch="from $SRC_IP iif $DEV tos $tosmatch"
+ getnomatch="from $SRC_IP iif $DEV tos $tosnomatch"
+ fib_rule4_test_match_n_redirect "$match" "$getmatch" \
+ "$getnomatch" "iif dscp masked redirect to table" \
+ "iif dscp masked no redirect to table"
+ fi
}
fib_rule4_vrf_test()
--
2.48.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
` (5 preceding siblings ...)
2025-02-20 8:05 ` [PATCH net-next 6/6] selftests: fib_rule_tests: Add DSCP mask match tests Ido Schimmel
@ 2025-02-21 15:29 ` Guillaume Nault
2025-02-22 0:30 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: Guillaume Nault @ 2025-02-21 15:29 UTC (permalink / raw)
To: Ido Schimmel
Cc: netdev, davem, kuba, pabeni, edumazet, horms, donald.hunter,
dsahern, petrm
On Thu, Feb 20, 2025 at 10:05:19AM +0200, Ido Schimmel wrote:
> In some deployments users would like to encode path information into
> certain bits of the IPv6 flow label, the UDP source port and the DSCP
> field and use this information to route packets accordingly.
>
> Redirecting traffic to a routing table based on specific bits in the
> DSCP field is not currently possible. Only exact match is currently
> supported by FIB rules.
>
> This patchset extends FIB rules to match on the DSCP field with an
> optional mask.
>
Reviewed-by: Guillaume Nault <gnault@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
` (6 preceding siblings ...)
2025-02-21 15:29 ` [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Guillaume Nault
@ 2025-02-22 0:30 ` patchwork-bot+netdevbpf
7 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-22 0:30 UTC (permalink / raw)
To: Ido Schimmel
Cc: netdev, davem, kuba, pabeni, edumazet, horms, donald.hunter,
dsahern, petrm, gnault
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 20 Feb 2025 10:05:19 +0200 you wrote:
> In some deployments users would like to encode path information into
> certain bits of the IPv6 flow label, the UDP source port and the DSCP
> field and use this information to route packets accordingly.
>
> Redirecting traffic to a routing table based on specific bits in the
> DSCP field is not currently possible. Only exact match is currently
> supported by FIB rules.
>
> [...]
Here is the summary with links:
- [net-next,1/6] net: fib_rules: Add DSCP mask attribute
https://git.kernel.org/netdev/net-next/c/ca4edd969a94
- [net-next,2/6] ipv4: fib_rules: Add DSCP mask matching
https://git.kernel.org/netdev/net-next/c/2ae00699b357
- [net-next,3/6] ipv6: fib_rules: Add DSCP mask matching
https://git.kernel.org/netdev/net-next/c/c29165c272b8
- [net-next,4/6] net: fib_rules: Enable DSCP mask usage
https://git.kernel.org/netdev/net-next/c/ea8af1affdc0
- [net-next,5/6] netlink: specs: Add FIB rule DSCP mask attribute
https://git.kernel.org/netdev/net-next/c/0df1328eaf04
- [net-next,6/6] selftests: fib_rule_tests: Add DSCP mask match tests
https://git.kernel.org/netdev/net-next/c/e818d1d1a6ee
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-02-22 0:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 8:05 [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 1/6] net: fib_rules: Add DSCP mask attribute Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 2/6] ipv4: fib_rules: Add DSCP mask matching Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 3/6] ipv6: " Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 4/6] net: fib_rules: Enable DSCP mask usage Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 5/6] netlink: specs: Add FIB rule DSCP mask attribute Ido Schimmel
2025-02-20 8:05 ` [PATCH net-next 6/6] selftests: fib_rule_tests: Add DSCP mask match tests Ido Schimmel
2025-02-21 15:29 ` [PATCH net-next 0/6] net: fib_rules: Add DSCP mask support Guillaume Nault
2025-02-22 0:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).