@@ -25,6 +25,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\n"
+ " ip mptcp endpoint change id ID [ backup | nobackup ]\n"
" ip mptcp endpoint show [ id ID ]\n"
" ip mptcp endpoint flush\n"
" ip mptcp limits set [ subflows NR ] [ add_addr_accepted NR ]\n"
@@ -45,6 +46,8 @@ 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
+
/* Mapping from argument to address flag mask */
static const struct {
const char *name;
@@ -54,6 +57,7 @@ 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 }
};
static void print_mptcp_addr_flags(unsigned int flags)
@@ -96,9 +100,9 @@ static int get_flags(const char *arg, __u32 *flags)
return -1;
}
-static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
- bool adding)
+static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n, int cmd)
{
+ bool adding = cmd == MPTCP_PM_CMD_ADD_ADDR;
struct rtattr *attr_addr;
bool addr_set = false;
inet_prefix address;
@@ -111,6 +115,11 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
ll_init_map(&rth);
while (argc > 0) {
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))
+ invarg("invalid flags\n", *argv);
+
} else if (matches(*argv, "id") == 0) {
NEXT_ARG();
@@ -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_GET_ADDR);
if (ret)
return ret;
@@ -531,6 +540,9 @@ int do_mptcp(int argc, char **argv)
if (matches(*argv, "add") == 0)
return mptcp_addr_modify(argc-1, argv+1,
MPTCP_PM_CMD_ADD_ADDR);
+ if (matches(*argv, "change") == 0)
+ return mptcp_addr_modify(argc-1, argv+1,
+ MPTCP_PM_CMD_SET_FLAGS);
if (matches(*argv, "delete") == 0)
return mptcp_addr_modify(argc-1, argv+1,
MPTCP_PM_CMD_DEL_ADDR);
@@ -34,6 +34,13 @@ ip-mptcp \- MPTCP path manager configuration
.BR "ip mptcp endpoint del id "
.I ID
+.ti -8
+.BR "ip mptcp endpoint change id "
+.I ID
+.RB "[ "
+.I BACKUP-OPT
+.RB "] "
+
.ti -8
.BR "ip mptcp endpoint show "
.RB "[ " id
@@ -57,6 +64,13 @@ ip-mptcp \- MPTCP path manager configuration
.B fullmesh
.RB "]"
+.ti -8
+.IR BACKUP-OPT " := ["
+.B backup
+.RB "|"
+.B nobackup
+.RB "]"
+
.ti -8
.BR "ip mptcp limits set "
.RB "[ "