Skip to content

Commit

Permalink
make listening socket creation optional for userspace path manager pl…
Browse files Browse the repository at this point in the history
…ugins
  • Loading branch information
marco-a-itl committed Aug 6, 2024
1 parent b102523 commit 93b25db
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
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);

/**
* @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) {
/**
* 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

0 comments on commit 93b25db

Please sign in to comment.