Skip to content

Commit 8e2760e

Browse files
matttbekuba-moo
authored andcommitted
Revert "mptcp: add needs_id for netlink appending addr"
This commit was originally adding the ability to add MPTCP endpoints with ID 0 by accident. The in-kernel PM, handling MPTCP endpoints at the net namespace level, is not supposed to handle endpoints with such ID, because this ID 0 is reserved to the initial subflow, as mentioned in the MPTCPv1 protocol [1], a per-connection setting. Note that 'ip mptcp endpoint add id 0' stops early with an error, but other tools might still request the in-kernel PM to create MPTCP endpoints with this restricted ID 0. In other words, it was wrong to call the mptcp_pm_has_addr_attr_id helper to check whether the address ID attribute is set: if it was set to 0, a new MPTCP endpoint would be created with ID 0, which is not expected, and might cause various issues later. Fixes: 584f389 ("mptcp: add needs_id for netlink appending addr") Cc: stable@vger.kernel.org Link: https://datatracker.ietf.org/doc/html/rfc8684#section-3.2-9 [1] Reviewed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20260407-net-mptcp-revert-pm-needs-id-v2-1-7a25cbc324f8@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9b55b25 commit 8e2760e

1 file changed

Lines changed: 5 additions & 19 deletions

File tree

net/mptcp/pm_kernel.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ static void __mptcp_pm_release_addr_entry(struct mptcp_pm_addr_entry *entry)
720720

721721
static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
722722
struct mptcp_pm_addr_entry *entry,
723-
bool needs_id, bool replace)
723+
bool replace)
724724
{
725725
struct mptcp_pm_addr_entry *cur, *del_entry = NULL;
726726
int ret = -EINVAL;
@@ -779,7 +779,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
779779
}
780780
}
781781

782-
if (!entry->addr.id && needs_id) {
782+
if (!entry->addr.id) {
783783
find_next:
784784
entry->addr.id = find_next_zero_bit(pernet->id_bitmap,
785785
MPTCP_PM_MAX_ADDR_ID + 1,
@@ -790,7 +790,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
790790
}
791791
}
792792

793-
if (!entry->addr.id && needs_id)
793+
if (!entry->addr.id)
794794
goto out;
795795

796796
__set_bit(entry->addr.id, pernet->id_bitmap);
@@ -923,7 +923,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk,
923923
return -ENOMEM;
924924

925925
entry->addr.port = 0;
926-
ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true, false);
926+
ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, false);
927927
if (ret < 0)
928928
kfree(entry);
929929

@@ -977,18 +977,6 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net,
977977
return 0;
978978
}
979979

980-
static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,
981-
struct genl_info *info)
982-
{
983-
struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1];
984-
985-
if (!nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
986-
mptcp_pm_address_nl_policy, info->extack) &&
987-
tb[MPTCP_PM_ADDR_ATTR_ID])
988-
return true;
989-
return false;
990-
}
991-
992980
/* Add an MPTCP endpoint */
993981
int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
994982
{
@@ -1037,9 +1025,7 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
10371025
goto out_free;
10381026
}
10391027
}
1040-
ret = mptcp_pm_nl_append_new_local_addr(pernet, entry,
1041-
!mptcp_pm_has_addr_attr_id(attr, info),
1042-
true);
1028+
ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true);
10431029
if (ret < 0) {
10441030
GENL_SET_ERR_MSG_FMT(info, "too many addresses or duplicate one: %d", ret);
10451031
goto out_free;

0 commit comments

Comments
 (0)