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

make listening socket creation optional for userspace path manager plugins #297

Merged
merged 4 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/mptcpd/path_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ MPTCPD_API bool mptcpd_pm_ready(struct mptcpd_pm const *pm);
* byte order.
* @param[in] id MPTCP local address ID.
* @param[in] token MPTCP connection token.
* @param[in] nolst Don't create listener.
*
* @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 *addr,
mptcpd_aid_t id,
mptcpd_token_t token);
mptcpd_token_t token,
bool nolst);
matttbe marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief Stop advertising network address to peers.
Expand Down
4 changes: 3 additions & 1 deletion include/mptcpd/private/path_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,16 @@ struct mptcpd_pm_cmd_ops
* network byte order.
* @param[in] id MPTCP local address ID.
* @param[in] token MPTCP connection token.
* @param[in] nolst Don't create listener.
*
* @return @c 0 if operation was successful. -1 or @c errno
* otherwise.
*/
int (*add_addr)(struct mptcpd_pm *pm,
struct sockaddr *addr,
mptcpd_aid_t id,
mptcpd_token_t token);
mptcpd_token_t token,
bool nolst);

/**
* @brief Stop advertising network address to peers.
Expand Down
6 changes: 4 additions & 2 deletions lib/path_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ int mptcpd_kpm_set_flags(struct mptcpd_pm *pm,
int mptcpd_pm_add_addr(struct mptcpd_pm *pm,
struct sockaddr *addr,
mptcpd_aid_t address_id,
mptcpd_token_t token)
mptcpd_token_t token,
bool nolst)
{
if (pm == NULL || addr == NULL || address_id == 0)
return EINVAL;
Expand All @@ -258,7 +259,8 @@ int mptcpd_pm_add_addr(struct mptcpd_pm *pm,
return ops->add_addr(pm,
addr,
address_id,
token);
token,
nolst);
}

int mptcpd_pm_remove_addr(struct mptcpd_pm *pm,
Expand Down
3 changes: 2 additions & 1 deletion plugins/path_managers/sspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,8 @@ static void sspi_send_addr(void *data, void *user_data)
mptcpd_pm_add_addr(info->pm,
sa,
address_id,
info->token);
info->token,
false);

/**
* @todo The sspi plugin currently doesn't stop advertising IP
Expand Down
25 changes: 13 additions & 12 deletions src/netlink_pm_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,21 @@ static int send_add_addr(struct mptcpd_pm *pm,
static int upstream_announce(struct mptcpd_pm *pm,
struct sockaddr *addr,
mptcpd_aid_t id,
mptcpd_token_t token)
mptcpd_token_t token,
bool nolst)
{
/**
* Set up MPTCP listening socket.
*
* @note An ephemeral port will be assigned to the port in
* @a addr if it is zero.
*
* @todo This should be optional.
*/
int const r = mptcpd_lm_listen(pm->lm, addr);
if (!nolst) {
matttbe marked this conversation as resolved.
Show resolved Hide resolved
/**
* Set up MPTCP listening socket.
*
* @note An ephemeral port will be assigned to the port in
* @a addr if it is zero.
*/
int const r = mptcpd_lm_listen(pm->lm, addr);

if (r != 0)
return r;
if (r != 0)
return r;
}

/**
* @todo Add support for the optional network interface index
Expand Down
3 changes: 2 additions & 1 deletion tests/test-commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ static void test_add_addr_user(void const *test_data)
int const result = mptcpd_pm_add_addr(pm,
u_addr->addr,
u_addr->id,
u_addr->token);
u_addr->token,
false);

/*
EADDRNOTAVAIL error will generally occur if the test is run
Expand Down
Loading