Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new upstream kernel PM commands. #199

Merged
merged 75 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
e8c69d8
include: Add remaining user space PM commands.
ossama-othman Jan 14, 2022
a93fd4e
src: Conform to existing naming convention.
ossama-othman Jan 14, 2022
2e3fe86
src: Organize kernel/user space PM code.
ossama-othman Jan 14, 2022
7006b41
src: Add support for MPTCP_PM_CMD_ANNOUNCE.
ossama-othman Jan 14, 2022
2983e45
src: Add support for MPTCP_PM_CMD_REMOVE.
ossama-othman Jan 14, 2022
026c1ae
src: Add support for MPTCP_PM_CMD_SUBFLOW_CREATE.
ossama-othman Jan 15, 2022
d7629c7
src: Add support for MPTCP_PM_CMD_SUBFLOW_DESTROY.
ossama-othman Jan 15, 2022
eb9018b
src: Remove unused private fields.
ossama-othman Jan 15, 2022
f86445e
src: Correct code indentation.
ossama-othman Jan 15, 2022
9fe1a35
src: Correct comments.
ossama-othman Jan 15, 2022
2abcd4f
include: Update to latest <linux/mptcp.h>.
ossama-othman May 12, 2022
50543d7
src: Reorder include directives to avoid conflict.
ossama-othman May 13, 2022
1b3f097
src: Display support kernel in "--help" output.
ossama-othman May 13, 2022
c139636
src: Fix build regression caused by rebase.
ossama-othman Jun 15, 2022
b47c81f
src: Add a MPTCP listener manager.
ossama-othman Jun 16, 2022
d45500a
src: Create/destroy mptcpd listener manager.
ossama-othman Jun 16, 2022
6273bbc
src: Create MPTCP listening sockets as needed.
ossama-othman Jun 16, 2022
769b0bc
tests: Add mptcpd listener manager unit test.
ossama-othman Jun 16, 2022
14f9e58
tests: Clarify why the loopback address is used.
ossama-othman Jun 16, 2022
a7c97de
include: Update mptcpd copies of <linux/mptcp.h>.
ossama-othman Jun 17, 2022
40cb8a5
m4: Update upstream <linux/mptcp.h> detection.
ossama-othman Jul 8, 2022
cfa291f
src: Parse MPTCP_ATTR_SERVER_SIDE event attribute.
ossama-othman Jul 8, 2022
81b615d
plugin: Propagate server_side attribute to plugins
ossama-othman Jul 8, 2022
38dce3a
plugins: Update connection operations signatures.
ossama-othman Jul 8, 2022
a878e0b
tests: Update test plugin infrastructure.
ossama-othman Jul 8, 2022
587581f
tests: Clarify plugin call relationship.
ossama-othman Jul 8, 2022
2c79001
listener_manager: Correct file descriptor cast.
ossama-othman Jul 8, 2022
4b0af5b
tests: Fix clang build regression.
ossama-othman Jul 8, 2022
4e477ae
lib: Refactor sockaddr hash code.
ossama-othman Jul 12, 2022
671ad53
tests: Add invalid MPTCP address ID test case.
ossama-othman Jul 13, 2022
16e6f1c
lib: Export the mptcpd listener manager API.
ossama-othman Jul 13, 2022
7154fb8
listener_manager: Map sockaddr to file descriptor.
ossama-othman Jul 14, 2022
6f2121f
Add sockaddr parameter to mptcpd_pm_remove_addr().
ossama-othman Jul 14, 2022
af5eee0
tests: Use new API in test-listener-manager.
ossama-othman Jul 14, 2022
8e8fcca
hash_sockaddr: Add todo comment about port hash.
ossama-othman Jul 14, 2022
f62e212
id_manager: Fix potential NULL dereference.
ossama-othman Jul 14, 2022
72a25af
src: Add missing addr param for mptcp.org impl.
ossama-othman Jul 14, 2022
7dbc71c
hash_sockaddr: Include IP port as part of the key.
ossama-othman Jul 17, 2022
b667955
hash_sockaddr: Simplify padding initialization.
ossama-othman Jul 17, 2022
4827421
hash_sockaddr: Include port in key comparison.
ossama-othman Jul 18, 2022
7d0d315
tests: Expand mptcpd_lm test cases.
ossama-othman Jul 18, 2022
89ae85c
tests: Fix spelling typo.
ossama-othman Jul 18, 2022
ba87b88
test-id-manager: Add different port test case.
ossama-othman Jul 19, 2022
dbd8dbd
lib: Refactor sockaddr hashing to IDM and LM.
ossama-othman Jul 19, 2022
9a0cf49
listener_manager: Make factory functions private.
ossama-othman Jul 22, 2022
2a5ace1
path_manager: Add mptcpd_pm_get_lm() accessor.
ossama-othman Jul 22, 2022
b40f91f
tests: Expand internal mptcpd_pm state checks.
ossama-othman Jul 22, 2022
0208b79
include: Clarify the role of the listener manager.
ossama-othman Jul 22, 2022
56d2922
include: Clarify 'server_side' plugin ops param.
ossama-othman Jul 22, 2022
96712be
lib: Remove unused Makefile variable assignment.
ossama-othman Jul 25, 2022
f5eb494
hash_sockaddr: Remove extra line.
ossama-othman Jul 26, 2022
f915775
listener_manager: Track ephemeral ports.
ossama-othman Jul 26, 2022
8022d4c
listener_manager: Reject unbound IP addresses.
ossama-othman Jul 26, 2022
9b82aff
test-listener-manager: Add bad address test cases.
ossama-othman Jul 26, 2022
f2b15a2
lib: Move IPPROTO_MPTCP def to global scope.
ossama-othman Jul 26, 2022
daa13d4
src: Improve genl command error logging.
ossama-othman Jul 26, 2022
47bafca
listener_manager: Update port in sockaddr arg.
ossama-othman Aug 3, 2022
eabb923
Use non-const sockaddr arg in mptcpd_pm_add_addr()
ossama-othman Aug 3, 2022
ffcb668
Add mptcpd_sockaddr_copy() utility function.
ossama-othman Aug 4, 2022
0d3194e
sspi: Pass non-const addr to mptcpd_pm_add_addr().
ossama-othman Aug 4, 2022
0690d9f
Make hexadecimal capitalization consistent.
ossama-othman Aug 4, 2022
a99543f
listener_manager: Forward declare struct sockaddr.
ossama-othman Aug 4, 2022
0d4210c
listener_manager: Add missing <stdbool.h> include.
ossama-othman Aug 4, 2022
8b9cc84
listener_manager: Disambiguate filename in docs.
ossama-othman Aug 4, 2022
73facae
tests: Overhaul test-commands unit test.
ossama-othman Aug 5, 2022
cc7021e
Merge branch 'master' into upstream-pm-cmds
ossama-othman Aug 5, 2022
087cb4a
netlink_pm_upstream: Clarify TODO comment.
ossama-othman Aug 5, 2022
dc40045
test-commands: Split kernel and user space cases.
ossama-othman Aug 5, 2022
e80db71
listener_manager: Return 0 or errno, not bool.
ossama-othman Aug 5, 2022
3e94d23
Return listen error to mptcpd_pm_add_addr() caller
ossama-othman Aug 5, 2022
a7a9b90
include: Clarify return values.
ossama-othman Aug 5, 2022
3d64db8
tests: Add listener manager negative test cases.
ossama-othman Aug 5, 2022
c1883e4
test-commands: Ignore EADDRNOTAVAIL error.
ossama-othman Aug 5, 2022
bde4681
tests: Remove unnecessary <ell/hashmap.h> include.
ossama-othman Aug 5, 2022
9fed337
tests: Fix compatibility with ELL 0.45 and later.
ossama-othman Aug 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ tests/test-commands
tests/test-configuration
tests/test-cxx-build
tests/test-id-manager
tests/test-listener-manager
tests/test-sockaddr
tests/test-addr-info
tests/test-murmur-hash
Expand Down
18 changes: 10 additions & 8 deletions include/linux/mptcp_org.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ enum {
* - MPTCP_EVENT_REMOVED: token, rem_id
* An address has been lost by the peer.
*
* - MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup,
* if_idx [, error]
* - MPTCP_EVENT_SUB_ESTABLISHED: token, family, loc_id, rem_id,
* saddr4 | saddr6, daddr4 | daddr6, sport,
* dport, backup, if_idx [, error]
* A new subflow has been established. 'error' should not be set.
*
* - MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport, backup, if_idx [, error]
* - MPTCP_EVENT_SUB_CLOSED: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* A subflow has been closed. An error (copy of sk_err) could be set if an
* error has been detected for this subflow.
*
* - MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport, backup, if_idx [, error]
* - MPTCP_EVENT_SUB_PRIORITY: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* The priority of a subflow has changed. 'error' should not be set.
*
* Commands for MPTCP:
Expand All @@ -88,7 +90,7 @@ enum {
* Announce that an address has been lost to the peer.
*
* - MPTCP_CMD_SUB_CREATE: token, family, loc_id, rem_id, daddr4 | daddr6,
* dport [,saddr4 | saddr6, sport, backup, if_idx]
* dport [, saddr4 | saddr6, sport, backup, if_idx]
* Create a new subflow.
*
* - MPTCP_CMD_SUB_DESTROY: token, family, saddr4 | saddr6, daddr4 | daddr6,
Expand Down
64 changes: 54 additions & 10 deletions include/linux/mptcp_upstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
#ifndef _UAPI_MPTCP_H
#define _UAPI_MPTCP_H

#ifndef __KERNEL__
#include <netinet/in.h> /* for sockaddr_in and sockaddr_in6 */
#include <sys/socket.h> /* for struct sockaddr */
#endif

#include <linux/const.h>
#include <linux/types.h>
#include <linux/in.h> /* for sockaddr_in */
#include <linux/in6.h> /* for sockaddr_in6 */
#include <linux/socket.h> /* for sockaddr_storage and sa_family */

#define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0)
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
Expand Down Expand Up @@ -50,6 +58,7 @@ enum {
MPTCP_PM_ATTR_SUBFLOWS, /* u32 */
MPTCP_PM_ATTR_TOKEN, /* u32 */
MPTCP_PM_ATTR_LOC_ID, /* u8 */
MPTCP_PM_ATTR_ADDR_REMOTE, /* nested address */

__MPTCP_PM_ATTR_MAX
};
Expand All @@ -75,6 +84,8 @@ enum {
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4)

enum {
MPTCP_PM_CMD_UNSPEC,
Expand All @@ -86,8 +97,10 @@ enum {
MPTCP_PM_CMD_SET_LIMITS,
MPTCP_PM_CMD_GET_LIMITS,
MPTCP_PM_CMD_SET_FLAGS,
MPTCP_PM_CMD_ANNOUNCE,
MPTCP_PM_CMD_REMOVE,
MPTCP_PM_CMD_ANNOUNCE,
MPTCP_PM_CMD_REMOVE,
MPTCP_PM_CMD_SUBFLOW_CREATE,
MPTCP_PM_CMD_SUBFLOW_DESTROY,

__MPTCP_PM_CMD_AFTER_LAST
};
Expand Down Expand Up @@ -132,19 +145,21 @@ struct mptcp_info {
* MPTCP_EVENT_REMOVED: token, rem_id
* An address has been lost by the peer.
*
* MPTCP_EVENT_SUB_ESTABLISHED: token, family, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup,
* if_idx [, error]
* MPTCP_EVENT_SUB_ESTABLISHED: token, family, loc_id, rem_id,
* saddr4 | saddr6, daddr4 | daddr6, sport,
* dport, backup, if_idx [, error]
* A new subflow has been established. 'error' should not be set.
*
* MPTCP_EVENT_SUB_CLOSED: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport, backup, if_idx [, error]
* MPTCP_EVENT_SUB_CLOSED: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* A subflow has been closed. An error (copy of sk_err) could be set if an
* error has been detected for this subflow.
*
* MPTCP_EVENT_SUB_PRIORITY: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport, backup, if_idx [, error]
* The priority of a subflow has changed. 'error' should not be set.
* MPTCP_EVENT_SUB_PRIORITY: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* The priority of a subflow has changed. 'error' should not be set.
*/
enum mptcp_event_type {
MPTCP_EVENT_UNSPEC = 0,
Expand Down Expand Up @@ -181,6 +196,7 @@ enum mptcp_event_attr {
MPTCP_ATTR_IF_IDX, /* s32 */
MPTCP_ATTR_RESET_REASON,/* u32 */
MPTCP_ATTR_RESET_FLAGS, /* u32 */
MPTCP_ATTR_SERVER_SIDE, /* u8 */

__MPTCP_ATTR_AFTER_LAST
};
Expand All @@ -196,4 +212,32 @@ enum mptcp_event_attr {
#define MPTCP_RST_EBADPERF 5
#define MPTCP_RST_EMIDDLEBOX 6

struct mptcp_subflow_data {
__u32 size_subflow_data; /* size of this structure in userspace */
__u32 num_subflows; /* must be 0, set by kernel */
__u32 size_kernel; /* must be 0, set by kernel */
__u32 size_user; /* size of one element in data[] */
} __attribute__((aligned(8)));

struct mptcp_subflow_addrs {
union {
__kernel_sa_family_t sa_family;
struct sockaddr sa_local;
struct sockaddr_in sin_local;
struct sockaddr_in6 sin6_local;
struct __kernel_sockaddr_storage ss_local;
};
union {
struct sockaddr sa_remote;
struct sockaddr_in sin_remote;
struct sockaddr_in6 sin6_remote;
struct __kernel_sockaddr_storage ss_remote;
};
};

/* MPTCP socket options */
#define MPTCP_INFO 1
#define MPTCP_TCPINFO 2
#define MPTCP_SUBFLOW_ADDRS 3

#endif /* _UAPI_MPTCP_H */
2 changes: 2 additions & 0 deletions include/mptcpd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pkginclude_HEADERS = \
addr_info.h \
export.h \
id_manager.h \
listener_manager.h \
network_monitor.h \
path_manager.h \
plugin.h \
Expand All @@ -16,6 +17,7 @@ noinst_HEADERS = \
private/config.h \
private/configuration.h \
private/id_manager.h \
private/listener_manager.h \
private/mptcp_org.h \
private/mptcp_upstream.h \
private/murmur_hash.h \
Expand Down
70 changes: 70 additions & 0 deletions include/mptcpd/listener_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: BSD-3-Clause
/**
* @file listener_manager.h
*
* @brief Map of MPTCP local address to listener.
*
* Copyright (c) 2022, Intel Corporation
*/

#ifndef MPTCPD_LISTENER_MANAGER_H
#define MPTCPD_LISTENER_MANAGER_H

#include <stdbool.h>

#include <mptcpd/export.h>


#ifdef __cplusplus
extern "C" {
#endif

struct mptcpd_lm;
struct sockaddr;

/**
* @brief Listen on the given MPTCP local address.
*
* Create a MPTCP listening socket for the given local address. This
* is needed to accept subflows, e.g. during a @c MP_JOIN operation.
*
* @param[in] lm The mptcpd address listener manager object.
* @param[in,out] sa The MPTCP local address. If the port is zero an
* ephemeral port will be chosen, and assigned to
* the appropriate underlying address
* family-specific port member, e.g. @c sin_port or
* @c sin6_port. The port will be in network byte
* order.
*
* @return @c 0 if operation was successful. -1 or @c errno otherwise.
*/
MPTCPD_API int mptcpd_lm_listen(struct mptcpd_lm *lm,
struct sockaddr *sa);

/**
* @brief Stop listening on a MPTCP local address.
*
* @param[in] lm The mptcpd address listener manager object.
* @param[in] sa The MPTCP local address with a non-zero port, such as
* the one assigned by @c mptcpd_lm_listen(), i.e. the
* non-zero port provided by the user or the ephemeral
* port chosen by the kernel.
*
* @return @c 0 if operation was successful. -1 or @c errno otherwise.
*/
MPTCPD_API int mptcpd_lm_close(struct mptcpd_lm *lm,
struct sockaddr const *sa);

#ifdef __cplusplus
}
#endif


#endif /* MPTCPD_LISTENER_MANAGER_H */


/*
Local Variables:
c-file-style: "linux"
End:
*/
40 changes: 30 additions & 10 deletions include/mptcpd/path_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @brief mptcpd generic netlink commands.
*
* Copyright (c) 2017-2021, Intel Corporation
* Copyright (c) 2017-2022, Intel Corporation
*/

#ifndef MPTCPD_LIB_PATH_MANAGER_H
Expand Down Expand Up @@ -107,25 +107,31 @@ MPTCPD_API bool mptcpd_pm_ready(struct mptcpd_pm const *pm);
/**
* @brief Advertise new network address to peers.
*
* @param[in] pm The mptcpd path manager object.
* @param[in] addr Local IP address and port to be advertised
* through the MPTCP protocol @c ADD_ADDR
* option. The port is optional, and is
* ignored if it is zero.
* @param[in] id MPTCP local address ID.
* @param[in] token MPTCP connection token.
* @param[in] pm The mptcpd path manager object.
* @param[in,out] addr Local IP address and port to be advertised
* through the MPTCP protocol @c ADD_ADDR
* option. If the port is zero an ephemeral port
* will be chosen, and assigned to the
* appropriate underlying address family-specific
* port member, e.g. @c sin_port or
* @c sin6_port. The port will be in network
* byte order.
* @param[in] id MPTCP local address ID.
* @param[in] token MPTCP connection token.
*
* @return @c 0 if operation was successful. @c errno otherwise.
* @return @c 0 if operation was successful. -1 or @c errno otherwise.
*/
MPTCPD_API int mptcpd_pm_add_addr(struct mptcpd_pm *pm,
struct sockaddr const *addr,
struct sockaddr *addr,
mptcpd_aid_t id,
mptcpd_token_t token);

/**
* @brief Stop advertising network address to peers.
*
* @param[in] pm The mptcpd path manager object.
* @param[in] addr Local IP address and port that should no longer
* be advertised through MPTCP.
* @param[in] address_id MPTCP local address ID to be sent in the
* MPTCP protocol @c REMOVE_ADDR option
* corresponding to the local address that will
Expand All @@ -135,6 +141,7 @@ MPTCPD_API int mptcpd_pm_add_addr(struct mptcpd_pm *pm,
* @return @c 0 if operation was successful. -1 or @c errno otherwise.
*/
MPTCPD_API int mptcpd_pm_remove_addr(struct mptcpd_pm *pm,
struct sockaddr const *addr,
mptcpd_aid_t address_id,
mptcpd_token_t token);

Expand Down Expand Up @@ -368,6 +375,19 @@ mptcpd_pm_get_nm(struct mptcpd_pm const *pm);
MPTCPD_API struct mptcpd_idm *
mptcpd_pm_get_idm(struct mptcpd_pm const *pm);

/**
* @brief Get pointer to the global MPTCP listener manager.
*
* @param[in] pm Mptcpd path manager data.
*
* @note The global MPTCP listener manager tracks MPTCP listening
* sockets associated with a local address.
*
* @return Global mptcpd MPTCP listener manager.
*/
MPTCPD_API struct mptcpd_lm *
mptcpd_pm_get_lm(struct mptcpd_pm const *pm);

#ifdef __cplusplus
}
#endif
Expand Down
30 changes: 19 additions & 11 deletions include/mptcpd/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @brief mptcpd user space path manager plugin header file.
*
* Copyright (c) 2017-2020, Intel Corporation
* Copyright (c) 2017-2020, 2022, Intel Corporation
*/

#ifndef MPTCPD_PLUGIN_H
Expand Down Expand Up @@ -139,29 +139,37 @@ struct mptcpd_plugin_ops
* A new MPTCP connection has been created, and pending
* completion.
*
* @param[in] token MPTCP connection token.
* @param[in] laddr Local address information.
* @param[in] raddr Remote address information.
* @param[in] pm Opaque pointer to mptcpd path manager
* object.
* @param[in] token MPTCP connection token.
* @param[in] laddr Local address information.
* @param[in] raddr Remote address information.
* @param[in] server_side @c true if this peer was the
* listener (server), @c false if this
* peer initiated the connection.
* @param[in] pm Opaque pointer to mptcpd path
* manager object.
*/
void (*new_connection)(mptcpd_token_t token,
struct sockaddr const *laddr,
struct sockaddr const *raddr,
bool server_side,
struct mptcpd_pm *pm);

/**
* @brief New MPTCP-capable connection has been established.
*
* @param[in] token MPTCP connection token.
* @param[in] laddr Local address information.
* @param[in] raddr Remote address information.
* @param[in] pm Opaque pointer to mptcpd path manager
* object.
* @param[in] token MPTCP connection token.
* @param[in] laddr Local address information.
* @param[in] raddr Remote address information.
* @param[in] server_side @c true if this peer was the
* listener (server), @c false if this
* peer initiated the connection.
* @param[in] pm Opaque pointer to mptcpd path
* manager object.
*/
void (*connection_established)(mptcpd_token_t token,
struct sockaddr const *laddr,
struct sockaddr const *raddr,
bool server_side,
struct mptcpd_pm *pm);

/**
Expand Down