Skip to content

Commit 0670654

Browse files
geliangtangkuba-moo
authored andcommitted
mptcp: add the outgoing MP_PRIO support
This patch added the outgoing MP_PRIO logic: In mptcp_pm_nl_mp_prio_send_ack, find the related subflow and subsocket according to the input parameter addr. Save the input priority value to suflow's backup, then set subflow's send_mp_prio flag to true, and save the input priority value to suflow's request_bkup. Finally, send out a pure ACK on the related subsocket. In mptcp_established_options_mp_prio, check whether the subflow's send_mp_prio is set. If it is, this is the packet for sending MP_PRIO. So save subflow->request_bkup value to mptcp_out_options's backup, and change the option type to OPTION_MPTCP_PRIO. In mptcp_write_options, clear the send_mp_prio flag and send out the MP_PRIO suboption with mptcp_out_options's backup value. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent dc8eb10 commit 0670654

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

net/mptcp/options.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,28 @@ static bool mptcp_established_options_rm_addr(struct sock *sk,
679679
return true;
680680
}
681681

682+
static bool mptcp_established_options_mp_prio(struct sock *sk,
683+
unsigned int *size,
684+
unsigned int remaining,
685+
struct mptcp_out_options *opts)
686+
{
687+
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
688+
689+
if (!subflow->send_mp_prio)
690+
return false;
691+
692+
if (remaining < TCPOLEN_MPTCP_PRIO)
693+
return false;
694+
695+
*size = TCPOLEN_MPTCP_PRIO;
696+
opts->suboptions |= OPTION_MPTCP_PRIO;
697+
opts->backup = subflow->request_bkup;
698+
699+
pr_debug("prio=%d", opts->backup);
700+
701+
return true;
702+
}
703+
682704
bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
683705
unsigned int *size, unsigned int remaining,
684706
struct mptcp_out_options *opts)
@@ -721,6 +743,12 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
721743
ret = true;
722744
}
723745

746+
if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) {
747+
*size += opt_size;
748+
remaining -= opt_size;
749+
ret = true;
750+
}
751+
724752
return ret;
725753
}
726754

@@ -1168,6 +1196,18 @@ void mptcp_write_options(__be32 *ptr, const struct tcp_sock *tp,
11681196
0, opts->rm_id);
11691197
}
11701198

1199+
if (OPTION_MPTCP_PRIO & opts->suboptions) {
1200+
const struct sock *ssk = (const struct sock *)tp;
1201+
struct mptcp_subflow_context *subflow;
1202+
1203+
subflow = mptcp_subflow_ctx(ssk);
1204+
subflow->send_mp_prio = 0;
1205+
1206+
*ptr++ = mptcp_option(MPTCPOPT_MP_PRIO,
1207+
TCPOLEN_MPTCP_PRIO,
1208+
opts->backup, TCPOPT_NOP);
1209+
}
1210+
11711211
if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
11721212
*ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
11731213
TCPOLEN_MPTCP_MPJ_SYN,

net/mptcp/pm_netlink.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,39 @@ void mptcp_pm_nl_add_addr_send_ack(struct mptcp_sock *msk)
442442
}
443443
}
444444

445+
int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
446+
struct mptcp_addr_info *addr,
447+
u8 bkup)
448+
{
449+
struct mptcp_subflow_context *subflow;
450+
451+
pr_debug("bkup=%d", bkup);
452+
453+
mptcp_for_each_subflow(msk, subflow) {
454+
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
455+
struct mptcp_addr_info local;
456+
457+
local_address((struct sock_common *)ssk, &local);
458+
if (!addresses_equal(&local, addr, addr->port))
459+
continue;
460+
461+
subflow->backup = bkup;
462+
subflow->send_mp_prio = 1;
463+
subflow->request_bkup = bkup;
464+
465+
spin_unlock_bh(&msk->pm.lock);
466+
pr_debug("send ack for mp_prio");
467+
lock_sock(ssk);
468+
tcp_send_ack(ssk);
469+
release_sock(ssk);
470+
spin_lock_bh(&msk->pm.lock);
471+
472+
return 0;
473+
}
474+
475+
return -EINVAL;
476+
}
477+
445478
void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk)
446479
{
447480
struct mptcp_subflow_context *subflow, *tmp;

net/mptcp/protocol.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define OPTION_MPTCP_ADD_ADDR6 BIT(7)
2525
#define OPTION_MPTCP_RM_ADDR BIT(8)
2626
#define OPTION_MPTCP_FASTCLOSE BIT(9)
27+
#define OPTION_MPTCP_PRIO BIT(10)
2728

2829
/* MPTCP option subtypes */
2930
#define MPTCPOPT_MP_CAPABLE 0
@@ -59,6 +60,7 @@
5960
#define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT 24
6061
#define TCPOLEN_MPTCP_PORT_LEN 4
6162
#define TCPOLEN_MPTCP_RM_ADDR_BASE 4
63+
#define TCPOLEN_MPTCP_PRIO 4
6264
#define TCPOLEN_MPTCP_FASTCLOSE 12
6365

6466
/* MPTCP MP_JOIN flags */
@@ -396,6 +398,7 @@ struct mptcp_subflow_context {
396398
map_valid : 1,
397399
mpc_map : 1,
398400
backup : 1,
401+
send_mp_prio : 1,
399402
rx_eof : 1,
400403
can_ack : 1, /* only after processing the remote a key */
401404
disposable : 1; /* ctx can be free at ulp release time */
@@ -550,6 +553,9 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
550553
const struct mptcp_addr_info *addr);
551554
void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
552555
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
556+
int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
557+
struct mptcp_addr_info *addr,
558+
u8 bkup);
553559
void mptcp_pm_free_anno_list(struct mptcp_sock *msk);
554560
struct mptcp_pm_add_entry *
555561
mptcp_pm_del_add_timer(struct mptcp_sock *msk,

0 commit comments

Comments
 (0)