mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
synced 2026-05-02 23:43:48 -04:00
mptcp: pm: reduce entries iterations on connect
__mptcp_subflow_connect() is currently called from the path-managers,
which have all the required information to create subflows. No need to
call the PM again to re-iterate over the list of entries with RCU lock
to get more info.
Instead, it is possible to pass a mptcp_pm_addr_entry structure, instead
of a mptcp_addr_info one. The former contains the ifindex and the flags
that are required when creating the new subflow.
This is a partial revert of commit ee285257a9 ("mptcp: drop flags and
ifindex arguments").
While at it, the local ID can also be set if it is known and 0, to avoid
having to set it in the 'rebuild_header' hook, which will cause a new
iteration of the endpoint entries.
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20240902-net-next-mptcp-mib-mpjtx-misc-v1-2-d3e0f3773b90@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
7bcf4d8022
commit
b83fbca1b4
@@ -119,23 +119,6 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk,
|
||||
unsigned int id,
|
||||
u8 *flags, int *ifindex)
|
||||
{
|
||||
struct mptcp_pm_addr_entry *match;
|
||||
|
||||
spin_lock_bh(&msk->pm.lock);
|
||||
match = mptcp_userspace_pm_lookup_addr_by_id(msk, id);
|
||||
spin_unlock_bh(&msk->pm.lock);
|
||||
if (match) {
|
||||
*flags = match->flags;
|
||||
*ifindex = match->ifindex;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk,
|
||||
struct mptcp_addr_info *skc)
|
||||
{
|
||||
@@ -352,8 +335,9 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
|
||||
struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE];
|
||||
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
|
||||
struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR];
|
||||
struct mptcp_pm_addr_entry local = { 0 };
|
||||
struct mptcp_pm_addr_entry entry = { 0 };
|
||||
struct mptcp_addr_info addr_r;
|
||||
struct mptcp_pm_local local;
|
||||
struct mptcp_sock *msk;
|
||||
int err = -EINVAL;
|
||||
struct sock *sk;
|
||||
@@ -379,18 +363,18 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
|
||||
goto create_err;
|
||||
}
|
||||
|
||||
err = mptcp_pm_parse_entry(laddr, info, true, &local);
|
||||
err = mptcp_pm_parse_entry(laddr, info, true, &entry);
|
||||
if (err < 0) {
|
||||
NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr");
|
||||
goto create_err;
|
||||
}
|
||||
|
||||
if (local.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) {
|
||||
if (entry.flags & MPTCP_PM_ADDR_FLAG_SIGNAL) {
|
||||
GENL_SET_ERR_MSG(info, "invalid addr flags");
|
||||
err = -EINVAL;
|
||||
goto create_err;
|
||||
}
|
||||
local.flags |= MPTCP_PM_ADDR_FLAG_SUBFLOW;
|
||||
entry.flags |= MPTCP_PM_ADDR_FLAG_SUBFLOW;
|
||||
|
||||
err = mptcp_pm_parse_addr(raddr, info, &addr_r);
|
||||
if (err < 0) {
|
||||
@@ -398,27 +382,29 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
|
||||
goto create_err;
|
||||
}
|
||||
|
||||
if (!mptcp_pm_addr_families_match(sk, &local.addr, &addr_r)) {
|
||||
if (!mptcp_pm_addr_families_match(sk, &entry.addr, &addr_r)) {
|
||||
GENL_SET_ERR_MSG(info, "families mismatch");
|
||||
err = -EINVAL;
|
||||
goto create_err;
|
||||
}
|
||||
|
||||
err = mptcp_userspace_pm_append_new_local_addr(msk, &local, false);
|
||||
err = mptcp_userspace_pm_append_new_local_addr(msk, &entry, false);
|
||||
if (err < 0) {
|
||||
GENL_SET_ERR_MSG(info, "did not match address and id");
|
||||
goto create_err;
|
||||
}
|
||||
|
||||
local.addr = entry.addr;
|
||||
local.flags = entry.flags;
|
||||
local.ifindex = entry.ifindex;
|
||||
|
||||
lock_sock(sk);
|
||||
|
||||
err = __mptcp_subflow_connect(sk, &local.addr, &addr_r);
|
||||
|
||||
err = __mptcp_subflow_connect(sk, &local, &addr_r);
|
||||
release_sock(sk);
|
||||
|
||||
spin_lock_bh(&msk->pm.lock);
|
||||
if (err)
|
||||
mptcp_userspace_pm_delete_local_addr(msk, &local);
|
||||
mptcp_userspace_pm_delete_local_addr(msk, &entry);
|
||||
else
|
||||
msk->pm.subflows++;
|
||||
spin_unlock_bh(&msk->pm.lock);
|
||||
|
||||
Reference in New Issue
Block a user