netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] vxlan: add support for flowlab inherit
@ 2024-01-20 12:44 Alce Lafranque
  2024-01-22 12:24 ` Ido Schimmel
  0 siblings, 1 reply; 15+ messages in thread
From: Alce Lafranque @ 2024-01-20 12:44 UTC (permalink / raw)
  To: netdev, stephen; +Cc: Alce Lafranque, Vincent Bernat

By default, VXLAN encapsulation over IPv6 sets the flow label to 0, with
an option for a fixed value. This commits add the ability to inherit the
flow label from the inner packet, like for other tunnel implementations.
This enables devices using only L3 headers for ECMP to correctly balance
VXLAN-encapsulated IPv6 packets.

In relation to the commit "c6e9dba3be5e" ('vxlan: add support for
                                           flowlabel inherit)

```
$ ./ip/ip link add dummy1 type dummy
$ ./ip/ip addr add 2001:db8::2/64 dev dummy1
$ ./ip/ip link set up dev dummy1
$ ./ip/ip link add vxlan1 type vxlan id 100 flowlabel inherit remote 2001:db8::1 local 2001:db8::2
$ ./ip/ip link set up dev vxlan1
$ ./ip/ip addr add 2001:db8:1::2/64 dev vxlan1
$ ./ip/ip link set arp off dev vxlan1
$ ping -q 2001:db8:1::1 &
$ tshark -d udp.port==8472,vxlan -Vpni dummy1 -c1
[...]
Internet Protocol Version 6, Src: 2001:db8::2, Dst: 2001:db8::1
    0110 .... = Version: 6
    .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
        .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
        .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
    .... 1011 0001 1010 1111 1011 = Flow Label: 0xb1afb
[...]
Virtual eXtensible Local Area Network
    Flags: 0x0800, VXLAN Network ID (VNI)
    Group Policy ID: 0
    VXLAN Network Identifier (VNI): 100
[...]
Internet Protocol Version 6, Src: 2001:db8:1::2, Dst: 2001:db8:1::1
    0110 .... = Version: 6
    .... 0000 0000 .... .... .... .... .... = Traffic Class: 0x00 (DSCP: CS0, ECN: Not-ECT)
        .... 0000 00.. .... .... .... .... .... = Differentiated Services Codepoint: Default (0)
        .... .... ..00 .... .... .... .... .... = Explicit Congestion Notification: Not ECN-Capable Transport (0)
    .... 1011 0001 1010 1111 1011 = Flow Label: 0xb1afb
```
```
$ ./ip/ip -d l l vxlan1
8: vxlan1: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 36:2c:83:91:53:9e brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
    vxlan id 100 remote 2001:db8::1 local 2001:db8::2 srcport 0 0 dstport 8472 ttl auto flowlabel inherit ageing 300 [...]
```

```
$ ./ip/ip link set vxlan1 type vxlan flowlabel 10
$ ./ip/ip -d l l vxlan1
8: vxlan1: <BROADCAST,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether 36:2c:83:91:53:9e brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
    vxlan id 100 remote 2001:db8::1 local 2001:db8::2 srcport 0 0 dstport 8472 ttl auto flowlabel 0xa ageing 300 [...]
```

Signed-off-by: Alce Lafranque <alce@lafranque.net>
Co-developed-by: Vincent Bernat <vincent@bernat.ch>
Signed-off-by: Vincent Bernat <vincent@bernat.ch>
---
 ip/iplink_vxlan.c | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 7781d60b..0b72a545 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -72,7 +72,7 @@ static void print_explain(FILE *f)
 		"	TOS	:= { NUMBER | inherit }\n"
 		"	TTL	:= { 1..255 | auto | inherit }\n"
 		"	DF	:= { unset | set | inherit }\n"
-		"	LABEL := 0-1048575\n"
+		"	LABEL   := { 0-1048575 | inherit }\n"
 	);
 }
 
@@ -214,10 +214,16 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 			NEXT_ARG();
 			check_duparg(&attrs, IFLA_VXLAN_LABEL, "flowlabel",
 				     *argv);
-			if (get_u32(&uval, *argv, 0) ||
-			    (uval & ~LABEL_MAX_MASK))
-				invarg("invalid flowlabel", *argv);
-			addattr32(n, 1024, IFLA_VXLAN_LABEL, htonl(uval));
+			if (strcmp(*argv, "inherit") == 0) {
+				addattr32(n, 1024, IFLA_VXLAN_LABEL_POLICY, VXLAN_LABEL_INHERIT);
+			} else {
+				if (get_u32(&uval, *argv, 0) ||
+				    (uval & ~LABEL_MAX_MASK))
+					invarg("invalid flowlabel", *argv);
+				addattr32(n, 1024, IFLA_VXLAN_LABEL_POLICY, VXLAN_LABEL_FIXED);
+				addattr32(n, 1024, IFLA_VXLAN_LABEL,
+					  htonl(uval));
+			}
 		} else if (!matches(*argv, "ageing")) {
 			__u32 age;
 
@@ -580,12 +586,25 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 			print_string(PRINT_ANY, "df", "df %s ", "inherit");
 	}
 
-	if (tb[IFLA_VXLAN_LABEL]) {
-		__u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
-
-		if (label)
-			print_0xhex(PRINT_ANY, "label",
-				    "flowlabel %#llx ", ntohl(label));
+	enum ifla_vxlan_label_policy policy = VXLAN_LABEL_FIXED;
+	if (tb[IFLA_VXLAN_LABEL_POLICY]) {
+		policy = rta_getattr_u32(tb[IFLA_VXLAN_LABEL_POLICY]);
+	}
+	switch (policy) {
+	case VXLAN_LABEL_FIXED:
+		if (tb[IFLA_VXLAN_LABEL]) {
+			__u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
+
+			if (label)
+				print_0xhex(PRINT_ANY, "label",
+					    "flowlabel %#llx ", ntohl(label));
+		}
+		break;
+	case VXLAN_LABEL_INHERIT:
+		print_string(PRINT_FP, NULL, "flowlabel %s ", "inherit");
+		break;
+	default:
+		break;
 	}
 
 	if (tb[IFLA_VXLAN_AGEING]) {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-01-29 18:44 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-20 12:44 [PATCH iproute2] vxlan: add support for flowlab inherit Alce Lafranque
2024-01-22 12:24 ` Ido Schimmel
2024-01-22 21:11   ` Vincent Bernat
2024-01-23  0:10     ` Stephen Hemminger
2024-01-23  0:29       ` David Ahern
2024-01-23  0:41   ` David Ahern
2024-01-23  7:58     ` Vincent Bernat
2024-01-23 16:19       ` David Ahern
2024-01-24 22:00         ` Vincent Bernat
2024-01-25 15:50           ` David Ahern
2024-01-26  6:28             ` Vincent Bernat
2024-01-26 17:17               ` David Ahern
2024-01-28 12:35                 ` Ido Schimmel
2024-01-28 14:28                   ` Vincent Bernat
2024-01-29 18:44                   ` David Ahern

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).