Skip to content

Commit 92c932b

Browse files
committed
Merge branch 'mptcp-pm-userspace-misc-cleanups'
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>
2 parents dcacb36 + 5409fd6 commit 92c932b

File tree

3 files changed

+147
-203
lines changed

3 files changed

+147
-203
lines changed

net/mptcp/pm_netlink.c

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ static void remote_address(const struct sock_common *skc,
107107
#endif
108108
}
109109

110-
static bool lookup_subflow_by_saddr(const struct list_head *list,
111-
const struct mptcp_addr_info *saddr)
110+
bool mptcp_lookup_subflow_by_saddr(const struct list_head *list,
111+
const struct mptcp_addr_info *saddr)
112112
{
113113
struct mptcp_subflow_context *subflow;
114114
struct mptcp_addr_info cur;
@@ -1447,8 +1447,8 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info)
14471447
return ret;
14481448
}
14491449

1450-
static bool remove_anno_list_by_saddr(struct mptcp_sock *msk,
1451-
const struct mptcp_addr_info *addr)
1450+
bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk,
1451+
const struct mptcp_addr_info *addr)
14521452
{
14531453
struct mptcp_pm_add_entry *entry;
14541454

@@ -1476,7 +1476,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
14761476

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

1479-
ret = remove_anno_list_by_saddr(msk, addr);
1479+
ret = mptcp_remove_anno_list_by_saddr(msk, addr);
14801480
if (ret || force) {
14811481
spin_lock_bh(&msk->pm.lock);
14821482
if (ret) {
@@ -1520,7 +1520,7 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net,
15201520
}
15211521

15221522
lock_sock(sk);
1523-
remove_subflow = lookup_subflow_by_saddr(&msk->conn_list, addr);
1523+
remove_subflow = mptcp_lookup_subflow_by_saddr(&msk->conn_list, addr);
15241524
mptcp_pm_remove_anno_addr(msk, addr, remove_subflow &&
15251525
!(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT));
15261526

@@ -1633,36 +1633,6 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info)
16331633
return ret;
16341634
}
16351635

1636-
/* Called from the userspace PM only */
1637-
void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list)
1638-
{
1639-
struct mptcp_rm_list alist = { .nr = 0 };
1640-
struct mptcp_pm_addr_entry *entry;
1641-
int anno_nr = 0;
1642-
1643-
list_for_each_entry(entry, rm_list, list) {
1644-
if (alist.nr >= MPTCP_RM_IDS_MAX)
1645-
break;
1646-
1647-
/* only delete if either announced or matching a subflow */
1648-
if (remove_anno_list_by_saddr(msk, &entry->addr))
1649-
anno_nr++;
1650-
else if (!lookup_subflow_by_saddr(&msk->conn_list,
1651-
&entry->addr))
1652-
continue;
1653-
1654-
alist.ids[alist.nr++] = entry->addr.id;
1655-
}
1656-
1657-
if (alist.nr) {
1658-
spin_lock_bh(&msk->pm.lock);
1659-
msk->pm.add_addr_signaled -= anno_nr;
1660-
mptcp_pm_remove_addr(msk, &alist);
1661-
spin_unlock_bh(&msk->pm.lock);
1662-
}
1663-
}
1664-
1665-
/* Called from the in-kernel PM only */
16661636
static void mptcp_pm_flush_addrs_and_subflows(struct mptcp_sock *msk,
16671637
struct list_head *rm_list)
16681638
{
@@ -1671,11 +1641,11 @@ static void mptcp_pm_flush_addrs_and_subflows(struct mptcp_sock *msk,
16711641

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

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

0 commit comments

Comments
 (0)