Skip to content

Commit 40453a5

Browse files
geliangtangkuba-moo
authored andcommitted
mptcp: add the incoming MP_PRIO support
This patch added the incoming MP_PRIO logic: Added a flag named mp_prio in struct mptcp_options_received, to mark the MP_PRIO is received, and save the priority value to struct mptcp_options_received's backup member. Then invoke mptcp_pm_mp_prio_received with the receiving subsocket and the backup value. In mptcp_pm_mp_prio_received, get the subflow context according the input subsocket, and change the subflow's backup as the incoming priority value. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0670654 commit 40453a5

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

net/mptcp/options.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,15 @@ static void mptcp_parse_option(const struct sk_buff *skb,
282282
pr_debug("RM_ADDR: id=%d", mp_opt->rm_id);
283283
break;
284284

285+
case MPTCPOPT_MP_PRIO:
286+
if (opsize != TCPOLEN_MPTCP_PRIO)
287+
break;
288+
289+
mp_opt->mp_prio = 1;
290+
mp_opt->backup = *ptr++ & MPTCP_PRIO_BKUP;
291+
pr_debug("MP_PRIO: prio=%d", mp_opt->backup);
292+
break;
293+
285294
case MPTCPOPT_MP_FASTCLOSE:
286295
if (opsize != TCPOLEN_MPTCP_FASTCLOSE)
287296
break;
@@ -313,6 +322,7 @@ void mptcp_get_options(const struct sk_buff *skb,
313322
mp_opt->port = 0;
314323
mp_opt->rm_addr = 0;
315324
mp_opt->dss = 0;
325+
mp_opt->mp_prio = 0;
316326

317327
length = (th->doff * 4) - sizeof(struct tcphdr);
318328
ptr = (const unsigned char *)(th + 1);
@@ -1022,6 +1032,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
10221032
mp_opt.rm_addr = 0;
10231033
}
10241034

1035+
if (mp_opt.mp_prio) {
1036+
mptcp_pm_mp_prio_received(sk, mp_opt.backup);
1037+
mp_opt.mp_prio = 0;
1038+
}
1039+
10251040
if (!mp_opt.dss)
10261041
return;
10271042

net/mptcp/pm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id)
207207
spin_unlock_bh(&pm->lock);
208208
}
209209

210+
void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup)
211+
{
212+
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
213+
214+
pr_debug("subflow->backup=%d, bkup=%d\n", subflow->backup, bkup);
215+
subflow->backup = bkup;
216+
}
217+
210218
/* path manager helpers */
211219

212220
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,

net/mptcp/protocol.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
#define MPTCP_ADDR_IPVERSION_4 4
8989
#define MPTCP_ADDR_IPVERSION_6 6
9090

91+
/* MPTCP MP_PRIO flags */
92+
#define MPTCP_PRIO_BKUP BIT(0)
93+
9194
/* MPTCP socket flags */
9295
#define MPTCP_DATA_READY 0
9396
#define MPTCP_NOSPACE 1
@@ -118,6 +121,7 @@ struct mptcp_options_received {
118121
dss : 1,
119122
add_addr : 1,
120123
rm_addr : 1,
124+
mp_prio : 1,
121125
family : 4,
122126
echo : 1,
123127
backup : 1;
@@ -553,6 +557,7 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
553557
const struct mptcp_addr_info *addr);
554558
void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
555559
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id);
560+
void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
556561
int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
557562
struct mptcp_addr_info *addr,
558563
u8 bkup);

0 commit comments

Comments
 (0)