mptcp: add id check for deleting address
PATCH v3 1/1 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 mptcp endpoint delete id 1 # ip mptcp endpoint delete id 0 10.0.1.1
---
v3:
- update ip-mptcp.8
v2:
- rebase for iproute2-next.git
- drop patch 2 & 3 in v1.
- change ip-mptcp.8 too.
--- ip/ipmptcp.c | 11 +++++++++-- man/man8/ip-mptcp.8 | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-)
ip/ipmptcp.c +9 -2
@@ -24,7 +24,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 change id ID [ backup | nobackup ]\n" " ip mptcp endpoint show [ id ID ]\n" " ip mptcp endpoint flush\n"
@@ -103,6 +103,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 adding = cmd ==MPTCP_PM_CMD_ADD_ADDR ; +bool deling = cmd ==MPTCP_PM_CMD_DEL_ADDR ;struct rtattr *attr_addr;bool addr_set = false;inet_prefix address;
@@ -156,8 +157,14 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, int cmd)if (!addr_set && adding)missarg ("ADDRESS" ); -if (!id_set && !adding) +if (!id_set && deling)missarg ("ID" ); +else if (id_set && deling) { +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" );
man/man8/ip-mptcp.8 +15 -1
@@ -31,8 +31,11 @@ ip-mptcp \- MPTCP path manager configuration .RB "] " .ti -8 -.BR "ip mptcp endpoint del id " +.BR "ip mptcp endpoint delete id " .I ID +.RB "[ " +.I IFADDR +.RB "] " .ti -8 .BR "ip mptcp endpoint change id "
@@ -107,6 +110,16 @@ ip mptcp endpoint show get existing MPTCP endpoint ip mptcp endpoint flush flush all existing MPTCP endpoints .TE +.TP +.IR IFADDR +An IPv4 or IPv6 address. When used with the +.B delete id +operation, an +.B IFADDR +is only included when the +.B ID +is 0. + .TP .IR PORT When a port number is specified, incoming MPTCP subflows for already
@@ -114,6 +127,7 @@ established MPTCP sockets will be accepted on the specified port, regardless the original listener port accepting the first MPTCP subflow and/or this peer being actually on the client side. +.TP .IR ID is a unique numeric identifier for the given endpoint
Signature · 1 line
2.31.1
Quoted 4 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.
Quoted 8 lines
# ip mptcp endpoint delete id 1 # ip mptcp endpoint delete id 0 10.0.1.1Signed-off-by Geliang Tang <[email protected]>---
v3:
- update ip-mptcp.8
Thanks for the manual page updates - looks good!
Quoted 85 lines
v2:
- rebase for iproute2-next.git
- drop patch 2 & 3 in v1.
- change ip-mptcp.8 too.
---ip/ipmptcp.c| 11 +++++++++--
man/man8/ip-mptcp.8 | 16 +++++++++++++++-2 files changed, 24 insertions(+), 3 deletions(-)ip/ipmptcp.c +9
-2@@ -24,7 +24,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 change id ID [ backup | nobackup ]\n" " ip mptcp endpoint show [ id ID ]\n" " ip mptcp endpoint flush\n"@@ -103,6 +103,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 adding = cmd ==MPTCP_PM_CMD_ADD_ADDR ; +bool deling = cmd ==MPTCP_PM_CMD_DEL_ADDR ;struct rtattr *attr_addr;bool addr_set = false;inet_prefix address;@@ -156,8 +157,14 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, int cmd)if (!addr_set && adding)missarg ("ADDRESS" ); -if (!id_set && !adding) +if (!id_set && deling)missarg ("ID" ); +else if (id_set && deling) { +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" );man/man8/ip-mptcp.8 +0
-0@@ -31,8 +31,11 @@ ip-mptcp \- MPTCP path manager configuration.RB "] "
.ti -8
-.BR "ip mptcp endpoint del id "
+.BR "ip mptcp endpoint delete id "
.I ID
+.RB "[ "
+.I IFADDR
+.RB "] ".ti -8
.BR "ip mptcp endpoint change id "man/man8/ip-mptcp.8 +0
-0@@ -107,6 +110,16 @@ ip mptcp endpoint show get existing MPTCP endpointip mptcp endpoint flush flush all existing MPTCP endpoints
.TE+.TP
+.IR IFADDRman/man8/ip-mptcp.8 +8
-0+An IPv4 or IPv6 address. When used with the +.B delete id +operation, an +.B IFADDR +is only included when the +.B ID +is 0. +.TP
.IR PORT
When a port number is specified, incoming MPTCP subflows for alreadyman/man8/ip-mptcp.8 +0
-0@@ -114,6 +127,7 @@ established MPTCP sockets will be accepted on the specified port, regardlessthe original listener port accepting the first MPTCP subflow and/or this peer being actually on the client side.
Quoted 9 lines
+.TP
.IR ID
is a unique numeric identifier for the given endpointSignature · 1 line
2.31.1
--
Mat Martineau
Intel