Skip to contentSkip to conversation

tc: m_tunnel_key: fix geneve opt output

PATCH In review Hangbin Liu 3 participants 6 messages Jun 18, 2020 – Jun 19, 2020

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

PATCH 1/1 tc: m_tunnel_key: fix geneve opt output

Commit f72c3ad00f3b changed the geneve option output from "geneve_opt" to "geneve_opts", which may break the program compatibility. Reset it back to geneve_opt.

Fixes f72c3ad00f3b ("tc: m_tunnel_key: add options support for vxlan")
---
 tc/m_tunnel_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tc/m_tunnel_key.c +1 -1
index bfec9072..0074f744 100644
@@ -534,7 +534,7 @@ static void tunnel_key_print_geneve_options(struct rtattr *attr)
 	struct rtattr *i = RTA_DATA(attr);
 	int ii, data_len = 0, offset = 0;
 	int rem = RTA_PAYLOAD(attr);
-	char *name = "geneve_opts";
+	char *name = "geneve_opt";
 	char strbuf[rem * 2 + 1];
 	char data[rem * 2 + 1];
 	uint8_t data_r[rem];
Signature · 1 line
2.25.4
#1 lore raw
Quoted 6 lines · Hangbin Liu

Commit f72c3ad00f3b changed the geneve option output from "geneve_opt" to "geneve_opts", which may break the program compatibility. Reset it back to geneve_opt.

Fixes f72c3ad00f3b ("tc: m_tunnel_key: add options support for vxlan")

Thanks Hangbin.

I agree that the patch in question did change the name of the option as you describe, perhaps inadvertently. But I wonder if perhaps this fix is too simple as the patch mentioned also:

1. Documents the option as geneve_opts
2. Adds vxlan_opts

So this patch invalidates the documentation and creates asymmetry between the VXLAN and Geneve variants of this feature.

Another problem is that any user of geneve_opts will break.

Perhaps a way out of this mess is to:
1. make geneve_opt an alias for geneve_opts (i.e. two names for the same thing)
2. Document geneve_opt, possibly marking it as deprecated.

Quoted 20 lines
---
 tc/m_tunnel_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tc/m_tunnel_key.c +1 -1
index bfec9072..0074f744 100644
@@ -534,7 +534,7 @@ static void tunnel_key_print_geneve_options(struct rtattr *attr)
 	struct rtattr *i = RTA_DATA(attr);
 	int ii, data_len = 0, offset = 0;
 	int rem = RTA_PAYLOAD(attr);
-	char *name = "geneve_opts";
+	char *name = "geneve_opt";
 	char strbuf[rem * 2 + 1];
 	char data[rem * 2 + 1];
 	uint8_t data_r[rem];
Signature · 1 line
2.25.4
#2 lore raw
Quoted 14 lines · Simon Horman
Quoted 6 lines · Hangbin Liu

Commit f72c3ad00f3b changed the geneve option output from "geneve_opt" to "geneve_opts", which may break the program compatibility. Reset it back to geneve_opt.

Fixes f72c3ad00f3b ("tc: m_tunnel_key: add options support for vxlan")

Thanks Hangbin.

I agree that the patch in question did change the name of the option as you describe, perhaps inadvertently. But I wonder if perhaps this fix is too simple as the patch mentioned also:

Quoted 5 lines

1. Documents the option as geneve_opts
2. Adds vxlan_opts

So this patch invalidates the documentation and creates asymmetry between the VXLAN and Geneve variants of this feature.

Not sure if I understand you comment correctly. This patch only fix the cmd output(revert to previous output format), The cmd option is not changed. e.g.

# tc actions add action tunnel_key set src_ip 1.1.1.1 dst_ip 2.2.2.2 id 42 \
     dst_port 6081 geneve_opts 0102:80:00880022 index 1
# tc actions get action tunnel_key index 1
total acts 0
        action order 1: tunnel_key  set
        src_ip 1.1.1.1
        dst_ip 2.2.2.2
        key_id 42
        dst_port 6081
        geneve_opt 0102:80:00880022
        csum pipe
         index 1 ref 1 bind 0

But this do make a asymmetry for vxlan and geneve output. I prefer to let them consistent personally. Also it looks more reasonable to output "geneve_opts" when we have parameter geneve_opts.

So I'm not going to fix it in iproute, but do as Davide mentioned, make tdc test case accept both 'geneve_opts' and 'geneve_opt'.

Thanks
Hangbin

#3 lore raw
Quoted 38 lines · Hangbin Liu
Quoted 14 lines · Simon Horman
Quoted 6 lines · Hangbin Liu

Commit f72c3ad00f3b changed the geneve option output from "geneve_opt" to "geneve_opts", which may break the program compatibility. Reset it back to geneve_opt.

Fixes f72c3ad00f3b ("tc: m_tunnel_key: add options support for vxlan")

Thanks Hangbin.

I agree that the patch in question did change the name of the option as you describe, perhaps inadvertently. But I wonder if perhaps this fix is too simple as the patch mentioned also:

Quoted 5 lines

1. Documents the option as geneve_opts
2. Adds vxlan_opts

So this patch invalidates the documentation and creates asymmetry between the VXLAN and Geneve variants of this feature.

Not sure if I understand you comment correctly. This patch only fix the cmd output(revert to previous output format), The cmd option is not changed. e.g.

# tc actions add action tunnel_key set src_ip 1.1.1.1 dst_ip 2.2.2.2 id 42 \
     dst_port 6081 geneve_opts 0102:80:00880022 index 1
# tc actions get action tunnel_key index 1
total acts 0
        action order 1: tunnel_key  set
        src_ip 1.1.1.1
        dst_ip 2.2.2.2
        key_id 42
        dst_port 6081
        geneve_opt 0102:80:00880022
        csum pipe
         index 1 ref 1 bind 0
Quoted 6 lines

But this do make a asymmetry for vxlan and geneve output. I prefer to let them consistent personally. Also it looks more reasonable to output "geneve_opts" when we have parameter geneve_opts.

So I'm not going to fix it in iproute, but do as Davide mentioned, make tdc test case accept both 'geneve_opts' and 'geneve_opt'.

Thanks. I agree this seems to be the best way forward.

#4 lore raw
In reply to Hangbin Liu
Quoted 15 lines · Hangbin Liu

Commit f72c3ad00f3b changed the geneve option output from "geneve_opt" to "geneve_opts", which may break the program compatibility. Reset it back to geneve_opt.

Fixes f72c3ad00f3b ("tc: m_tunnel_key: add options support for vxlan")
---
 tc/m_tunnel_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tc/m_tunnel_key.c +0 -0
index bfec9072..0074f744 100644

tc/m_tunnel_key.c static void tunnel_key_print_geneve_options(struct rtattr *attr) · line 540

Quoted 8 lines
tc/m_tunnel_key.c +1 -1
@@ -534,7 +534,7 @@ static void tunnel_key_print_geneve_options(struct rtattr *attr)
 	struct rtattr *i = RTA_DATA(attr);
 	int ii, data_len = 0, offset = 0;
 	int rem = RTA_PAYLOAD(attr);
-	char *name = "geneve_opts";
+	char *name = "geneve_opt";
 	char strbuf[rem * 2 + 1];
 	char data[rem * 2 + 1];
 	uint8_t data_r[rem];

... by the way, this patch does not look good to me. It fixes program compatibility for

# tc action show 

but at the same time, I think it breaks program compatibility for

# tc -j action show

see below: looking at commit f72c3ad00f3b,

static void tunnel_key_print_tos_ttl(FILE *f, char *name,
@@ -519,8 +586,7 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)

                                        tb[TCA_TUNNEL_KEY_ENC_KEY_ID]);
                tunnel_key_print_dst_port(f, "dst_port",
                                          tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);

- tunnel_key_print_key_opt("geneve_opts",
- tb[TCA_TUNNEL_KEY_ENC_OPTS]);
+ tunnel_key_print_key_opt(tb[TCA_TUNNEL_KEY_ENC_OPTS])

here "name" was "geneve_opts", with the 's', and it was used here:

		open_json_array(PRINT_JSON, name);

so, the proper way to restore script compatibility is to do something like:

- print_string(PRINT_FP, name, "\t%s ", name);
+ print_string(PRINT_FP, NULL, "\t%s ", "geneve_opt");

yes, we can "harmonize" like Simon proposed, but then the fix in the (currently broken) tdc test case should accept both 'geneve_opts' and 'geneve_opt'. Something similar has been done in the past for act_ife see net.git commit 91fa038d9446 ("selftests: tc-testing: fix parsing of ife type").

Signature · 1 line
davide
#5 lore raw
Quoted 28 lines · Davide Caratti
Quoted 15 lines · Hangbin Liu

Commit f72c3ad00f3b changed the geneve option output from "geneve_opt" to "geneve_opts", which may break the program compatibility. Reset it back to geneve_opt.

Fixes f72c3ad00f3b ("tc: m_tunnel_key: add options support for vxlan")
---
 tc/m_tunnel_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tc/m_tunnel_key.c +0 -0
index bfec9072..0074f744 100644

tc/m_tunnel_key.c static void tunnel_key_print_geneve_options(struct rtattr *attr) · line 540

Quoted 8 lines
tc/m_tunnel_key.c +1 -1
@@ -534,7 +534,7 @@ static void tunnel_key_print_geneve_options(struct rtattr *attr)
 	struct rtattr *i = RTA_DATA(attr);
 	int ii, data_len = 0, offset = 0;
 	int rem = RTA_PAYLOAD(attr);
-	char *name = "geneve_opts";
+	char *name = "geneve_opt";
 	char strbuf[rem * 2 + 1];
 	char data[rem * 2 + 1];
 	uint8_t data_r[rem];

... by the way, this patch does not look good to me. It fixes program compatibility for

Quoted 5 lines
# tc action show 

but at the same time, I think it breaks program compatibility for

# tc -j action show

Ah, sorry, I'm not familiar with json output and forgot to check it. Thanks for the remind.

Quoted 22 lines

see below: looking at commit f72c3ad00f3b,

static void tunnel_key_print_tos_ttl(FILE *f, char *name,

(quoted diff) +1 -2
@@ -519,8 +586,7 @@ static int print_tunnel_key(struct action_util *au, FILE *f, struct rtattr *arg)
                                        tb[TCA_TUNNEL_KEY_ENC_KEY_ID]);
                tunnel_key_print_dst_port(f, "dst_port",
                                          tb[TCA_TUNNEL_KEY_ENC_DST_PORT]);
-               tunnel_key_print_key_opt("geneve_opts",
-                                        tb[TCA_TUNNEL_KEY_ENC_OPTS]);
+               tunnel_key_print_key_opt(tb[TCA_TUNNEL_KEY_ENC_OPTS])
 

here "name" was "geneve_opts", with the 's', and it was used here:

		open_json_array(PRINT_JSON, name);

so, the proper way to restore script compatibility is to do something like:

(quoted diff) +1 -1
-	print_string(PRINT_FP, name, "\t%s ", name);
+	print_string(PRINT_FP, NULL, "\t%s ", "geneve_opt");
Quoted 5 lines

yes, we can "harmonize" like Simon proposed, but then the fix in the (currently broken) tdc test case should accept both 'geneve_opts' and 'geneve_opt'. Something similar has been done in the past for act_ife see net.git commit 91fa038d9446 ("selftests: tc-testing: fix parsing of ife type").

From semantics, it looks more reasonable to output "geneve_opts" as the parameter is "geneve_opts", which is also symmetry with vxlan.

So I'm going to fix the tdc to accept both 'geneve_opts' and 'geneve_opt'.

Thanks
Hangbin