Skip to content

Commit

Permalink
mptcp: add rm_list in mptcp_options_received
Browse files Browse the repository at this point in the history
This patch changed the member rm_id in struct mptcp_options_received as a
list of the removing address ids, and renamed it to rm_list.

In mptcp_parse_option, parsed the RM_ADDR suboption and filled them into
the rm_list in struct mptcp_options_received.

In mptcp_incoming_options, passed this rm_list to the function
mptcp_pm_rm_addr_received.

It also changed the parameter type of mptcp_pm_rm_addr_received.

Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and jenkins-tessares committed Feb 18, 2021
1 parent ad2399b commit ad3cbae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
12 changes: 8 additions & 4 deletions net/mptcp/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
int expected_opsize;
u8 version;
u8 flags;
u8 i;

switch (subtype) {
case MPTCPOPT_MP_CAPABLE:
Expand Down Expand Up @@ -272,14 +273,17 @@ static void mptcp_parse_option(const struct sk_buff *skb,
break;

case MPTCPOPT_RM_ADDR:
if (opsize != TCPOLEN_MPTCP_RM_ADDR_BASE)
if (opsize < TCPOLEN_MPTCP_RM_ADDR_BASE + 1 ||
opsize > TCPOLEN_MPTCP_RM_ADDR_BASE + MPTCP_RM_IDS_MAX)
break;

ptr++;

mp_opt->rm_addr = 1;
mp_opt->rm_id = *ptr++;
pr_debug("RM_ADDR: id=%d", mp_opt->rm_id);
mp_opt->rm_list.nr = opsize - TCPOLEN_MPTCP_RM_ADDR_BASE;
for (i = 0; i < mp_opt->rm_list.nr; i++)
mp_opt->rm_list.ids[i] = *ptr++;
pr_debug("RM_ADDR: rm_list_nr=%d", mp_opt->rm_list.nr);
break;

case MPTCPOPT_MP_PRIO:
Expand Down Expand Up @@ -1043,7 +1047,7 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
}

if (mp_opt.rm_addr) {
mptcp_pm_rm_addr_received(msk, mp_opt.rm_id);
mptcp_pm_rm_addr_received(msk, mp_opt.rm_list);
mp_opt.rm_addr = 0;
}

Expand Down
10 changes: 6 additions & 4 deletions net/mptcp/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,19 @@ void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_SEND_ACK);
}

void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, struct mptcp_rm_list rm_list)
{
struct mptcp_pm_data *pm = &msk->pm;
u8 i;

pr_debug("msk=%p remote_id=%d", msk, rm_id);
pr_debug("msk=%p remote_ids_nr=%d", msk, rm_list.nr);

mptcp_event_addr_removed(msk, rm_id);
for (i = 0; i < rm_list.nr; i++)
mptcp_event_addr_removed(msk, rm_list.ids[i]);

spin_lock_bh(&pm->lock);
mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED);
pm->rm_id = rm_id;
pm->rm_id = rm_list.ids[0];
spin_unlock_bh(&pm->lock);
}

Expand Down
4 changes: 2 additions & 2 deletions net/mptcp/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ struct mptcp_options_received {
mpc_map:1,
__unused:2;
u8 addr_id;
u8 rm_id;
struct mptcp_rm_list rm_list;
union {
struct in_addr addr;
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
Expand Down Expand Up @@ -647,7 +647,7 @@ void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id);
void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr);
void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, struct mptcp_rm_list rm_list);
void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
struct mptcp_addr_info *addr,
Expand Down

0 comments on commit ad3cbae

Please sign in to comment.