Skip to content

Commit f84281b

Browse files
matttbegregkh
authored andcommitted
mptcp: pm: nl: announce deny-join-id0 flag
commit 2293c57 upstream. During the connection establishment, a peer can tell the other one that it cannot establish new subflows to the initial IP address and port by setting the 'C' flag [1]. Doing so makes sense when the sender is behind a strict NAT, operating behind a legacy Layer 4 load balancer, or using anycast IP address for example. When this 'C' flag is set, the path-managers must then not try to establish new subflows to the other peer's initial IP address and port. The in-kernel PM has access to this info, but the userspace PM didn't. The RFC8684 [1] is strict about that: (...) therefore the receiver MUST NOT try to open any additional subflows toward this address and port. So it is important to tell the userspace about that as it is responsible for the respect of this flag. When a new connection is created and established, the Netlink events now contain the existing but not currently used 'flags' attribute. When MPTCP_PM_EV_FLAG_DENY_JOIN_ID0 is set, it means no other subflows to the initial IP address and port -- info that are also part of the event -- can be established. Link: https://datatracker.ietf.org/doc/html/rfc8684#section-3.1-20.6 [1] Fixes: 702c2f6 ("mptcp: netlink: allow userspace-driven subflow establishment") Reported-by: Marek Majkowski <marek@cloudflare.com> Closes: multipath-tcp/mptcp_net-next#532 Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20250912-net-mptcp-pm-uspace-deny_join_id0-v1-2-40171884ade8@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> [ Conflicts in mptcp_pm.yaml, and mptcp_pm.h, because these files have been added later by commit bc8aeb2 ("Documentation: netlink: add a YAML spec for mptcp"), and commit 9d1ed17 ("uapi: mptcp: use header file generated from YAML spec"), which are not in this version. Applying the same modifications, but only in mptcp.h. Conflict in pm_netlink.c, because of a difference in the context, introduced by commit b9f4554 ("mptcp: annotate lockless access for token"), which is not in this version. ] Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3d7c075 commit f84281b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

include/uapi/linux/mptcp.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ enum {
8181

8282
#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1)
8383

84+
#define MPTCP_PM_EV_FLAG_DENY_JOIN_ID0 _BITUL(0)
85+
8486
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
8587
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
8688
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
@@ -127,13 +129,13 @@ struct mptcp_info {
127129

128130
/*
129131
* MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6,
130-
* sport, dport
132+
* sport, dport, server-side, [flags]
131133
* A new MPTCP connection has been created. It is the good time to allocate
132134
* memory and send ADD_ADDR if needed. Depending on the traffic-patterns
133135
* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent.
134136
*
135137
* MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6,
136-
* sport, dport
138+
* sport, dport, server-side, [flags]
137139
* A MPTCP connection is established (can start new subflows).
138140
*
139141
* MPTCP_EVENT_CLOSED: token

net/mptcp/pm_netlink.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,13 +2242,20 @@ static int mptcp_event_created(struct sk_buff *skb,
22422242
const struct sock *ssk)
22432243
{
22442244
int err = nla_put_u32(skb, MPTCP_ATTR_TOKEN, msk->token);
2245+
u16 flags = 0;
22452246

22462247
if (err)
22472248
return err;
22482249

22492250
if (nla_put_u8(skb, MPTCP_ATTR_SERVER_SIDE, READ_ONCE(msk->pm.server_side)))
22502251
return -EMSGSIZE;
22512252

2253+
if (READ_ONCE(msk->pm.remote_deny_join_id0))
2254+
flags |= MPTCP_PM_EV_FLAG_DENY_JOIN_ID0;
2255+
2256+
if (flags && nla_put_u16(skb, MPTCP_ATTR_FLAGS, flags))
2257+
return -EMSGSIZE;
2258+
22522259
return mptcp_event_add_subflow(skb, ssk);
22532260
}
22542261

0 commit comments

Comments
 (0)