Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
mptcp: fullmesh: extract RM_ADDR option manipulation
Browse files Browse the repository at this point in the history
Move these operations -- space check and filling -- to dedicated
functions to be able to re-use them in other path-managers later.

Also, it makes sense to move the manipulation of the TCP Options
elsewhere.

For the new function in mptcp_output.c, symbols have to be exported to
be able to use it from kernel modules as the PMs can be compiled as
modules.

Reviewed-by: Tim Froidcoeur <tim.froidcoeur@tessares.net>
Acked-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit 7c18800)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
matttbe committed Jan 10, 2023
1 parent 1926e10 commit 23863e8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
13 changes: 13 additions & 0 deletions include/net/mptcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1385,12 +1385,25 @@ static inline bool mptcp_options_add_addr6_enough_space(const struct mptcp_cb *m
return remaining >= MPTCP_SUB_LEN_ADD_ADDR6_ALIGN_VER1;
}

static inline bool mptcp_options_rm_addr_enough_space(u16 remove_addrs,
int *remove_addr_len,
unsigned int size)
{
unsigned int remaining = MAX_TCP_OPTION_SPACE - size;

*remove_addr_len = mptcp_sub_len_remove_addr_align(remove_addrs);

return remaining >= *remove_addr_len;
}

unsigned int mptcp_options_fill_add_addr4(struct mptcp_cb *mpcb,
struct tcp_out_options *opts,
struct mptcp_loc4 *loc);
unsigned int mptcp_options_fill_add_addr6(struct mptcp_cb *mpcb,
struct tcp_out_options *opts,
struct mptcp_loc6 *loc);
unsigned int mptcp_options_fill_rm_addr(struct tcp_out_options *opts,
u16 remove_addrs, int remove_addr_len);

/* TCP and MPTCP mpc flag-depending functions */
u16 mptcp_select_window(struct sock *sk);
Expand Down
11 changes: 5 additions & 6 deletions net/mptcp/mptcp_fullmesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,14 +1632,13 @@ static void full_mesh_addr_signal(struct sock *sk, unsigned *size,
if (likely(!fmp->remove_addrs))
goto exit;

remove_addr_len = mptcp_sub_len_remove_addr_align(fmp->remove_addrs);
if (MAX_TCP_OPTION_SPACE - *size < remove_addr_len)
if (!mptcp_options_rm_addr_enough_space(fmp->remove_addrs,
&remove_addr_len, *size))
goto exit;

opts->options |= OPTION_MPTCP;
opts->mptcp_options |= OPTION_REMOVE_ADDR;
opts->remove_addrs = fmp->remove_addrs;
*size += remove_addr_len;
*size += mptcp_options_fill_rm_addr(opts, fmp->remove_addrs,
remove_addr_len);

if (skb)
fmp->remove_addrs = 0;

Expand Down
11 changes: 11 additions & 0 deletions net/mptcp/mptcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2108,3 +2108,14 @@ unsigned int mptcp_options_fill_add_addr6(struct mptcp_cb *mpcb,
return MPTCP_SUB_LEN_ADD_ADDR6_ALIGN_VER1;
}
EXPORT_SYMBOL(mptcp_options_fill_add_addr6);

unsigned int mptcp_options_fill_rm_addr(struct tcp_out_options *opts,
u16 remove_addrs, int remove_addr_len)
{
opts->options |= OPTION_MPTCP;
opts->mptcp_options |= OPTION_REMOVE_ADDR;
opts->remove_addrs = remove_addrs;

return remove_addr_len;
}
EXPORT_SYMBOL(mptcp_options_fill_rm_addr);

0 comments on commit 23863e8

Please sign in to comment.