Skip to contentSkip to conversation

ipv4: allow newer DSCP values in ip rules

PATCH In review Pavel Balaev 2 participants 3 messages Nov 19, 2018 – Nov 20, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: allow newer DSCP values in ip rules

This patch adds ability to set newer RFC2597 DSCP values in ip rules. Values are presents in /etc/iproute2/rt_dsfield:

0x28    AF11
0x30    AF12
0x38    AF13
0x48    AF21

...

If one tries to apply this values with iproure2 (ip rule add tos 0x28 ...) he will get error from netlink: "Invalid tos" for this moment.

After this patch this one can use it:

$ ip r add default via 192.168.0.6 table test
$ ip ru add tos 0x80 table test
$ ip ru
0:      from all lookup local
32764:  from all tos CS4 lookup test
32766:  from all lookup main
32767:  from all lookup default
$ ip r get fibmatch 8.8.8.9 tos 0x80
default tos CS4 via 192.168.0.6 dev lan table test
---
 net/ipv4/fib_rules.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/fib_rules.c +1 -1
index f8eb78d0..7a6c5bfe 100644
@@ -220,7 +220,7 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
 	int err = -EINVAL;
 	struct fib4_rule *rule4 = (struct fib4_rule *) rule;
 
-	if (frh->tos & ~IPTOS_TOS_MASK) {
+	if (frh->tos & ~(IPTOS_TOS_MASK | IPTOS_PREC_MASK)) {
 		NL_SET_ERR_MSG(extack, "Invalid tos");
 		goto errout;
 	}
Signature · 1 line
2.18.1
maintainer
#1 lore raw

From: Pavel Balaev <[email protected]>
Date: Mon, 19 Nov 2018 12:00:45 +0300

Quoted 1 line

After this patch this one can use it:

You can "configure it" but it doesn't work at all.

Did you test this in any way beyond simply dumping the FIB rule tables?

The whole kernel masks the TOS value using RT_TOS() so it is going to clear out those extra bits every time the configured value actually gets used.

#2 lore raw
Quoted 5 lines · David Miller

From: Pavel Balaev <[email protected]>
Date: Mon, 19 Nov 2018 12:00:45 +0300

Quoted 1 line

After this patch this one can use it:

Quoted 8 lines

You can "configure it" but it doesn't work at all.

Did you test this in any way beyond simply dumping the FIB rule tables?

The whole kernel masks the TOS value using RT_TOS() so it is going to clear out those extra bits every time the configured value actually gets used.

Ok, I got it. I'll test RFC2597 values with full scheme and tries to make it works.