Blame SOURCES/0003-mptcp-add-support-for-port-based-endpoint.patch

74a1de
From 0ccd2dbb3eca44a892a183db8c2e4221488ecf51 Mon Sep 17 00:00:00 2001
74a1de
Message-Id: <0ccd2dbb3eca44a892a183db8c2e4221488ecf51.1628790091.git.aclaudi@redhat.com>
74a1de
In-Reply-To: <650694eb0120722499207078f965442ef7343bb1.1628790091.git.aclaudi@redhat.com>
74a1de
References: <650694eb0120722499207078f965442ef7343bb1.1628790091.git.aclaudi@redhat.com>
74a1de
From: Andrea Claudi <aclaudi@redhat.com>
74a1de
Date: Mon, 9 Aug 2021 15:18:11 +0200
74a1de
Subject: [PATCH] mptcp: add support for port based endpoint
74a1de
74a1de
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1984733
74a1de
Upstream Status: iproute2.git commit 42fbca91
74a1de
74a1de
commit 42fbca91cd616ae714c3f6aa2d4e2c3399498e38
74a1de
Author: Paolo Abeni <pabeni@redhat.com>
74a1de
Date:   Fri Feb 19 21:42:55 2021 +0100
74a1de
74a1de
    mptcp: add support for port based endpoint
74a1de
74a1de
    The feature is supported by the kernel since 5.11-net-next,
74a1de
    let's allow user-space to use it.
74a1de
74a1de
    Just parse and dump an additional, per endpoint, u16 attribute
74a1de
74a1de
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
74a1de
    Signed-off-by: David Ahern <dsahern@kernel.org>
74a1de
74a1de
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
74a1de
---
74a1de
 ip/ipmptcp.c        | 16 ++++++++++++++--
74a1de
 man/man8/ip-mptcp.8 |  8 ++++++++
74a1de
 2 files changed, 22 insertions(+), 2 deletions(-)
74a1de
74a1de
diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
74a1de
index e1ffafb3..5f659b59 100644
74a1de
--- a/ip/ipmptcp.c
74a1de
+++ b/ip/ipmptcp.c
74a1de
@@ -17,7 +17,7 @@ static void usage(void)
74a1de
 {
74a1de
 	fprintf(stderr,
74a1de
 		"Usage:	ip mptcp endpoint add ADDRESS [ dev NAME ] [ id ID ]\n"
74a1de
-		"				      [ FLAG-LIST ]\n"
74a1de
+		"				      [ port NR ] [ FLAG-LIST ]\n"
74a1de
 		"	ip mptcp endpoint delete id ID\n"
74a1de
 		"	ip mptcp endpoint show [ id ID ]\n"
74a1de
 		"	ip mptcp endpoint flush\n"
74a1de
@@ -97,6 +97,7 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
74a1de
 	bool id_set = false;
74a1de
 	__u32 index = 0;
74a1de
 	__u32 flags = 0;
74a1de
+	__u16 port = 0;
74a1de
 	__u8 id = 0;
74a1de
 
74a1de
 	ll_init_map(&rth);
74a1de
@@ -123,6 +124,10 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
74a1de
 			if (!index)
74a1de
 				invarg("device does not exist\n", ifname);
74a1de
 
74a1de
+		} else if (matches(*argv, "port") == 0) {
74a1de
+			NEXT_ARG();
74a1de
+			if (get_u16(&port, *argv, 0))
74a1de
+				invarg("expected port", *argv);
74a1de
 		} else if (get_addr(&address, *argv, AF_UNSPEC) == 0) {
74a1de
 			addr_set = true;
74a1de
 		} else {
74a1de
@@ -145,6 +150,8 @@ static int mptcp_parse_opt(int argc, char **argv, struct nlmsghdr *n,
74a1de
 		addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_FLAGS, flags);
74a1de
 	if (index)
74a1de
 		addattr32(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_IF_IDX, index);
74a1de
+	if (port)
74a1de
+		addattr16(n, MPTCP_BUFLEN, MPTCP_PM_ADDR_ATTR_PORT, port);
74a1de
 	if (addr_set) {
74a1de
 		int type;
74a1de
 
74a1de
@@ -181,8 +188,8 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
74a1de
 	__u8 family = AF_UNSPEC, addr_attr_type;
74a1de
 	const char *ifname;
74a1de
 	unsigned int flags;
74a1de
+	__u16 id, port;
74a1de
 	int index;
74a1de
-	__u16 id;
74a1de
 
74a1de
 	parse_rtattr_nested(tb, MPTCP_PM_ADDR_ATTR_MAX, addrinfo);
74a1de
 
74a1de
@@ -196,6 +203,11 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
74a1de
 		print_string(PRINT_ANY, "address", "%s ",
74a1de
 			     format_host_rta(family, tb[addr_attr_type]));
74a1de
 	}
74a1de
+	if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {
74a1de
+		port = rta_getattr_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]);
74a1de
+		if (port)
74a1de
+			print_uint(PRINT_ANY, "port", "port %u ", port);
74a1de
+	}
74a1de
 	if (tb[MPTCP_PM_ADDR_ATTR_ID]) {
74a1de
 		id = rta_getattr_u8(tb[MPTCP_PM_ADDR_ATTR_ID]);
74a1de
 		print_uint(PRINT_ANY, "id", "id %u ", id);
74a1de
diff --git a/man/man8/ip-mptcp.8 b/man/man8/ip-mptcp.8
74a1de
index ef8409ea..98cb93b9 100644
74a1de
--- a/man/man8/ip-mptcp.8
74a1de
+++ b/man/man8/ip-mptcp.8
74a1de
@@ -20,6 +20,8 @@ ip-mptcp \- MPTCP path manager configuration
74a1de
 .ti -8
74a1de
 .BR "ip mptcp endpoint add "
74a1de
 .IR IFADDR
74a1de
+.RB "[ " port
74a1de
+.IR PORT " ]"
74a1de
 .RB "[ " dev
74a1de
 .IR IFNAME " ]"
74a1de
 .RB "[ " id
74a1de
@@ -87,6 +89,12 @@ ip mptcp endpoint flush	flush all existing MPTCP endpoints
74a1de
 .TE
74a1de
 
74a1de
 .TP
74a1de
+.IR PORT
74a1de
+When a port number is specified, incoming MPTCP subflows for already
74a1de
+established MPTCP sockets will be accepted on the specified port, regardless
74a1de
+the original listener port accepting the first MPTCP subflow and/or
74a1de
+this peer being actually on the client side.
74a1de
+
74a1de
 .IR ID
74a1de
 is a unique numeric identifier for the given endpoint
74a1de
 
74a1de
-- 
74a1de
2.31.1
74a1de