Skip to contentSkip to conversation

selftests: forwarding: vxlan_bridge_1d: fix tos value

PATCH Applied Hangbin Liu 4 participants 10 messages Feb 13, 2020 – Feb 18, 2020

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

PATCH 1/1 selftests: forwarding: vxlan_bridge_1d: fix tos value

After commit 71130f29979c ("vxlan: fix tos value before xmit") we start strict vxlan xmit tos value by RT_TOS(), which limits the tos value less than 0x1E. With current value 0x40 the test will failed with "v1: Expected to capture 10 packets, got 0". So let's choose a smaller tos value for testing.

Fixes d417ecf533fe ("selftests: forwarding: vxlan_bridge_1d: Add a TOS test")
---
 tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +3 -3
index bb10e33690b2..353613fc1947 100755
@@ -516,9 +516,9 @@ test_tos()
 	RET=0
 
 	tc filter add dev v1 egress pref 77 prot ip \
-		flower ip_tos 0x40 action pass
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x40" v1 egress 77 10
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x30" v1 egress 77 0
+		flower ip_tos 0x11 action pass
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x11" v1 egress 77 10
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x12" v1 egress 77 0
 	tc filter del dev v1 egress pref 77 prot ip
 
 	log_test "VXLAN: envelope TOS inheritance"
Signature · 1 line
2.19.2
#1 lore raw
Quoted 2 lines · Hangbin Liu

After commit 71130f29979c ("vxlan: fix tos value before xmit") we start strict vxlan xmit tos value by RT_TOS(), which limits the tos value less

I don't understand how it is OK to slice the TOS field like this. It could contain a DSCP value, which will be mangled.

Quoted 15 lines

than 0x1E. With current value 0x40 the test will failed with "v1: Expected to capture 10 packets, got 0". So let's choose a smaller tos value for testing.

Fixes d417ecf533fe ("selftests: forwarding: vxlan_bridge_1d: Add a TOS test")
---
 tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +0 -0
index bb10e33690b2..353613fc1947 100755

tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh test_tos() · line 521

Quoted 9 lines
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +3 -3
@@ -516,9 +516,9 @@ test_tos()
 	RET=0
 
 	tc filter add dev v1 egress pref 77 prot ip \
-		flower ip_tos 0x40 action pass
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x40" v1 egress 77 10
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x30" v1 egress 77 0
+		flower ip_tos 0x11 action pass
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x11" v1 egress 77 10
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x12" v1 egress 77 0

0x11 and 0x12 set the ECN bits, I think it would be better to avoid that. It works just as well with 0x14 and 0x18.

Quoted 3 lines
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +0 -0
 	tc filter del dev v1 egress pref 77 prot ip
 
 	log_test "VXLAN: envelope TOS inheritance"
#2 lore raw
Quoted 8 lines · Petr Machata
Quoted 2 lines · Hangbin Liu

After commit 71130f29979c ("vxlan: fix tos value before xmit") we start strict vxlan xmit tos value by RT_TOS(), which limits the tos value less

I don't understand how it is OK to slice the TOS field like this. It could contain a DSCP value, which will be mangled.

Thanks for this remind. I re-checked the tos definition and found a summary from Peter Dawson[1].

IPv4/6 Header:0 |0 1 2 3 |0 1 2 3 |0 1 2 3 |0 1 2 3 |
RFC2460(IPv6)   |Version | Traffic Class   |        |
RFC2474(IPv6)   |Version | DSCP        |ECN|        |
RFC2474(IPv4)   |Version |  IHL   |    DSCP     |ECN|
RFC1349(IPv4)   |Version |  IHL   | PREC |  TOS   |X|
RFC791 (IPv4)   |Version |  IHL   |      TOS        |

According to this I think our current IPTOS_TOS_MASK should be updated to 0xFC based on RFC2474. But I'm not sure if there will have compatibility issue.

What do you think?

Quoted 10 lines

tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh test_tos() · line 521

Quoted 7 lines
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +3 -3
 	tc filter add dev v1 egress pref 77 prot ip \
-		flower ip_tos 0x40 action pass
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x40" v1 egress 77 10
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x30" v1 egress 77 0
+		flower ip_tos 0x11 action pass
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x11" v1 egress 77 10
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x12" v1 egress 77 0

0x11 and 0x12 set the ECN bits, I think it would be better to avoid that. It works just as well with 0x14 and 0x18.

Thanks, I will update it.

[1] https://lore.kernel.org/patchwork/patch/799698/#992992

Regards
Hangbin

#3 lore raw
Quoted 20 lines · Hangbin Liu
Quoted 8 lines · Petr Machata
Quoted 2 lines · Hangbin Liu

After commit 71130f29979c ("vxlan: fix tos value before xmit") we start strict vxlan xmit tos value by RT_TOS(), which limits the tos value less

I don't understand how it is OK to slice the TOS field like this. It could contain a DSCP value, which will be mangled.

Thanks for this remind. I re-checked the tos definition and found a summary from Peter Dawson[1].

IPv4/6 Header:0 |0 1 2 3 |0 1 2 3 |0 1 2 3 |0 1 2 3 |
RFC2460(IPv6)   |Version | Traffic Class   |        |
RFC2474(IPv6)   |Version | DSCP        |ECN|        |
RFC2474(IPv4)   |Version |  IHL   |    DSCP     |ECN|
RFC1349(IPv4)   |Version |  IHL   | PREC |  TOS   |X|
RFC791 (IPv4)   |Version |  IHL   |      TOS        |
Quoted 3 lines

According to this I think our current IPTOS_TOS_MASK should be updated to 0xFC based on RFC2474. But I'm not sure if there will have compatibility issue. What do you think?

Looking at the various uses of RT_TOS, it looks like they tend to be used in tunneling and routing code. I think that in both cases it makes sense to convert to 0xfc. But I'm not ready to vouch for this :)

What is the problem that commit 71130f29979c aims to solve? It's not clear to me from the commit message. What issues arise if the TOS is copied as is?

Quoted 18 lines
Quoted 11 lines

tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh test_tos() · line 521

Quoted 8 lines
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +3 -3
 	tc filter add dev v1 egress pref 77 prot ip \
-		flower ip_tos 0x40 action pass
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x40" v1 egress 77 10
-	vxlan_ping_test $h1 192.0.2.3 "-Q 0x30" v1 egress 77 0
+		flower ip_tos 0x11 action pass
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x11" v1 egress 77 10
+	vxlan_ping_test $h1 192.0.2.3 "-Q 0x12" v1 egress 77 0

0x11 and 0x12 set the ECN bits, I think it would be better to avoid that. It works just as well with 0x14 and 0x18.

Thanks, I will update it.

[1] https://lore.kernel.org/patchwork/patch/799698/#992992

Regards
Hangbin

#4 lore raw
Quoted 16 lines · Petr Machata
Quoted 16 lines
Quoted 5 lines
Quoted 2 lines

After commit 71130f29979c ("vxlan: fix tos value before xmit") we start strict vxlan xmit tos value by RT_TOS(), which limits the tos value less

I don't understand how it is OK to slice the TOS field like this. It could contain a DSCP value, which will be mangled.

Thanks for this remind. I re-checked the tos definition and found a summary from Peter Dawson[1].

IPv4/6 Header:0 |0 1 2 3 |0 1 2 3 |0 1 2 3 |0 1 2 3 |
RFC2460(IPv6)   |Version | Traffic Class   |        |
RFC2474(IPv6)   |Version | DSCP        |ECN|        |
RFC2474(IPv4)   |Version |  IHL   |    DSCP     |ECN|
RFC1349(IPv4)   |Version |  IHL   | PREC |  TOS   |X|
RFC791 (IPv4)   |Version |  IHL   |      TOS        |
Quoted 7 lines
Quoted 3 lines

According to this I think our current IPTOS_TOS_MASK should be updated to 0xFC based on RFC2474. But I'm not sure if there will have compatibility issue. What do you think?

Looking at the various uses of RT_TOS, it looks like they tend to be used in tunneling and routing code. I think that in both cases it makes sense to convert to 0xfc. But I'm not ready to vouch for this :)

Yes, I also could not... Maybe David or Daniel could help give some comments?

Quoted 4 lines

What is the problem that commit 71130f29979c aims to solve? It's not clear to me from the commit message. What issues arise if the TOS is copied as is?

As the commit said, we should not use config tos directly. We should remove the precedence field based on RFC1349 or ENC field based on RFC2474.

Thanks
Hangbin

#5 lore raw
Quoted 28 lines · Hangbin Liu
Quoted 16 lines · Petr Machata
Quoted 16 lines
Quoted 5 lines
Quoted 2 lines

After commit 71130f29979c ("vxlan: fix tos value before xmit") we start strict vxlan xmit tos value by RT_TOS(), which limits the tos value less

I don't understand how it is OK to slice the TOS field like this. It could contain a DSCP value, which will be mangled.

Thanks for this remind. I re-checked the tos definition and found a summary from Peter Dawson[1].

IPv4/6 Header:0 |0 1 2 3 |0 1 2 3 |0 1 2 3 |0 1 2 3 |
RFC2460(IPv6)   |Version | Traffic Class   |        |
RFC2474(IPv6)   |Version | DSCP        |ECN|        |
RFC2474(IPv4)   |Version |  IHL   |    DSCP     |ECN|
RFC1349(IPv4)   |Version |  IHL   | PREC |  TOS   |X|
RFC791 (IPv4)   |Version |  IHL   |      TOS        |
Quoted 7 lines
Quoted 3 lines

According to this I think our current IPTOS_TOS_MASK should be updated to 0xFC based on RFC2474. But I'm not sure if there will have compatibility issue. What do you think?

Looking at the various uses of RT_TOS, it looks like they tend to be used in tunneling and routing code. I think that in both cases it makes sense to convert to 0xfc. But I'm not ready to vouch for this :)

Yes, I also could not... Maybe David or Daniel could help give some comments?

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

What is the problem that commit 71130f29979c aims to solve? It's not clear to me from the commit message. What issues arise if the TOS is copied as is?

As the commit said, we should not use config tos directly. We should remove the precedence field based on RFC1349 or ENC field based on RFC2474.

Well, RFC1349 didn't know about DSCP. I do not think it is possible to conform to both RFC1349 and RFC2474 at the same time.

RFC2474 states that "DS field [...] is intended to supersede the existing definitions of the IPv4 TOS octet [RFC791] and the IPv6 Traffic Class octet [IPv6]". So the field should be assumed to contain DSCP from that point on. In my opinion, that makes commit 71130f29979c incorrect.

(And other similar uses of RT_TOS in other tunneling devices likewise.)

#6 lore raw
Quoted 10 lines · Petr Machata
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

Thanks for this remind. I re-checked the tos definition and found a summary from Peter Dawson[1].

IPv4/6 Header:0 |0 1 2 3 |0 1 2 3 |0 1 2 3 |0 1 2 3 |
RFC2460(IPv6)   |Version | Traffic Class   |        |
RFC2474(IPv6)   |Version | DSCP        |ECN|        |
RFC2474(IPv4)   |Version |  IHL   |    DSCP     |ECN|
RFC1349(IPv4)   |Version |  IHL   | PREC |  TOS   |X|
RFC791 (IPv4)   |Version |  IHL   |      TOS        |
Quoted 5 lines
Quoted 2 lines

As the commit said, we should not use config tos directly. We should remove the precedence field based on RFC1349 or ENC field based on RFC2474.

Well, RFC1349 didn't know about DSCP. I do not think it is possible to conform to both RFC1349 and RFC2474 at the same time.

No, we can't. I mean no mater based on RFC1349 or RFC2474, we should not use the config tos directly.

Quoted 7 lines

RFC2474 states that "DS field [...] is intended to supersede the existing definitions of the IPv4 TOS octet [RFC791] and the IPv6 Traffic Class octet [IPv6]". So the field should be assumed to contain DSCP from that point on. In my opinion, that makes commit 71130f29979c incorrect.

(And other similar uses of RT_TOS in other tunneling devices likewise.)

Yes, that's also what I mean, should we update RT_TOS to match RFC2474?

Thanks
Hangbin

maintainer
#7 lore raw

From: Hangbin Liu <[email protected]>
Date: Tue, 18 Feb 2020 10:05:08 +0800

Quoted 10 lines · Petr Machata
Quoted 6 lines

RFC2474 states that "DS field [...] is intended to supersede the existing definitions of the IPv4 TOS octet [RFC791] and the IPv6 Traffic Class octet [IPv6]". So the field should be assumed to contain DSCP from that point on. In my opinion, that makes commit 71130f29979c incorrect.

(And other similar uses of RT_TOS in other tunneling devices likewise.)

Yes, that's also what I mean, should we update RT_TOS to match RFC2474?

The RT_TOS() value elides the two lowest bits so that we can store other pieces of binary state into those two lower bits.

So you can't just blindly change the RT_TOS() definition without breaking a bunch of things.

#8 lore raw

Hi David,

Thanks for the comments. Please see the reply below.

Quoted 6 lines · David Miller
Quoted 6 lines · Petr Machata
Quoted 5 lines

RFC2474 states that "DS field [...] is intended to supersede the existing definitions of the IPv4 TOS octet [RFC791] and the IPv6 Traffic Class octet [IPv6]". So the field should be assumed to contain DSCP from that point on. In my opinion, that makes commit 71130f29979c incorrect.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

(And other similar uses of RT_TOS in other tunneling devices likewise.)

Yes, that's also what I mean, should we update RT_TOS to match RFC2474?

The RT_TOS() value elides the two lowest bits so that we can store other pieces of binary state into those two lower bits.

In my understanding, RT_TOS() only omit the lowest bits and first 3 bit, as it defined like:
#define RT_TOS(tos) ((tos)&IPTOS_TOS_MASK)
#define IPTOS_TOS_MASK 0x1E

Quoted 3 lines
IPv4/6 Header:0 |0 1 2 3 |0 1 2 3 |0 1 2 3 |0 1 2 3 |
RFC2474(IPv4)   |Version |  IHL   |    DSCP     |ECN|
RFC1349(IPv4)   |Version |  IHL   | PREC |  TOS   |X|

This looks that it's based on rfc1349. At the same time, we have function INET_ECN_encapsulate() to respect of rfc2474, which elides the two lowest bits to stor ECN.

But this two has some conflicts. RT_TOS() omit config tos with 3 PREC bits and 1 ECN bit. INET_ECN_encapsulate() then omit 1 more ECN bits and set new ECN based on inner header.

Petr mentioned(and I agree) that this would make us lost 3 DSCP bit info. So what I though is we should update IPTOS_TOS_MASK to 0xFC, so we can catch all DSCP field from config tos and leave the two lowest ECN bit to INET_ECN_encapsulate().

Quoted 3 lines

So you can't just blindly change the RT_TOS() definition without breaking a bunch of things.

Yes, RT_TOS() was used in many places. I'm also afraid it may break some old configs. But then I found that the current IPTOS_TOS_MASK is more strict. It only take 4 bits(and 1 bit will be overwrite by ECN bit later) from tos config. If we update it to 0xFC, it would take more bits.

So what do you think?

Thanks
Hangbin

maintainer Applied
#9 lore raw
In reply to Hangbin Liu

From: Hangbin Liu <[email protected]>
Date: Thu, 13 Feb 2020 17:40:54 +0800

Quoted 8 lines

After commit 71130f29979c ("vxlan: fix tos value before xmit") we start strict vxlan xmit tos value by RT_TOS(), which limits the tos value less than 0x1E. With current value 0x40 the test will failed with "v1: Expected to capture 10 packets, got 0". So let's choose a smaller tos value for testing.

Fixes d417ecf533fe ("selftests: forwarding: vxlan_bridge_1d: Add a TOS test")

Applied.