All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] mptcp: add the fullmesh flag setting support
@ 2022-02-04  3:29 Geliang Tang
  2022-02-04 18:17 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Geliang Tang @ 2022-02-04  3:29 UTC (permalink / raw)
  To: Stephen Hemminger, David Ahern, netdev
  Cc: Geliang Tang, mptcp, Paolo Abeni, Mat Martineau

This patch added the fullmesh flag setting support, use it like this:

 ip mptcp endpoint change id 1 fullmesh
 ip mptcp endpoint change id 1 nofullmesh
 ip mptcp endpoint change id 1 backup fullmesh
 ip mptcp endpoint change id 1 nobackup nofullmesh

Add the fullmesh flag check for the adding address, the fullmesh flag
can't be used with the signal flag in that case.

Update the port keyword check for the setting flags, allow to use the
port keyword with the non-signal flags. Don't allow to use the port
keyword with the id number.

Update the usage of 'ip mptcp endpoint change', it can be used in two
forms, using the address directly or the id number of the address:

 ip mptcp endpoint change id 1 fullmesh
 ip mptcp endpoint change 10.0.2.1 fullmesh
 ip mptcp endpoint change 10.0.2.1 port 10100 fullmesh

Acked-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 ip/ipmptcp.c        | 26 +++++++++++++++++++-------
 man/man8/ip-mptcp.8 | 17 ++++++++++++-----
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
index eef7c6f4..efda7ef2 100644
--- a/ip/ipmptcp.c
+++ b/ip/ipmptcp.c
@@ -25,14 +25,15 @@ 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 change id ID [ backup | nobackup ]\n"
+		"	ip mptcp endpoint change [ id ID ] [ ADDRESS ] CHANGE-OPT\n"
 		"	ip mptcp endpoint show [ id ID ]\n"
 		"	ip mptcp endpoint flush\n"
 		"	ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
 		"	ip mptcp limits show\n"
 		"	ip mptcp monitor\n"
 		"FLAG-LIST := [ FLAG-LIST ] FLAG\n"
-		"FLAG  := [ signal | subflow | backup | fullmesh ]\n");
+		"FLAG  := [ signal | subflow | backup | fullmesh ]\n"
+		"CHANGE-OPT := [ backup | nobackup | fullmesh | nofullmesh ]\n");
 
 	exit(-1);
 }
@@ -46,7 +47,7 @@ static int genl_family = -1;
 	GENL_REQUEST(_req, MPTCP_BUFLEN, genl_family, 0,	\
 		     MPTCP_PM_VER, _cmd, _flags)
 
-#define MPTCP_PM_ADDR_FLAG_NOBACKUP 0x0
+#define MPTCP_PM_ADDR_FLAG_NONE 0x0
 
 /* Mapping from argument to address flag mask */
 static const struct {
@@ -57,7 +58,8 @@ static const struct {
 	{ "subflow",		MPTCP_PM_ADDR_FLAG_SUBFLOW },
 	{ "backup",		MPTCP_PM_ADDR_FLAG_BACKUP },
 	{ "fullmesh",		MPTCP_PM_ADDR_FLAG_FULLMESH },
-	{ "nobackup",		MPTCP_PM_ADDR_FLAG_NOBACKUP }
+	{ "nobackup",		MPTCP_PM_ADDR_FLAG_NONE },
+	{ "nofullmesh",		MPTCP_PM_ADDR_FLAG_NONE }
 };
 
 static void print_mptcp_addr_flags(unsigned int flags)
@@ -102,6 +104,7 @@ static int get_flags(const char *arg, __u32 *flags)
 
 static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, int cmd)
 {
+	bool setting = cmd == MPTCP_PM_CMD_SET_FLAGS;
 	bool adding = cmd == MPTCP_PM_CMD_ADD_ADDR;
 	bool deling = cmd == MPTCP_PM_CMD_DEL_ADDR;
 	struct rtattr *attr_addr;
@@ -116,9 +119,15 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, int cmd)
 	ll_init_map(&rth);
 	while (argc > 0) {
 		if (get_flags(*argv, &flags) == 0) {
-			/* allow changing the 'backup' flag only */
+			if (adding &&
+			    (flags & MPTCP_PM_ADDR_FLAG_SIGNAL) &&
+			    (flags & MPTCP_PM_ADDR_FLAG_FULLMESH))
+				invarg("invalid flags\n", *argv);
+
+			/* allow changing the 'backup' and 'fullmesh' flags only */
 			if (cmd == MPTCP_PM_CMD_SET_FLAGS &&
-			    (flags & ~MPTCP_PM_ADDR_FLAG_BACKUP))
+			    (flags & ~(MPTCP_PM_ADDR_FLAG_BACKUP |
+				       MPTCP_PM_ADDR_FLAG_FULLMESH)))
 				invarg("invalid flags\n", *argv);
 
 		} else if (matches(*argv, "id") == 0) {
@@ -166,9 +175,12 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, int cmd)
 			invarg("address is needed for deleting id 0 address\n", "ID");
 	}
 
-	if (port && !(flags & MPTCP_PM_ADDR_FLAG_SIGNAL))
+	if (adding && port && !(flags & MPTCP_PM_ADDR_FLAG_SIGNAL))
 		invarg("flags must have signal when using port", "port");
 
+	if (id_set && setting && port)
+		invarg("port can't be used with id", "port");
+
 	attr_addr = addattr_nest(n, MPTCP_BUFLEN,
 				 MPTCP_PM_ATTR_ADDR | NLA_F_NESTED);
 	if (id_set)
diff --git a/man/man8/ip-mptcp.8 b/man/man8/ip-mptcp.8
index 0e789225..72762f49 100644
--- a/man/man8/ip-mptcp.8
+++ b/man/man8/ip-mptcp.8
@@ -38,11 +38,14 @@ ip-mptcp \- MPTCP path manager configuration
 .RB "] "
 
 .ti -8
-.BR "ip mptcp endpoint change id "
+.BR "ip mptcp endpoint change "
+.RB "[ " id
 .I ID
-.RB "[ "
-.I BACKUP-OPT
-.RB "] "
+.RB "] [ "
+.IR IFADDR
+.RB "] [ " port
+.IR PORT " ]"
+.RB "CHANGE-OPT"
 
 .ti -8
 .BR "ip mptcp endpoint show "
@@ -68,10 +71,14 @@ ip-mptcp \- MPTCP path manager configuration
 .RB  "]"
 
 .ti -8
-.IR BACKUP-OPT " := ["
+.IR CHANGE-OPT " := ["
 .B backup
 .RB "|"
 .B nobackup
+.RB "|"
+.B fullmesh
+.RB "|"
+.B nofullmesh
 .RB  "]"
 
 .ti -8
-- 
2.31.1


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

* Re: [PATCH iproute2-next] mptcp: add the fullmesh flag setting support
  2022-02-04  3:29 [PATCH iproute2-next] mptcp: add the fullmesh flag setting support Geliang Tang
@ 2022-02-04 18:17 ` Stephen Hemminger
  2022-02-07  3:01   ` Geliang Tang
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2022-02-04 18:17 UTC (permalink / raw)
  To: Geliang Tang; +Cc: David Ahern, netdev, mptcp, Paolo Abeni, Mat Martineau

On Fri,  4 Feb 2022 11:29:03 +0800
Geliang Tang <geliang.tang@suse.com> wrote:

> This patch added the fullmesh flag setting support, use it like this:
> 
>  ip mptcp endpoint change id 1 fullmesh
>  ip mptcp endpoint change id 1 nofullmesh
>  ip mptcp endpoint change id 1 backup fullmesh
>  ip mptcp endpoint change id 1 nobackup nofullmesh
> 
> Add the fullmesh flag check for the adding address, the fullmesh flag
> can't be used with the signal flag in that case.
> 
> Update the port keyword check for the setting flags, allow to use the
> port keyword with the non-signal flags. Don't allow to use the port
> keyword with the id number.
> 
> Update the usage of 'ip mptcp endpoint change', it can be used in two
> forms, using the address directly or the id number of the address:
> 
>  ip mptcp endpoint change id 1 fullmesh
>  ip mptcp endpoint change 10.0.2.1 fullmesh
>  ip mptcp endpoint change 10.0.2.1 port 10100 fullmesh
> 
> Acked-by: Paolo Abeni <pabeni@redhat.com>
> Acked-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>

I don't see  any parts in here to show the flag settings?

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

* Re: [PATCH iproute2-next] mptcp: add the fullmesh flag setting support
  2022-02-04 18:17 ` Stephen Hemminger
@ 2022-02-07  3:01   ` Geliang Tang
  0 siblings, 0 replies; 4+ messages in thread
From: Geliang Tang @ 2022-02-07  3:01 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Ahern, netdev, mptcp, Paolo Abeni, Mat Martineau

On Fri, Feb 04, 2022 at 10:17:34AM -0800, Stephen Hemminger wrote:
> On Fri,  4 Feb 2022 11:29:03 +0800
> Geliang Tang <geliang.tang@suse.com> wrote:
> 
> > This patch added the fullmesh flag setting support, use it like this:
> > 
> >  ip mptcp endpoint change id 1 fullmesh
> >  ip mptcp endpoint change id 1 nofullmesh
> >  ip mptcp endpoint change id 1 backup fullmesh
> >  ip mptcp endpoint change id 1 nobackup nofullmesh
> > 
> > Add the fullmesh flag check for the adding address, the fullmesh flag
> > can't be used with the signal flag in that case.
> > 
> > Update the port keyword check for the setting flags, allow to use the
> > port keyword with the non-signal flags. Don't allow to use the port
> > keyword with the id number.
> > 
> > Update the usage of 'ip mptcp endpoint change', it can be used in two
> > forms, using the address directly or the id number of the address:
> > 
> >  ip mptcp endpoint change id 1 fullmesh
> >  ip mptcp endpoint change 10.0.2.1 fullmesh
> >  ip mptcp endpoint change 10.0.2.1 port 10100 fullmesh
> > 
> > Acked-by: Paolo Abeni <pabeni@redhat.com>
> > Acked-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> > Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> 
> I don't see  any parts in here to show the flag settings?
> 

Hi Stephen,

Thanks for your review.

We use the 'ip mptcp endpoint change flags' command to set the flags of the
given address. It's a little strange because we use 'set flags' in the
kernel space (like MPTCP_PM_CMD_SET_FLAGS, mptcp_nl_cmd_set_flags), but
'change flags' in the user space.

Before applying this patch, we can only set the backup flag:

> sudo ip mptcp endpoint add 10.0.2.1 subflow
> sudo ip mptcp endpoint show
10.0.2.1 id 1 subflow
> sudo ip mptcp endpoint change id 1 backup
> sudo ip mptcp endpoint show
10.0.2.1 id 1 subflow backup 
> sudo ip mptcp endpoint change id 1 nobackup
> sudo ip mptcp endpoint show
10.0.2.1 id 1 subflow

The commit 73c762c1f07d ("mptcp: set fullmesh flag in pm_netlink") is
merged to net-next recently. It added the fullmesh flag setting in the
kernel space.

We need to let the fullmesh flag not be blocked in the user space. So this
patch added this code:

 +                       /* allow changing the 'backup' and 'fullmesh' flags only */
                         if (cmd == MPTCP_PM_CMD_SET_FLAGS &&
 -                           (flags & ~MPTCP_PM_ADDR_FLAG_BACKUP))
 +                           (flags & ~(MPTCP_PM_ADDR_FLAG_BACKUP |
 +                                      MPTCP_PM_ADDR_FLAG_FULLMESH)))
                                 invarg("invalid flags\n", *argv);

Now we can set the fullmesh flag like this:

> sudo ip mptcp endpoint flush
> sudo ip mptcp endpoint add 10.0.2.1 subflow
> sudo ip mptcp endpoint show
10.0.2.1 id 1 subflow 
> sudo ip mptcp endpoint change id 1 fullmesh
> sudo ip mptcp endpoint show
10.0.2.1 id 1 subflow fullmesh 
> sudo ip mptcp endpoint change id 1 nofullmesh
> sudo ip mptcp endpoint show
10.0.2.1 id 1 subflow 

This patch also added the related flags checks and updated the usage.

Thanks,

Geliang
SUSE


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

* [PATCH iproute2-next] mptcp: add the fullmesh flag setting support
@ 2022-01-11  4:21 Geliang Tang
  0 siblings, 0 replies; 4+ messages in thread
From: Geliang Tang @ 2022-01-11  4:21 UTC (permalink / raw)
  To: mptcp; +Cc: Geliang Tang

This patch added the fullmesh flag setting support.

 ip mptcp endpoint change id 1 fullmesh
 ip mptcp endpoint change id 1 nofullmesh

Needs to apply the patch "mptcp: add id check for deleting address"
first.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 include/uapi/linux/mptcp.h |  1 +
 ip/ipmptcp.c               | 10 +++++++---
 man/man8/ip-mptcp.8        |  8 ++++++--
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h
index cefa9a91..38e8c832 100644
--- a/include/uapi/linux/mptcp.h
+++ b/include/uapi/linux/mptcp.h
@@ -79,6 +79,7 @@ enum {
 #define MPTCP_PM_ADDR_FLAG_SUBFLOW			(1 << 1)
 #define MPTCP_PM_ADDR_FLAG_BACKUP			(1 << 2)
 #define MPTCP_PM_ADDR_FLAG_FULLMESH			(1 << 3)
+#define MPTCP_PM_ADDR_FLAG_NOFULLMESH			(1 << 4)
 
 enum {
 	MPTCP_PM_CMD_UNSPEC,
diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
index f85c49a8..ee786537 100644
--- a/ip/ipmptcp.c
+++ b/ip/ipmptcp.c
@@ -25,7 +25,8 @@ 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 change id ID [ backup | nobackup ]\n"
+		"	ip mptcp endpoint change id ID [ backup | nobackup |\n"
+		"					 fullmesh | nofullmesh ]\n"
 		"	ip mptcp endpoint show [ id ID ]\n"
 		"	ip mptcp endpoint flush\n"
 		"	ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
@@ -57,7 +58,8 @@ static const struct {
 	{ "subflow",		MPTCP_PM_ADDR_FLAG_SUBFLOW },
 	{ "backup",		MPTCP_PM_ADDR_FLAG_BACKUP },
 	{ "fullmesh",		MPTCP_PM_ADDR_FLAG_FULLMESH },
-	{ "nobackup",		MPTCP_PM_ADDR_FLAG_NOBACKUP }
+	{ "nobackup",		MPTCP_PM_ADDR_FLAG_NOBACKUP },
+	{ "nofullmesh",		MPTCP_PM_ADDR_FLAG_NOFULLMESH }
 };
 
 static void print_mptcp_addr_flags(unsigned int flags)
@@ -118,7 +120,9 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, int cmd)
 		if (get_flags(*argv, &flags) == 0) {
 			/* allow changing the 'backup' flag only */
 			if (cmd == MPTCP_PM_CMD_SET_FLAGS &&
-			    (flags & ~MPTCP_PM_ADDR_FLAG_BACKUP))
+			    (flags & ~MPTCP_PM_ADDR_FLAG_BACKUP) &&
+			    (flags & ~MPTCP_PM_ADDR_FLAG_FULLMESH) &&
+			    (flags & ~MPTCP_PM_ADDR_FLAG_NOFULLMESH))
 				invarg("invalid flags\n", *argv);
 
 		} else if (matches(*argv, "id") == 0) {
diff --git a/man/man8/ip-mptcp.8 b/man/man8/ip-mptcp.8
index 0e789225..bddbff3c 100644
--- a/man/man8/ip-mptcp.8
+++ b/man/man8/ip-mptcp.8
@@ -41,7 +41,7 @@ ip-mptcp \- MPTCP path manager configuration
 .BR "ip mptcp endpoint change id "
 .I ID
 .RB "[ "
-.I BACKUP-OPT
+.I CHANGE-OPT
 .RB "] "
 
 .ti -8
@@ -68,10 +68,14 @@ ip-mptcp \- MPTCP path manager configuration
 .RB  "]"
 
 .ti -8
-.IR BACKUP-OPT " := ["
+.IR CHANGE-OPT " := ["
 .B backup
 .RB "|"
 .B nobackup
+.RB "|"
+.B fullmesh
+.RB "|"
+.B nofullmesh
 .RB  "]"
 
 .ti -8
-- 
2.31.1


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

end of thread, other threads:[~2022-02-07  3:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04  3:29 [PATCH iproute2-next] mptcp: add the fullmesh flag setting support Geliang Tang
2022-02-04 18:17 ` Stephen Hemminger
2022-02-07  3:01   ` Geliang Tang
  -- strict thread matches above, loose matches on Subject: below --
2022-01-11  4:21 Geliang Tang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.