Skip to contentSkip to conversation

more patches from pm_nl_ctl

PATCH Superseded Geliang Tang 2 participants 8 messages Jan 4, 2022 – Jan 10, 2022 Networking MPTCP

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover more patches from pm_nl_ctl

This patched added id 0 address deleting, fullmesh flag and backup setting from pm_nl_ctl. With these patches, we can replace all pm_nl_ctl in the selftests with 'ip mptcp' command.

Geliang Tang (3):
mptcp: add id check for deleting address
mptcp: add the addr flag fullmesh
mptcp: add the backup flag setting

 include/uapi/linux/mptcp.h |  2 ++
 ip/ipmptcp.c               | 31 +++++++++++++++++++++++++------
 2 files changed, 27 insertions(+), 6 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH RESEND 1/3 mptcp: add id check for deleting address

This patch added the id check for deleting address in mptcp_parse_opt(). The ADDRESS argument is invalid for the non-zero id address, only needed for the id 0 address.

---
 ip/ipmptcp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
ip/ipmptcp.c +7 -1
index fd042da8..c2691ef4 100644
@@ -18,7 +18,7 @@ static void usage(void)
 	fprintf(stderr,
 		"Usage:	ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n"
 		"				      [ port NR ] [ FLAG-LIST ]\n"
-		"	ip mptcp endpoint delete id ID\n"
+		"	ip mptcp endpoint delete id ID [ ADDRESS ]\n"
 		"	ip mptcp endpoint show [ id ID ]\n"
 		"	ip mptcp endpoint flush\n"
 		"	ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
@@ -142,6 +142,12 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 
 	if (!id_set && !adding)
 		missarg("ID");
+	else if (id_set && !adding) {
+		if (id && addr_set)
+			invarg("invalid for non-zero id address\n", "ADDRESS");
+		else if (!id && !addr_set)
+			invarg("address is needed for deleting id 0 address\n", "ID");
+	}
 
 	if (port && !(flags & MPTCP_PM_ADDR_FLAG_SIGNAL))
 		invarg("flags must have signal when using port", "port");
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH RESEND iproute2-next 1/3] mptcp: add id check for deleting address

Quoted 15 lines · Geliang Tang

This patch added the id check for deleting address in mptcp_parse_opt(). The ADDRESS argument is invalid for the non-zero id address, only needed for the id 0 address.

---
ip/ipmptcp.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
ip/ipmptcp.c +0 -0
index fd042da8..c2691ef4 100644

ip/ipmptcp.c static void usage(void) · line 21

Quoted 5 lines
ip/ipmptcp.c +1 -1
@@ -18,7 +18,7 @@ static void usage(void)
 	fprintf(stderr,
 		"Usage:	ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n"
 		"				      [ port NR ] [ FLAG-LIST ]\n"
-		"	ip mptcp endpoint delete id ID\n"
+		"	ip mptcp endpoint delete id ID [ ADDRESS ]\n"

Please also update man/man8/ip-mptcp.8 for the optional ADDRESS parameter.

ip/ipmptcp.c static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, · line 145

Quoted 8 lines
ip/ipmptcp.c +1 -0
 		"	ip mptcp endpoint show [ id ID ]\n"
 		"	ip mptcp endpoint flush\n"
 		"	ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
@@ -142,6 +142,12 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 
 	if (!id_set && !adding)
 		missarg("ID");
+	else if (id_set && !adding) {

I think it would be good to move the 'deling' changes (and the change to the last parameter of mptcp_parse_opt()) from patch 3 to this patch.

Quoted 10 lines
ip/ipmptcp.c +5 -0
+		if (id && addr_set)
+			invarg("invalid for non-zero id address\n", "ADDRESS");
+		else if (!id && !addr_set)
+			invarg("address is needed for deleting id 0 address\n", "ID");
+	}
 
 	if (port && !(flags & MPTCP_PM_ADDR_FLAG_SIGNAL))
 		invarg("flags must have signal when using port", "port");
Signature · 1 line
2.31.1

--
Mat Martineau
Intel

#3 lore raw

PATCH 2/3 mptcp: add the addr flag fullmesh

In reply to Geliang Tang

The address flag fullmesh had been added into pm_nl_ctl.c in the commit 371b90377e60 ("selftests: mptcp: set and print the fullmesh flag"). This patch added it to 'ip mptcp' too.

---
 ip/ipmptcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
ip/ipmptcp.c +2 -1
index c2691ef4..8c4fd18c 100644
@@ -25,7 +25,7 @@ static void usage(void)
 		"	ip mptcp limits show\n"
 		"	ip mptcp monitor\n"
 		"FLAG-LIST := [ FLAG-LIST ] FLAG\n"
-		"FLAG  := [ signal | subflow | backup ]\n");
+		"FLAG  := [ signal | subflow | backup | fullmesh ]\n");
 
 	exit(-1);
 }
@@ -47,6 +47,7 @@ static const struct {
 	{ "signal",		MPTCP_PM_ADDR_FLAG_SIGNAL },
 	{ "subflow",		MPTCP_PM_ADDR_FLAG_SUBFLOW },
 	{ "backup",		MPTCP_PM_ADDR_FLAG_BACKUP },
+	{ "fullmesh",		MPTCP_PM_ADDR_FLAG_FULLMESH },
 };
 
 static void print_mptcp_addr_flags(unsigned int flags)
Signature · 1 line
2.31.1
#4 lore raw

PATCH 3/3 mptcp: add the backup flag setting

In reply to Geliang Tang

The address flag backup setting had been added into pm_nl_ctl.c in commit 6e8b244a3e9d ("selftests: mptcp: add set_flags command in pm_nl_ctl"). This patch added it to 'ip mptcp' too.

---
 include/uapi/linux/mptcp.h |  2 ++
 ip/ipmptcp.c               | 22 +++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)
include/uapi/linux/mptcp.h +2 -0
index 957743ce..2b76e526 100644
@@ -75,6 +75,8 @@ enum {
 #define MPTCP_PM_ADDR_FLAG_BACKUP			(1 << 2)
 #define MPTCP_PM_ADDR_FLAG_FULLMESH			(1 << 3)
 
+#define MPTCP_PM_ADDR_FLAG_MAX				(1 << 8)
+
 enum {
 	MPTCP_PM_CMD_UNSPEC,
 
ip/ipmptcp.c +17 -5
index 8c4fd18c..fc1fd5ce 100644
@@ -19,6 +19,7 @@ static void usage(void)
 		"Usage:	ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n"
 		"				      [ port NR ] [ FLAG-LIST ]\n"
 		"	ip mptcp endpoint delete id ID [ ADDRESS ]\n"
+		"	ip mptcp endpoint set ADDRESS [ backup | nobackup ]"
 		"	ip mptcp endpoint show [ id ID ]\n"
 		"	ip mptcp endpoint flush\n"
 		"	ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
@@ -47,6 +48,7 @@ static const struct {
 	{ "signal",		MPTCP_PM_ADDR_FLAG_SIGNAL },
 	{ "subflow",		MPTCP_PM_ADDR_FLAG_SUBFLOW },
 	{ "backup",		MPTCP_PM_ADDR_FLAG_BACKUP },
+	{ "nobackup",		MPTCP_PM_ADDR_FLAG_MAX },
 	{ "fullmesh",		MPTCP_PM_ADDR_FLAG_FULLMESH },
 };
 
@@ -91,17 +93,24 @@ static int get_flags(const char *arg, __u32 *flags)
 }
 
 static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
-			 bool adding)
+			 int cmd)
 {
 	struct rtattr *attr_addr;
 	bool addr_set = false;
 	inet_prefix address;
 	bool id_set = false;
+	bool adding = 0;
+	bool deling = 0;
 	__u32 index = 0;
 	__u32 flags = 0;
 	__u16 port = 0;
 	__u8 id = 0;
 
+	if (cmd == MPTCP_PM_CMD_ADD_ADDR)
+		adding = 1;
+	else if (cmd == MPTCP_PM_CMD_DEL_ADDR)
+		deling = 1;
+
 	ll_init_map(&rth);
 	while (argc > 0) {
 		if (get_flags(*argv, &flags) == 0) {
@@ -141,9 +150,9 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 	if (!addr_set && adding)
 		missarg("ADDRESS");
 
-	if (!id_set && !adding)
+	if (!id_set && deling)
 		missarg("ID");
-	else if (id_set && !adding) {
+	else if (id_set && deling) {
 		if (id && addr_set)
 			invarg("invalid for non-zero id address\n", "ADDRESS");
 		else if (!id && !addr_set)
@@ -183,7 +192,7 @@ static int mptcp_addr_modify(int argc, char **argv, int cmd)
 	MPTCP_REQUEST(req, cmd, NLM_F_REQUEST);
 	int ret;
 
-	ret = mptcp_parse_opt(argc, argv, &req.n, cmd == MPTCP_PM_CMD_ADD_ADDR);
+	ret = mptcp_parse_opt(argc, argv, &req.n, cmd);
 	if (ret)
 		return ret;
 
@@ -299,7 +308,7 @@ static int mptcp_addr_show(int argc, char **argv)
 	if (argc <= 0)
 		return mptcp_addr_dump();
 
-	ret = mptcp_parse_opt(argc, argv, &req.n, false);
+	ret = mptcp_parse_opt(argc, argv, &req.n, MPTCP_PM_CMD_DEL_ADDR);
 	if (ret)
 		return ret;
 
@@ -534,6 +543,9 @@ int do_mptcp(int argc, char **argv)
 		if (matches(*argv, "delete") == 0)
 			return mptcp_addr_modify(argc-1, argv+1,
 						 MPTCP_PM_CMD_DEL_ADDR);
+		if (matches(*argv, "set") == 0)
+			return mptcp_addr_modify(argc-1, argv+1,
+						 MPTCP_PM_CMD_SET_FLAGS);
 		if (matches(*argv, "show") == 0)
 			return mptcp_addr_show(argc-1, argv+1);
 		if (matches(*argv, "flush") == 0)
Signature · 1 line
2.31.1
#5 lore raw

Re: [PATCH iproute2-next 3/3] mptcp: add the backup flag setting

Quoted 28 lines · Geliang Tang

The address flag backup setting had been added into pm_nl_ctl.c in commit 6e8b244a3e9d ("selftests: mptcp: add set_flags command in pm_nl_ctl"). This patch added it to 'ip mptcp' too.

---
include/uapi/linux/mptcp.h | 2 ++
ip/ipmptcp.c | 22 +++++++++++++++++-----

2 files changed, 19 insertions(+), 5 deletions(-)
include/uapi/linux/mptcp.h +2 -0
index 957743ce..2b76e526 100644
@@ -75,6 +75,8 @@ enum {
 #define MPTCP_PM_ADDR_FLAG_BACKUP			(1 << 2)
 #define MPTCP_PM_ADDR_FLAG_FULLMESH			(1 << 3)
 
+#define MPTCP_PM_ADDR_FLAG_MAX				(1 << 8)
+
 enum {
 	MPTCP_PM_CMD_UNSPEC,
 
ip/ipmptcp.c +0 -0
index 8c4fd18c..fc1fd5ce 100644

ip/ipmptcp.c static void usage(void) · line 22

Quoted 4 lines
ip/ipmptcp.c +1 -0
@@ -19,6 +19,7 @@ static void usage(void)
 		"Usage:	ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n"
 		"				      [ port NR ] [ FLAG-LIST ]\n"
 		"	ip mptcp endpoint delete id ID [ ADDRESS ]\n"
+		"	ip mptcp endpoint set ADDRESS [ backup | nobackup ]"

Like patch 1, please update the man page too.

ip/ipmptcp.c static const struct { · line 51

Quoted 8 lines
ip/ipmptcp.c +1 -0
 		"	ip mptcp endpoint show [ id ID ]\n"
 		"	ip mptcp endpoint flush\n"
 		"	ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
@@ -47,6 +48,7 @@ static const struct {
 	{ "signal",		MPTCP_PM_ADDR_FLAG_SIGNAL },
 	{ "subflow",		MPTCP_PM_ADDR_FLAG_SUBFLOW },
 	{ "backup",		MPTCP_PM_ADDR_FLAG_BACKUP },
+	{ "nobackup",		MPTCP_PM_ADDR_FLAG_MAX },

Since MPTCP_PM_ADDR_FLAG_MAX is 0x100, and the flags attribute in the netlink command is 32 bits wide, this ends up setting a bit and sending it to the kernel. While that bit isn't used right now, it could be in a future kernel version - and this approach to implementing 'nobackup' could have unexpected effects. Could you try a different way of implementing this that doesn't have a side effect?

- Mat

Quoted 72 lines
ip/ipmptcp.c +15 -5
 	{ "fullmesh",		MPTCP_PM_ADDR_FLAG_FULLMESH },
 };
 
@@ -91,17 +93,24 @@ static int get_flags(const char *arg, __u32 *flags)
 }
 
 static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
-			 bool adding)
+			 int cmd)
 {
 	struct rtattr *attr_addr;
 	bool addr_set = false;
 	inet_prefix address;
 	bool id_set = false;
+	bool adding = 0;
+	bool deling = 0;
 	__u32 index = 0;
 	__u32 flags = 0;
 	__u16 port = 0;
 	__u8 id = 0;
 
+	if (cmd == MPTCP_PM_CMD_ADD_ADDR)
+		adding = 1;
+	else if (cmd == MPTCP_PM_CMD_DEL_ADDR)
+		deling = 1;
+
 	ll_init_map(&rth);
 	while (argc > 0) {
 		if (get_flags(*argv, &flags) == 0) {
@@ -141,9 +150,9 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 	if (!addr_set && adding)
 		missarg("ADDRESS");
 
-	if (!id_set && !adding)
+	if (!id_set && deling)
 		missarg("ID");
-	else if (id_set && !adding) {
+	else if (id_set && deling) {
 		if (id && addr_set)
 			invarg("invalid for non-zero id address\n", "ADDRESS");
 		else if (!id && !addr_set)
@@ -183,7 +192,7 @@ static int mptcp_addr_modify(int argc, char **argv, int cmd)
 	MPTCP_REQUEST(req, cmd, NLM_F_REQUEST);
 	int ret;
 
-	ret = mptcp_parse_opt(argc, argv, &req.n, cmd == MPTCP_PM_CMD_ADD_ADDR);
+	ret = mptcp_parse_opt(argc, argv, &req.n, cmd);
 	if (ret)
 		return ret;
 
@@ -299,7 +308,7 @@ static int mptcp_addr_show(int argc, char **argv)
 	if (argc <= 0)
 		return mptcp_addr_dump();
 
-	ret = mptcp_parse_opt(argc, argv, &req.n, false);
+	ret = mptcp_parse_opt(argc, argv, &req.n, MPTCP_PM_CMD_DEL_ADDR);
 	if (ret)
 		return ret;
 
@@ -534,6 +543,9 @@ int do_mptcp(int argc, char **argv)
 		if (matches(*argv, "delete") == 0)
 			return mptcp_addr_modify(argc-1, argv+1,
 						 MPTCP_PM_CMD_DEL_ADDR);
+		if (matches(*argv, "set") == 0)
+			return mptcp_addr_modify(argc-1, argv+1,
+						 MPTCP_PM_CMD_SET_FLAGS);
 		if (matches(*argv, "show") == 0)
 			return mptcp_addr_show(argc-1, argv+1);
 		if (matches(*argv, "flush") == 0)
Signature · 1 line
2.31.1

--
Mat Martineau
Intel

#6 lore raw
In reply to Geliang Tang
Quoted 4 lines · Geliang Tang

This patched added id 0 address deleting, fullmesh flag and backup setting from pm_nl_ctl. With these patches, we can replace all pm_nl_ctl in the selftests with 'ip mptcp' command.

Quoted 11 lines

Geliang Tang (3):
mptcp: add id check for deleting address
mptcp: add the addr flag fullmesh
mptcp: add the backup flag setting

include/uapi/linux/mptcp.h | 2 ++
ip/ipmptcp.c | 31 +++++++++++++++++++++++++------

2 files changed, 27 insertions(+), 6 deletions(-)
Signature · 1 line
2.31.1

Hi Geliang -

I found that this doesn't apply to https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git, but it does apply to iproute2.git

If you check iproute2-next, there's already a patch in there from Paolo that adds the fullmesh flag.

Can you rebase the other two patches on iproute2-next for v2?

Thanks,

--
Mat Martineau
Intel

#7 lore raw

Hi Mat,

Thanks for your review.

Quoted 18 lines · Mat Martineau
Quoted 4 lines · Geliang Tang

This patched added id 0 address deleting, fullmesh flag and backup setting from pm_nl_ctl. With these patches, we can replace all pm_nl_ctl in the selftests with 'ip mptcp' command.

Quoted 11 lines

Geliang Tang (3):
mptcp: add id check for deleting address
mptcp: add the addr flag fullmesh
mptcp: add the backup flag setting

include/uapi/linux/mptcp.h | 2 ++
ip/ipmptcp.c | 31 +++++++++++++++++++++++++------

2 files changed, 27 insertions(+), 6 deletions(-)
Signature · 1 line
2.31.1
Quoted 8 lines

Hi Geliang -

I found that this doesn't apply to
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git, but it does apply to iproute2.git

If you check iproute2-next, there's already a patch in there from Paolo that adds the fullmesh flag.

Yes, v1 was against the wrong repo, not iproute2-next.git.

I just noticed there's already a patch in iproute2-next from Davide that adds the backup flag setting too:
"mptcp: add support for changing the backup flag"

So patch 2 and 3 in this series should be dropped.

Quoted 2 lines

Can you rebase the other two patches on iproute2-next for v2?

I only updated patch 1 for v2.

Thanks,
-Geliang

Quoted 9 lines

Thanks,

--
Mat Martineau
Intel