Skip to contentSkip to conversation

vxlan: show correct ttl inherit info

PATCH In review Hangbin Liu 2 participants 4 messages Sep 27, 2018

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

PATCH 1/1 vxlan: show correct ttl inherit info

We should only show ttl inherit when IFLA_VXLAN_TTL_INHERIT supplied. Otherwise show the ttl number, or auto when it is 0.

---
 ip/iplink_vxlan.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
ip/iplink_vxlan.c +10 -6
index 831f39a..7fc0e2b 100644
@@ -145,7 +145,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 			NEXT_ARG();
 			check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
 			if (strcmp(*argv, "inherit") == 0) {
-				addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
+				addattr(n, 1024, IFLA_VXLAN_TTL_INHERIT);
 			} else if (strcmp(*argv, "auto") == 0) {
 				addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
 			} else {
@@ -527,12 +527,16 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 			print_string(PRINT_FP, NULL, "tos %s ", "inherit");
 	}
 
-	if (tb[IFLA_VXLAN_TTL])
-		ttl = rta_getattr_u8(tb[IFLA_VXLAN_TTL]);
-	if (is_json_context() || ttl)
-		print_uint(PRINT_ANY, "ttl", "ttl %u ", ttl);
-	else
+	if (tb[IFLA_VXLAN_TTL_INHERIT] &&
+	    rta_getattr_u8(tb[IFLA_VXLAN_TTL_INHERIT])) {
 		print_string(PRINT_FP, NULL, "ttl %s ", "inherit");
+	} else if (tb[IFLA_VXLAN_TTL]) {
+		ttl = rta_getattr_u8(tb[IFLA_VXLAN_TTL]);
+		if (is_json_context() || ttl)
+			print_uint(PRINT_ANY, "ttl", "ttl %u ", ttl);
+		else
+			print_string(PRINT_FP, NULL, "ttl %s ", "auto");
+	}
 
 	if (tb[IFLA_VXLAN_LABEL]) {
 		__u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
Signature · 1 line
2.5.5
#1 lore raw

Hi Hangbin,

Quoted 13 lines · Hangbin Liu

We should only show ttl inherit when IFLA_VXLAN_TTL_INHERIT supplied. Otherwise show the ttl number, or auto when it is 0.

---
 ip/iplink_vxlan.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
ip/iplink_vxlan.c +0 -0
index 831f39a..7fc0e2b 100644

ip/iplink_vxlan.c static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, · line 148

Quoted 5 lines
ip/iplink_vxlan.c +1 -1
@@ -145,7 +145,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 			NEXT_ARG();
 			check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
 			if (strcmp(*argv, "inherit") == 0) {
-				addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
+				addattr(n, 1024, IFLA_VXLAN_TTL_INHERIT);

So for VXLAN, the attribute is just added but with a zero value. Looking at respective kernel code, this seems fine. Now I wonder why for Geneve, you set the value to 1 and when displaying explicitly check whether the attribute is there *and* non-zero. OK, looks like Geneve driver always exports IFLA_GENEVE_TTL_INHERIT. Oddly, I can't find where VXLAN driver in kernel does export the IFLA_VXLAN_TTL_INHERIT attribute. Am I missing something?
Do you know why handling of the attributes in both drivers differ?

Cheers, Phil

#2 lore raw
Quoted 22 lines · Phil Sutter

Hi Hangbin,

Quoted 13 lines · Hangbin Liu

We should only show ttl inherit when IFLA_VXLAN_TTL_INHERIT supplied. Otherwise show the ttl number, or auto when it is 0.

---
 ip/iplink_vxlan.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
ip/iplink_vxlan.c +0 -0
index 831f39a..7fc0e2b 100644

ip/iplink_vxlan.c static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, · line 148

Quoted 5 lines
ip/iplink_vxlan.c +1 -1
@@ -145,7 +145,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 			NEXT_ARG();
 			check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
 			if (strcmp(*argv, "inherit") == 0) {
-				addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
+				addattr(n, 1024, IFLA_VXLAN_TTL_INHERIT);
Quoted 7 lines

So for VXLAN, the attribute is just added but with a zero value. Looking at respective kernel code, this seems fine. Now I wonder why for Geneve, you set the value to 1 and when displaying explicitly check whether the attribute is there *and* non-zero. OK, looks like Geneve driver always exports IFLA_GENEVE_TTL_INHERIT. Oddly, I can't find where VXLAN driver in kernel does export the IFLA_VXLAN_TTL_INHERIT attribute. Am I missing something?

Hi Phil,

The vxlan ttl inherit exportation is just fixed by
net commit 8fd78069874 ("vxlan: fill ttl inherit info") yesterday.

Quoted 1 line

Do you know why handling of the attributes in both drivers differ?

That's because I set IFLA_VXLAN_TTL_INHERIT type to NLA_FLAG. But when fix the geneve issue, I forgot this and set IFLA_GENEVE_TTL_INHERIT type to NLA_U8... :(

I noticed this when post the iproute2 patch. But I thought this should have no much influence, so I just leave it as it is.

If you think we'd better have a same behaver. We can drop the geneve iproute2 patch and post a fix to net kernel tree.

Thanks
Hangbin

#3 lore raw

Hi Hangbin,

Quoted 29 lines · Hangbin Liu
Quoted 20 lines · Phil Sutter
Quoted 13 lines · Hangbin Liu

We should only show ttl inherit when IFLA_VXLAN_TTL_INHERIT supplied. Otherwise show the ttl number, or auto when it is 0.

---
 ip/iplink_vxlan.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
ip/iplink_vxlan.c +0 -0
index 831f39a..7fc0e2b 100644

ip/iplink_vxlan.c static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, · line 148

Quoted 5 lines
ip/iplink_vxlan.c +1 -1
@@ -145,7 +145,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 			NEXT_ARG();
 			check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
 			if (strcmp(*argv, "inherit") == 0) {
-				addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
+				addattr(n, 1024, IFLA_VXLAN_TTL_INHERIT);
Quoted 7 lines

So for VXLAN, the attribute is just added but with a zero value. Looking at respective kernel code, this seems fine. Now I wonder why for Geneve, you set the value to 1 and when displaying explicitly check whether the attribute is there *and* non-zero. OK, looks like Geneve driver always exports IFLA_GENEVE_TTL_INHERIT. Oddly, I can't find where VXLAN driver in kernel does export the IFLA_VXLAN_TTL_INHERIT attribute. Am I missing something?

Quoted 4 lines

Hi Phil,

The vxlan ttl inherit exportation is just fixed by
net commit 8fd78069874 ("vxlan: fill ttl inherit info") yesterday.

Ah, thanks!

Quoted 11 lines
Quoted 1 line

Do you know why handling of the attributes in both drivers differ?

That's because I set IFLA_VXLAN_TTL_INHERIT type to NLA_FLAG. But when fix the geneve issue, I forgot this and set IFLA_GENEVE_TTL_INHERIT type to NLA_U8... :(

I noticed this when post the iproute2 patch. But I thought this should have no much influence, so I just leave it as it is.

If you think we'd better have a same behaver. We can drop the geneve iproute2 patch and post a fix to net kernel tree.

I guess it doesn't make much difference, but NLA_FLAG would be more appropriate. If you want to spend the extra effort to fix it, I guess now's the time - later it can't be changed anymore due to compatibility issues (I guess).

Thanks, Phil