Skip to content

Commit 725aaff

Browse files
authored
flags: add 'laminar' endpoints support (#326)
* include: update MPTCP upstream headers Some new defines related to MPTCP_INFO and EV flags, and switch to _BITUL(). Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> * flags: add 'luminar' endpoints support Currently, upon the reception of an ADD_ADDR (and when the fullmesh flag is not used), the in-kernel PM will create new subflows using the local address the routing configuration will pick. It would be easier to pick local addresses from a selected list of endpoints, and use it only once, than relying on routing rules. Use case: both the client (C) and the server (S) have two addresses (a and b). The client establishes the connection between C(a) and S(a). Once established, the server announces its additional address S(b). Once received, the client connects to it using its second address C(b). Compared to a situation without the 'laminar' endpoint for C(b), the client didn't use this address C(b) to establish a subflow to the server's primary address S(a). So at the end, we have: C S C(a) --- S(a) C(b) --- S(b) In case of a 3rd address on each side (C(c) and S(c)), upon the reception of an ADD_ADDR with S(c), the client should not pick C(b) because it has already been used. C(c) should then be used. Note that this situation is currently possible if C doesn't add any endpoint, but configure the routing in order to pick C(b) for the route to S(b), and pick C(c) for the route to S(c). That doesn't sound very practical because it means knowing in advance the IP addresses that will be used and announced by the server. 'laminar', like the idea of laminar flows: the different subflows don't mix with each other on an endpoint, unlike the "turbulent" way traffic is mixed by 'fullmesh'. This new flag is then added to mptcpd as well. Link: multipath-tcp/mptcp_net-next#503 Link: https://git.kernel.org/netdev/net-next/c/539f6b9de39e Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> * tests: commands: also check flags Endpoints are usually added with a flag: validate that. Set a random one (the new 'subflow' one) instead of 0. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> * tests: config: check --addr-flags This parameter was not validated before. Use all possible flags (even if they are not individually checked). Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> --------- Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
1 parent 1de9138 commit 725aaff

File tree

9 files changed

+46
-13
lines changed

9 files changed

+46
-13
lines changed

etc/mptcpd.conf.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ path-manager=@mptcpd_default_pm@
3737
# signal (do not use with the "fullmesh" flag)
3838
# backup
3939
# fullmesh (do not use with the "signal" flag)
40+
# laminar
4041
#
4142
# Plugins that deal with the in-kernel path manager may use these
4243
# flags when advertising addresses.

include/linux/mptcp_upstream.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,43 @@
3434
#define MPTCP_PM_EV_FLAG_DENY_JOIN_ID0 _BITUL(0)
3535
#define MPTCP_PM_EV_FLAG_SERVER_SIDE _BITUL(1)
3636

37-
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
38-
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
39-
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
40-
#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
41-
#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4)
37+
#define MPTCP_PM_ADDR_FLAG_SIGNAL _BITUL(0)
38+
#define MPTCP_PM_ADDR_FLAG_SUBFLOW _BITUL(1)
39+
#define MPTCP_PM_ADDR_FLAG_BACKUP _BITUL(2)
40+
#define MPTCP_PM_ADDR_FLAG_FULLMESH _BITUL(3)
41+
#define MPTCP_PM_ADDR_FLAG_IMPLICIT _BITUL(4)
42+
#define MPTCP_PM_ADDR_FLAG_LAMINAR _BITUL(5)
4243

4344
struct mptcp_info {
4445
__u8 mptcpi_subflows;
46+
#define mptcpi_extra_subflows mptcpi_subflows
4547
__u8 mptcpi_add_addr_signal;
4648
__u8 mptcpi_add_addr_accepted;
4749
__u8 mptcpi_subflows_max;
50+
#define mptcpi_limit_extra_subflows mptcpi_subflows_max
4851
__u8 mptcpi_add_addr_signal_max;
52+
#define mptcpi_endp_signal_max mptcpi_add_addr_signal_max
4953
__u8 mptcpi_add_addr_accepted_max;
54+
#define mptcpi_limit_add_addr_accepted mptcpi_add_addr_accepted_max
55+
/* 16-bit hole that can no longer be filled */
5056
__u32 mptcpi_flags;
5157
__u32 mptcpi_token;
5258
__u64 mptcpi_write_seq;
5359
__u64 mptcpi_snd_una;
5460
__u64 mptcpi_rcv_nxt;
5561
__u8 mptcpi_local_addr_used;
5662
__u8 mptcpi_local_addr_max;
63+
#define mptcpi_endp_subflow_max mptcpi_local_addr_max
5764
__u8 mptcpi_csum_enabled;
65+
/* 8-bit hole that can no longer be filled */
5866
__u32 mptcpi_retransmits;
5967
__u64 mptcpi_bytes_retrans;
6068
__u64 mptcpi_bytes_sent;
6169
__u64 mptcpi_bytes_received;
6270
__u64 mptcpi_bytes_acked;
6371
__u8 mptcpi_subflows_total;
64-
__u8 reserved[3];
72+
__u8 mptcpi_endp_laminar_max;
73+
__u8 reserved[2];
6574
__u32 mptcpi_last_data_sent;
6675
__u32 mptcpi_last_data_recv;
6776
__u32 mptcpi_last_ack_recv;

include/mptcpd/types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ typedef uint32_t mptcpd_flags_t;
7373
* @note Do not use with @c MPTCPD_ADDR_FLAG_SIGNAL.
7474
*/
7575
#define MPTCPD_ADDR_FLAG_FULLMESH (1U << 3)
76+
77+
/// Use this endpoint in reaction to ADD_ADDR, but only once.
78+
#define MPTCPD_ADDR_FLAG_LAMINAR (1U << 5)
7679
///@}
7780

7881
/**

man/mptcpd.8.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ is a comma separated list containing one or more of the flags
7272
.IR subflow ,
7373
.IR signal ,
7474
.IR backup ,
75+
.IR fullmesh ,
7576
and
76-
.I fullmesh
77+
.IR laminar
7778
that plugins that deal with the in-kernel path manager may use when
7879
advertising addresses, e.g.
7980
.B --addr-flags=subflow

plugins/path_managers/addr_adv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ static void update_limits(struct mptcpd_pm *pm, int delta)
5454
If the pm creates outgoing subflows, we assume this is
5555
the client side, and accepts add_addrs from the server.
5656
*/
57-
if (pm->config->addr_flags & MPTCPD_ADDR_FLAG_SUBFLOW)
57+
if (pm->config->addr_flags &
58+
(MPTCPD_ADDR_FLAG_SUBFLOW | MPTCPD_ADDR_FLAG_LAMINAR))
5859
_limits[1].limit = _limits[0].limit;
5960

6061
int const result = mptcpd_kpm_set_limits(pm,

src/configuration.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ static struct tok_entry const addr_flags_toks[] = {
121121
{ MPTCPD_ADDR_FLAG_SIGNAL, "signal" },
122122
{ MPTCPD_ADDR_FLAG_BACKUP, "backup" },
123123
{ MPTCPD_ADDR_FLAG_FULLMESH, "fullmesh" },
124+
{ MPTCPD_ADDR_FLAG_LAMINAR, "laminar" },
124125
{ 0, NULL },
125126
};
126127

src/netlink_pm_upstream.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
#if MPTCPD_ADDR_FLAG_SIGNAL != MPTCP_PM_ADDR_FLAG_SIGNAL \
3535
|| MPTCPD_ADDR_FLAG_SUBFLOW != MPTCP_PM_ADDR_FLAG_SUBFLOW \
3636
|| MPTCPD_ADDR_FLAG_BACKUP != MPTCP_PM_ADDR_FLAG_BACKUP \
37-
|| MPTCPD_ADDR_FLAG_FULLMESH != MPTCP_PM_ADDR_FLAG_FULLMESH
37+
|| MPTCPD_ADDR_FLAG_FULLMESH != MPTCP_PM_ADDR_FLAG_FULLMESH \
38+
|| MPTCPD_ADDR_FLAG_LAMINAR != MPTCP_PM_ADDR_FLAG_LAMINAR
3839
# error Mismatch between mptcpd and upstream kernel addr flags.
3940
#endif
4041

tests/test-commands.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ struct test_addr_info
5858

5959
// MPTCP address ID used for add_addr and dump_addr calls.
6060
mptcpd_aid_t id;
61+
62+
// MPTCP address flags used in the endpoints
63+
mptcpd_flags_t const flags;
6164
};
6265

6366
struct test_info
@@ -186,6 +189,7 @@ static void get_addr_callback(struct mptcpd_addr_info const *info,
186189

187190
assert(mptcpd_addr_info_get_id(info) == k_addr->id);
188191
assert(mptcpd_addr_info_get_index(info) == k_addr->ifindex);
192+
assert(mptcpd_addr_info_get_flags(info) == k_addr->flags);
189193
assert(sockaddr_is_equal(k_addr->addr,
190194
mptcpd_addr_info_get_addr(info)));
191195
}
@@ -210,6 +214,7 @@ static void dump_addrs_callback(struct mptcpd_addr_info const *info,
210214
return;
211215

212216
assert(mptcpd_addr_info_get_index(info) == k_addr->ifindex);
217+
assert(mptcpd_addr_info_get_flags(info) == k_addr->flags);
213218
assert(sockaddr_is_equal(k_addr->addr,
214219
mptcpd_addr_info_get_addr(info)));
215220
}
@@ -327,12 +332,10 @@ static void test_add_addr_kernel(void const *test_data)
327332

328333
k_addr->id = mptcpd_idm_get_id(idm, k_addr->addr);
329334

330-
uint32_t flags = 0;
331-
332335
int const result = mptcpd_kpm_add_addr(pm,
333336
k_addr->addr,
334337
k_addr->id,
335-
flags,
338+
k_addr->flags,
336339
k_addr->ifindex);
337340

338341
assert(result == 0 || result == ENOTSUP);
@@ -911,7 +914,8 @@ static void test_commands(void const *data)
911914
.k_addr = {
912915
.addr = (struct sockaddr *) &kernel_addr,
913916
.ifindex = if_nametoindex(loopback),
914-
.prefix_len = get_prefix_len(info.k_addr.addr)
917+
.prefix_len = get_prefix_len(info.k_addr.addr),
918+
.flags = MPTCPD_ADDR_FLAG_SUBFLOW
915919
}
916920
};
917921

tests/test-configuration.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ static void test_load_plugins(void const *test_data)
108108
RUN_CONFIG(argv);
109109
}
110110

111+
static void test_addr_flags(void const *test_data)
112+
{
113+
(void) test_data;
114+
115+
static char *argv[] =
116+
{ TEST_PROGRAM_NAME, "--addr-flags",
117+
"signal,subflow,fullmesh,backup,laminar" };
118+
119+
RUN_CONFIG(argv);
120+
}
121+
111122
static void test_multi_arg(void const *test_data)
112123
{
113124
(void) test_data;
@@ -176,6 +187,7 @@ int main(int argc, char *argv[])
176187
l_test_add("plugin dir", test_plugin_dir, NULL);
177188
l_test_add("path manager", test_path_manager, NULL);
178189
l_test_add("load plugins", test_load_plugins, NULL);
190+
l_test_add("addr flags", test_addr_flags, NULL);
179191
l_test_add("multi arg", test_multi_arg, NULL);
180192
l_test_add("config file", test_config_file, NULL);
181193
l_test_add("debug", test_debug, NULL);

0 commit comments

Comments
 (0)