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

Geliang Tang posted 3 patches 4 years, 1 month ago
[PATCH RESEND iproute2-next 1/3] mptcp: add id check for deleting address
Posted by Geliang Tang 4 years, 1 month ago
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.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/171
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 ip/ipmptcp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
index fd042da8..c2691ef4 100644
--- a/ip/ipmptcp.c
+++ b/ip/ipmptcp.c
@@ -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");
-- 
2.31.1


Re: [PATCH RESEND iproute2-next 1/3] mptcp: add id check for deleting address
Posted by Mat Martineau 4 years, 1 month ago
On Tue, 4 Jan 2022, Geliang Tang wrote:

> 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.
>
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/171
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
> ip/ipmptcp.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
> index fd042da8..c2691ef4 100644
> --- a/ip/ipmptcp.c
> +++ b/ip/ipmptcp.c
> @@ -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 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.

> +		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");
> -- 
> 2.31.1


--
Mat Martineau
Intel