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
Changes from 1 commit
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
114 changes: 87 additions & 27 deletions tests/test-listener-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@


#include <arpa/inet.h>
#include <netinet/in.h>

#include <ell/util.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks with a recent ELL - needs the wrapper pragmas for these ELL includes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit e80db71.

#include <ell/log.h>
#include <ell/test.h>
#include <ell/hashmap.h>
Expand All @@ -22,6 +24,52 @@
#include <assert.h>


struct ipv4_listen_case
{
struct sockaddr_in const addr;
char const *const desc;
};

struct ipv6_listen_case
{
struct sockaddr_in6 const addr;
char const *const desc;
};

/**
* @brief Initialize test case to listed on IPv4 loopback address.
*
* @param[in] port IP port to listen on.
*/
#define INIT_IPV4_TEST_CASE(port) \
{ \
.addr = { \
.sin_family = AF_INET, \
.sin_port = htons(port), \
.sin_addr = { \
.s_addr = htonl(INADDR_LOOPBACK) \
} \
}, \
.desc = "listen - IPv4 on port " L_STRINGIFY(port) \
}

/**
* @brief Initialize test case to listed on IPv6 loopback address.
*
* @param[in] port IP port to listen on.
*/
#define INIT_IPV6_TEST_CASE(port) \
{ \
.addr = { \
.sin6_family = AF_INET6, \
.sin6_port = htons(port), \
.sin6_addr = { .s6_addr = { [15] = 0x01 } } \
}, \
.desc = "listen - IPv6 on port " L_STRINGIFY(port) \
}

// -----------------------------------------------------------------------

static struct mptcpd_lm *_lm;

static void test_create(void const *test_data)
Expand All @@ -47,7 +95,6 @@ static void test_close(void const *test_data)
assert(mptcpd_lm_close(_lm, sa));
}


static void test_destroy(void const *test_data)
{
(void) test_data;
Expand All @@ -58,43 +105,56 @@ static void test_destroy(void const *test_data)
int main(int argc, char *argv[])
{
l_log_set_stderr();
//l_debug_enable("*");

l_test_init(&argc, &argv);

/*
Listen on the loopback address since we need an address
backed by a network interface so that underlying bind() call
can succeed.
Listen on the IPv4 and IPv6 loopback addresses since we need
an address backed by a network interface so that the
underlying bind() call can succeed.
*/
struct sockaddr_in addr4 = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl(INADDR_LOOPBACK) }
struct ipv4_listen_case const ipv4_cases[] = {
INIT_IPV4_TEST_CASE(0x3456),
INIT_IPV4_TEST_CASE(0x3457),
INIT_IPV4_TEST_CASE(0x3456), // Same port as above.
INIT_IPV4_TEST_CASE(0)
};

struct sockaddr const *const sa4 =
(struct sockaddr const *) &addr4;

/*
Listen on the loopback address since we need an address
backed by a network interface so that underlying bind() call
can succeed.
*/
struct sockaddr_in6 addr6 = {
.sin6_family = AF_INET6
struct ipv6_listen_case const ipv6_cases[] = {
INIT_IPV6_TEST_CASE(0x4567),
INIT_IPV6_TEST_CASE(0x4578),
INIT_IPV6_TEST_CASE(0x4567), // Same port as above.
INIT_IPV6_TEST_CASE(0)
};

addr6.sin6_addr = in6addr_loopback;

struct sockaddr const *const sa6 =
(struct sockaddr const *) &addr6;
l_test_add("create lm", test_create, NULL);

for (size_t i = 0; i < L_ARRAY_SIZE(ipv4_cases); ++i) {
char const *const desc = ipv4_cases[i].desc;
struct sockaddr const *const sa =
(struct sockaddr const *) &ipv4_cases[i].addr;

l_test_add(desc, test_listen, sa);
}

for (size_t i = 0; i < L_ARRAY_SIZE(ipv6_cases); ++i) {
char const *const desc = ipv6_cases[i].desc;
struct sockaddr const *const sa =
(struct sockaddr const *) &ipv6_cases[i].addr;

l_test_add(desc, test_listen, sa);
}

l_test_add("close - IPv4",
test_close,
(struct sockaddr const *) &ipv4_cases[0]);
l_test_add("close - IPv6",
test_close,
(struct sockaddr const *) &ipv6_cases[0]);

l_test_add("create listener manager", test_create, NULL);
l_test_add("listen - IPv4 - FIRST", test_listen, sa4);
l_test_add("listen - IPv6", test_listen, sa6);
l_test_add("listen - IPv4 - SECOND", test_listen, sa4);
l_test_add("close - IPv4", test_close, sa4);
l_test_add("close - IPv6", test_close, sa6);
l_test_add("destroy listener manager", test_destroy, NULL);
l_test_add("destroy lm", test_destroy, NULL);

return l_test_run();
}
Expand Down