@@ -17,7 +17,7 @@ static void usage(void)
{
fprintf(stderr,
"Usage: ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n"
- " [ FLAG-LIST ]\n"
+ " [ port NR ] [ FLAG-LIST ]\n"
" ip mptcp endpoint delete id ID\n"
" ip mptcp endpoint show [ id ID ]\n"
" ip mptcp endpoint flush\n"
@@ -97,6 +97,7 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
bool id_set = false;
__u32 index = 0;
__u32 flags = 0;
+ __u16 port = 0;
__u8 id = 0;
ll_init_map(&rth);
@@ -123,6 +124,10 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
if (!index)
invarg("device does not exist\n", ifname);
+ } else if (matches(*argv, "port") == 0) {
+ NEXT_ARG();
+ if (get_u16(&port, *argv, 0))
+ invarg("expected port", *argv);
} else if (get_addr(&address, *argv, AF_UNSPEC) == 0) {
addr_set = true;
} else {
@@ -145,6 +150,8 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_FLAGS, flags);
if (index)
addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_IF_IDX, index);
+ if (port)
+ addattr16(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_PORT, port);
if (addr_set) {
int type;
@@ -181,8 +188,8 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
__u8 family = AF_UNSPEC, addr_attr_type;
const char *ifname;
unsigned int flags;
+ __u16 id, port;
int index;
- __u16 id;
parse_rtattr_nested(tb, MPTCP_PM_ADDR_ATTR_MAX, addrinfo);
@@ -196,6 +203,11 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
print_string(PRINT_ANY, "address", "%s ",
format_host_rta(family, tb[addr_attr_type]));
}
+ if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {
+ port = rta_getattr_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]);
+ if (port)
+ print_uint(PRINT_ANY, "port", "port %u ", port);
+ }
if (tb[MPTCP_PM_ADDR_ATTR_ID]) {
id = rta_getattr_u8(tb[MPTCP_PM_ADDR_ATTR_ID]);
print_uint(PRINT_ANY, "id", "id %u ", id);
@@ -20,6 +20,8 @@ ip-mptcp \- MPTCP path manager configuration
.ti -8
.BR "ip mptcp endpoint add "
.IR IFADDR
+.RB "[ " port
+.IR PORT " ]"
.RB "[ " dev
.IR IFNAME " ]"
.RB "[ " id
@@ -87,6 +89,12 @@ ip mptcp endpoint flush flush all existing MPTCP endpoints
.TE
.TP
+.IR PORT
+When a port number is specified, incoming MPTCP subflows for already
+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.
+
.IR ID
is a unique numeric identifier for the given endpoint
The feature is supported by the kernel since 5.11-net-next, let's allow user-space to use it. Just parse and dump an additional, per endpoint, u16 attribute Signed-off-by: Paolo Abeni <pabeni@redhat.com> --- ip/ipmptcp.c | 16 ++++++++++++++-- man/man8/ip-mptcp.8 | 8 ++++++++ 2 files changed, 22 insertions(+), 2 deletions(-)