aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeliang Tang <tanggeliang@kylinos.cn>2024-02-15 19:25:29 +0100
committerDavid S. Miller <davem@davemloft.net>2024-02-18 10:25:00 +0000
commit584f3894262634596532cf43a5e782e34a0ce374 (patch)
treecdf615a120ed65375984edcede8b2d4c30312176
parent6c347be62ae963b301ead8e7fa7b9973e6e0d6e1 (diff)
downloadlinux-584f3894262634596532cf43a5e782e34a0ce374.tar.gz
mptcp: add needs_id for netlink appending addr
Just the same as userspace PM, a new parameter needs_id is added for in-kernel PM mptcp_pm_nl_append_new_local_addr() too. Add a new helper mptcp_pm_has_addr_attr_id() to check whether an address ID is set from PM or not. In mptcp_pm_nl_get_local_id(), needs_id is always true, but in mptcp_pm_nl_add_addr_doit(), pass mptcp_pm_has_addr_attr_id() to needs_it. Fixes: efd5a4c04e18 ("mptcp: add the address ID assignment bitmap") Cc: stable@vger.kernel.org Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Notes
Fixes: efd5a4c04e18 ("mptcp: add the address ID assignment bitmap") # v5.12-rc2 Stable: 7e7a81f9f2da # v6.6.19 Stable: 70a4a2657201 # v6.1.80 Stable: 5101e9f11a87 # v5.15.151 Lore: https://lore.kernel.org/r/1d1970ac75aa9b924f1da17c3c89dcba96e5bb46.1706759413.git.tanggeliang@kylinos.cn # mptcp Lore: https://lore.kernel.org/r/20240215-upstream-net-20240215-misc-fixes-v1-2-8c01a55d8f6a@kernel.org # linux-kselftest, lkml, mptcp, netdev, stable Lore: https://lore.kernel.org/r/20240226215620.757784-2-matttbe@kernel.org # mptcp, stable Lore: https://lore.kernel.org/r/20240227131616.709399360@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240227131635.218651774@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240227131637.684501106@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/20240228173714.262012-4-matttbe@kernel.org # mptcp, stable Lore: https://lore.kernel.org/r/20240304211544.631172024@linuxfoundation.org # linux-patches, stable Lore: https://lore.kernel.org/r/7a7abb740b313d77a06d644360ce3f21dd4d7f09.1705375746.git.tanggeliang@kylinos.cn # mptcp Lore: https://lore.kernel.org/r/be3463f397dc050c6a11cbdf6a281dccff9b0642.1705558030.git.tanggeliang@kylinos.cn # mptcp Lore: https://lore.kernel.org/r/c56153b95c3086a8cddf4a7d5efc34cbbf473b87.1704892316.git.geliang.tang@linux.dev # mptcp
-rw-r--r--net/mptcp/pm_netlink.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 287a60381eae6..a24c9128dee9e 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -901,7 +901,8 @@ static void __mptcp_pm_release_addr_entry(struct mptcp_pm_addr_entry *entry)
}
static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
- struct mptcp_pm_addr_entry *entry)
+ struct mptcp_pm_addr_entry *entry,
+ bool needs_id)
{
struct mptcp_pm_addr_entry *cur, *del_entry = NULL;
unsigned int addr_max;
@@ -949,7 +950,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
}
}
- if (!entry->addr.id) {
+ if (!entry->addr.id && needs_id) {
find_next:
entry->addr.id = find_next_zero_bit(pernet->id_bitmap,
MPTCP_PM_MAX_ADDR_ID + 1,
@@ -960,7 +961,7 @@ find_next:
}
}
- if (!entry->addr.id)
+ if (!entry->addr.id && needs_id)
goto out;
__set_bit(entry->addr.id, pernet->id_bitmap);
@@ -1092,7 +1093,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc
entry->ifindex = 0;
entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT;
entry->lsk = NULL;
- ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
+ ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, true);
if (ret < 0)
kfree(entry);
@@ -1285,6 +1286,18 @@ next:
return 0;
}
+static bool mptcp_pm_has_addr_attr_id(const struct nlattr *attr,
+ struct genl_info *info)
+{
+ struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1];
+
+ if (!nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr,
+ mptcp_pm_address_nl_policy, info->extack) &&
+ tb[MPTCP_PM_ADDR_ATTR_ID])
+ return true;
+ return false;
+}
+
int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR];
@@ -1326,7 +1339,8 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
goto out_free;
}
}
- ret = mptcp_pm_nl_append_new_local_addr(pernet, entry);
+ ret = mptcp_pm_nl_append_new_local_addr(pernet, entry,
+ !mptcp_pm_has_addr_attr_id(attr, info));
if (ret < 0) {
GENL_SET_ERR_MSG_FMT(info, "too many addresses or duplicate one: %d", ret);
goto out_free;