Skip to content

Commit 1950e24

Browse files
committed
interface: add 'deny_join_id0' parameter
This flag being added on the kernel side [1]. It is set when the other peer requested not to create new subflows to the initial IP address and port. The 'new_connection' and 'connection_established' interfaces are then modified: a new deny_join_id0 parameter is added. LIB_CURRENT, the sspi plugin, and different tests have been modified accordingly. Link: https://lore.kernel.org/[email protected] Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent 2058b80 commit 1950e24

File tree

16 files changed

+88
-11
lines changed

16 files changed

+88
-11
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ AC_INIT([mptcpd],
1818
# Interfaces changed: CURRENT++ REVISION=0
1919
# added: CURRENT++ REVISION=0 AGE++
2020
# removed: CURRENT++ REVISION=0 AGE=0
21-
LIB_CURRENT=4
21+
LIB_CURRENT=5
2222
LIB_REVISION=0
2323
LIB_AGE=1
2424

include/linux/mptcp_upstream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)
3232
#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1)
3333

34+
#define MPTCP_PM_EV_FLAG_DENY_JOIN_ID0 _BITUL(0)
35+
3436
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
3537
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
3638
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)

include/linux/mptcp_upstream_pm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
* good time to allocate memory and send ADD_ADDR if needed. Depending on the
1717
* traffic-patterns it can take a long time until the MPTCP_EVENT_ESTABLISHED
1818
* is sent. Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6,
19-
* sport, dport, server-side.
19+
* sport, dport, server-side, [flags].
2020
* @MPTCP_EVENT_ESTABLISHED: A MPTCP connection is established (can start new
2121
* subflows). Attributes: token, family, saddr4 | saddr6, daddr4 | daddr6,
22-
* sport, dport, server-side.
22+
* sport, dport, server-side, [flags].
2323
* @MPTCP_EVENT_CLOSED: A MPTCP connection has stopped. Attribute: token.
2424
* @MPTCP_EVENT_ANNOUNCED: A new address has been announced by the peer.
2525
* Attributes: token, rem_id, family, daddr4 | daddr6 [, dport].

include/mptcpd/plugin.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,17 @@ struct mptcpd_plugin_ops
145145
* @param[in] server_side @c true if this peer was the
146146
* listener (server), @c false if this
147147
* peer initiated the connection.
148+
* @param[in] deny_join_id0 @c true if the other peer requested not to
149+
* create a new subflow to the initial IP
150+
* address and port
148151
* @param[in] pm Opaque pointer to mptcpd path
149152
* manager object.
150153
*/
151154
void (*new_connection)(mptcpd_token_t token,
152155
struct sockaddr const *laddr,
153156
struct sockaddr const *raddr,
154157
bool server_side,
158+
bool deny_join_id0,
155159
struct mptcpd_pm *pm);
156160

157161
/**
@@ -163,13 +167,17 @@ struct mptcpd_plugin_ops
163167
* @param[in] server_side @c true if this peer was the
164168
* listener (server), @c false if this
165169
* peer initiated the connection.
170+
* @param[in] deny_join_id0 @c true if the other peer requested not to
171+
* create a new subflow to the initial IP
172+
* address and port
166173
* @param[in] pm Opaque pointer to mptcpd path
167174
* manager object.
168175
*/
169176
void (*connection_established)(mptcpd_token_t token,
170177
struct sockaddr const *laddr,
171178
struct sockaddr const *raddr,
172179
bool server_side,
180+
bool deny_join_id0,
173181
struct mptcpd_pm *pm);
174182

175183
/**

include/mptcpd/private/plugin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ MPTCPD_API void mptcpd_plugin_unload(struct mptcpd_pm *pm);
6060
* @param[in] laddr Local address information.
6161
* @param[in] raddr Remote address information.
6262
* @param[in] server_side Server side connection flag.
63+
* @param[in] deny_join_id0 No MPJ to the initial address and port.
6364
* @param[in] pm Opaque pointer to mptcpd path manager object.
6465
*/
6566
MPTCPD_API void mptcpd_plugin_new_connection(
@@ -68,6 +69,7 @@ MPTCPD_API void mptcpd_plugin_new_connection(
6869
struct sockaddr const *laddr,
6970
struct sockaddr const *raddr,
7071
bool server_side,
72+
bool deny_join_id0,
7173
struct mptcpd_pm *pm);
7274

7375
/**
@@ -77,13 +79,15 @@ MPTCPD_API void mptcpd_plugin_new_connection(
7779
* @param[in] laddr Local address information.
7880
* @param[in] raddr Remote address information.
7981
* @param[in] server_side Server side connection flag.
82+
* @param[in] deny_join_id0 No MPJ to the initial address and port.
8083
* @param[in] pm Opaque pointer to mptcpd path manager object.
8184
*/
8285
MPTCPD_API void mptcpd_plugin_connection_established(
8386
mptcpd_token_t token,
8487
struct sockaddr const *laddr,
8588
struct sockaddr const *raddr,
8689
bool server_side,
90+
bool deny_join_id0,
8791
struct mptcpd_pm *pm);
8892

8993
/**

lib/plugin.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ void mptcpd_plugin_new_connection(char const *name,
575575
struct sockaddr const *laddr,
576576
struct sockaddr const *raddr,
577577
bool server_side,
578+
bool deny_join_id0,
578579
struct mptcpd_pm *pm)
579580
{
580581
struct mptcpd_plugin_ops const *const ops = name_to_ops(name);
@@ -586,13 +587,19 @@ void mptcpd_plugin_new_connection(char const *name,
586587
l_error("Unable to map connection to plugin.");
587588

588589
if (ops && ops->new_connection)
589-
ops->new_connection(token, laddr, raddr, server_side, pm);
590+
ops->new_connection(token,
591+
laddr,
592+
raddr,
593+
server_side,
594+
deny_join_id0,
595+
pm);
590596
}
591597

592598
void mptcpd_plugin_connection_established(mptcpd_token_t token,
593599
struct sockaddr const *laddr,
594600
struct sockaddr const *raddr,
595601
bool server_side,
602+
bool deny_join_id0,
596603
struct mptcpd_pm *pm)
597604
{
598605
struct mptcpd_plugin_ops const *const ops = token_to_ops(token);
@@ -602,6 +609,7 @@ void mptcpd_plugin_connection_established(mptcpd_token_t token,
602609
laddr,
603610
raddr,
604611
server_side,
612+
deny_join_id0,
605613
pm);
606614
}
607615

plugins/path_managers/sspi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,10 +542,12 @@ static void sspi_new_connection(mptcpd_token_t token,
542542
struct sockaddr const *laddr,
543543
struct sockaddr const *raddr,
544544
bool server_side,
545+
bool deny_join_id0,
545546
struct mptcpd_pm *pm)
546547
{
547548
(void) raddr;
548549
(void) server_side;
550+
(void) deny_join_id0;
549551

550552
/**
551553
* @note Because we directly store connection tokens in a
@@ -604,12 +606,14 @@ static void sspi_connection_established(mptcpd_token_t token,
604606
struct sockaddr const *laddr,
605607
struct sockaddr const *raddr,
606608
bool server_side,
609+
bool deny_join_id0,
607610
struct mptcpd_pm *pm)
608611
{
609612
(void) token;
610613
(void) laddr;
611614
(void) raddr;
612615
(void) server_side;
616+
(void) deny_join_id0;
613617
(void) pm;
614618

615619
/**

src/path_manager.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Copyright (c) 2017-2022, Intel Corporation
88
*/
99

10+
#include "linux/mptcp_upstream_pm.h"
1011
#ifdef HAVE_CONFIG_H
1112
# include <mptcpd/private/config.h>
1213
#endif
@@ -133,6 +134,9 @@ struct pm_event_attrs
133134

134135
/// Server side connection event (boolean)
135136
uint8_t const *server_side;
137+
138+
/// Event flags
139+
uint16_t const *flags;
136140
};
137141

138142
/**
@@ -196,8 +200,10 @@ static void parse_netlink_attributes(struct l_genl_msg *msg,
196200
case MPTCP_ATTR_SERVER_SIDE:
197201
MPTCP_GET_NL_ATTR(data, len, attrs->server_side);
198202
break;
199-
case MPTCP_ATTR_FAMILY:
200203
case MPTCP_ATTR_FLAGS:
204+
MPTCP_GET_NL_ATTR(data, len, attrs->flags);
205+
break;
206+
case MPTCP_ATTR_FAMILY:
201207
case MPTCP_ATTR_TIMEOUT:
202208
case MPTCP_ATTR_RESET_REASON:
203209
case MPTCP_ATTR_RESET_FLAGS:
@@ -253,12 +259,16 @@ static void handle_connection_created(struct pm_event_attrs const *attrs,
253259
static char const *const pm_name = NULL;
254260
bool const server_side =
255261
(attrs->server_side != NULL ? *attrs->server_side : false);
262+
bool const deny_join_id0 =
263+
attrs->flags != NULL &&
264+
*attrs->flags & MPTCP_PM_EV_FLAG_DENY_JOIN_ID0;
256265

257266
mptcpd_plugin_new_connection(pm_name,
258267
*attrs->token,
259268
(struct sockaddr *) &laddr,
260269
(struct sockaddr *) &raddr,
261270
server_side,
271+
deny_join_id0,
262272
pm);
263273
}
264274

@@ -305,11 +315,15 @@ static void handle_connection_established(struct pm_event_attrs const *attrs,
305315
// Assume server_side is false if event attribute is unavailable.
306316
bool const server_side =
307317
(attrs->server_side != NULL ? *attrs->server_side : false);
318+
bool const deny_join_id0 =
319+
attrs->flags != NULL &&
320+
*attrs->flags & MPTCP_PM_EV_FLAG_DENY_JOIN_ID0;
308321

309322
mptcpd_plugin_connection_established(*attrs->token,
310323
(struct sockaddr *) &laddr,
311324
(struct sockaddr *) &raddr,
312325
server_side,
326+
deny_join_id0,
313327
pm);
314328
}
315329

tests/lib/call_plugin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ void call_plugin_ops(struct plugin_call_count const *count,
2929
args->laddr,
3030
args->raddr,
3131
args->server_side,
32+
args->deny_join_id0,
3233
args->pm);
3334

3435
for (int i = 0; i < count->connection_established; ++i)
3536
mptcpd_plugin_connection_established(args->token,
3637
args->laddr,
3738
args->raddr,
3839
args->server_side,
40+
args->deny_join_id0,
3941
args->pm);
4042

4143
for (int i = 0; i < count->new_address; ++i)

tests/lib/test-plugin.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,22 @@ static mptcpd_aid_t const test_laddr_id_1 = 0x34;
151151
static mptcpd_aid_t const test_raddr_id_1 = 0x56;
152152
static bool const test_backup_1 = true;
153153
static bool const test_server_side_1 = true;
154+
static bool const test_deny_join_id0_1 = true;
154155

155156

156157
static mptcpd_token_t const test_token_2 = 0x23456789;
157158
static mptcpd_aid_t const test_laddr_id_2 = 0x23;
158159
static mptcpd_aid_t const test_raddr_id_2 = 0x45;
159160
static bool const test_backup_2 = false;
160161
static bool const test_server_side_2 = true;
162+
static bool const test_deny_join_id0_2 = true;
161163

162164
static mptcpd_token_t const test_token_4 = 0x34567890;
163165
static mptcpd_aid_t const test_laddr_id_4 = 0x90;
164166
static mptcpd_aid_t const test_raddr_id_4 = 0x01;
165167
static bool const test_backup_4 = true;
166168
static bool const test_server_side_4 = false;
169+
static bool const test_deny_join_id0_4 = false;
167170

168171
// For verifying that a plugin will not be dispatched.
169172
static mptcpd_token_t const test_bad_token = 0xFFFFFFFF;
@@ -306,6 +309,9 @@ struct plugin_call_args
306309
/// Server side connection flag.
307310
bool server_side;
308311

312+
/// Remote peer deny a MP_JOIN to the initial IP address and port
313+
bool deny_join_id0;
314+
309315
/// Mptcpd path manager object.
310316
struct mptcpd_pm *const pm;
311317
};

0 commit comments

Comments
 (0)