Skip to content

Commit

Permalink
Merge branch 'mptcp-pm-userspace-misc-cleanups'
Browse files Browse the repository at this point in the history
Matthieu Baerts says:

====================
mptcp: pm: userspace: misc cleanups

These cleanups lead the way to the unification of the path-manager
interfaces, and allow future extensions. The following patches are not
linked to each others, but are all related to the userspace
path-manager.

- Patch 1: add a new helper to reduce duplicated code.

- Patch 2: add a macro to iterate over the address list, clearer.

- Patch 3: reduce duplicated code to get the corresponding MPTCP socket.

- Patch 4: move userspace PM specific code out of the in-kernel one.

- Patch 5: pass an entry instead of a list with always one entry.

- Patch 6: uniform struct type used for the local addresses.

- Patch 7: simplify error handling.
====================

Link: https://patch.msgid.link/20241213-net-next-mptcp-pm-misc-cleanup-v1-0-ddb6d00109a8@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Dec 15, 2024
2 parents dcacb36 + 5409fd6 commit 92c932b
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 203 deletions.
46 changes: 8 additions & 38 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ static void remote_address(const struct sock_common *skc,
#endif
}

static bool lookup_subflow_by_saddr(const struct list_head *list,
const struct mptcp_addr_info *saddr)
bool mptcp_lookup_subflow_by_saddr(const struct list_head *list,
const struct mptcp_addr_info *saddr)
{
struct mptcp_subflow_context *subflow;
struct mptcp_addr_info cur;
Expand Down Expand Up @@ -1447,8 +1447,8 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
return ret;
}

static bool remove_anno_list_by_saddr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr)
bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr)
{
struct mptcp_pm_add_entry *entry;

Expand Down Expand Up @@ -1476,7 +1476,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,

list.ids[list.nr++] = mptcp_endp_get_local_id(msk, addr);

ret = remove_anno_list_by_saddr(msk, addr);
ret = mptcp_remove_anno_list_by_saddr(msk, addr);
if (ret || force) {
spin_lock_bh(&msk->pm.lock);
if (ret) {
Expand Down Expand Up @@ -1520,7 +1520,7 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net,
}

lock_sock(sk);
remove_subflow = lookup_subflow_by_saddr(&msk->conn_list, addr);
remove_subflow = mptcp_lookup_subflow_by_saddr(&msk->conn_list, addr);
mptcp_pm_remove_anno_addr(msk, addr, remove_subflow &&
!(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT));

Expand Down Expand Up @@ -1633,36 +1633,6 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info)
return ret;
}

/* Called from the userspace PM only */
void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list)
{
struct mptcp_rm_list alist = { .nr = 0 };
struct mptcp_pm_addr_entry *entry;
int anno_nr = 0;

list_for_each_entry(entry, rm_list, list) {
if (alist.nr >= MPTCP_RM_IDS_MAX)
break;

/* only delete if either announced or matching a subflow */
if (remove_anno_list_by_saddr(msk, &entry->addr))
anno_nr++;
else if (!lookup_subflow_by_saddr(&msk->conn_list,
&entry->addr))
continue;

alist.ids[alist.nr++] = entry->addr.id;
}

if (alist.nr) {
spin_lock_bh(&msk->pm.lock);
msk->pm.add_addr_signaled -= anno_nr;
mptcp_pm_remove_addr(msk, &alist);
spin_unlock_bh(&msk->pm.lock);
}
}

/* Called from the in-kernel PM only */
static void mptcp_pm_flush_addrs_and_subflows(struct mptcp_sock *msk,
struct list_head *rm_list)
{
Expand All @@ -1671,11 +1641,11 @@ static void mptcp_pm_flush_addrs_and_subflows(struct mptcp_sock *msk,

list_for_each_entry(entry, rm_list, list) {
if (slist.nr < MPTCP_RM_IDS_MAX &&
lookup_subflow_by_saddr(&msk->conn_list, &entry->addr))
mptcp_lookup_subflow_by_saddr(&msk->conn_list, &entry->addr))
slist.ids[slist.nr++] = mptcp_endp_get_local_id(msk, &entry->addr);

if (alist.nr < MPTCP_RM_IDS_MAX &&
remove_anno_list_by_saddr(msk, &entry->addr))
mptcp_remove_anno_list_by_saddr(msk, &entry->addr))
alist.ids[alist.nr++] = mptcp_endp_get_local_id(msk, &entry->addr);
}

Expand Down
Loading

0 comments on commit 92c932b

Please sign in to comment.