[PATCH iproute2-next] mptcp: add id check for deleting address

Geliang Tang posted 1 patch 3 weeks, 4 days ago
Failed in applying to current master (apply log)
ip/ipmptcp.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

[PATCH iproute2-next] mptcp: add id check for deleting address

Posted by Geliang Tang 3 weeks, 4 days 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