Skip to content

Commit 06faa22

Browse files
geliangtangdavem330
authored andcommitted
mptcp: remove multi addresses and subflows in PM
This patch implemented the function to remove a list of addresses and subflows, named mptcp_nl_remove_addrs_list, which had a input parameter rm_list as the removing addresses list. In mptcp_nl_remove_addrs_list, traverse all the existing msk sockets to invoke mptcp_pm_remove_addrs_and_subflows to remove a list of addresses for each msk socket. In mptcp_pm_remove_addrs_and_subflows, traverse all the addresses in the removing addresses list, to find whether this address is in the conn_list or anno_list. If it is, put the address ID into the removing address list or the removing subflow list, and pass the two lists to mptcp_pm_remove_addr and mptcp_pm_remove_subflow. Signed-off-by: Geliang Tang <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ddd14bb commit 06faa22

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

net/mptcp/pm_netlink.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,54 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)
12001200
return ret;
12011201
}
12021202

1203+
static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
1204+
struct list_head *rm_list)
1205+
{
1206+
struct mptcp_rm_list alist = { .nr = 0 }, slist = { .nr = 0 };
1207+
struct mptcp_pm_addr_entry *entry;
1208+
1209+
list_for_each_entry(entry, rm_list, list) {
1210+
if (lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) &&
1211+
alist.nr < MPTCP_RM_IDS_MAX &&
1212+
slist.nr < MPTCP_RM_IDS_MAX) {
1213+
alist.ids[alist.nr++] = entry->addr.id;
1214+
slist.ids[slist.nr++] = entry->addr.id;
1215+
} else if (remove_anno_list_by_saddr(msk, &entry->addr) &&
1216+
alist.nr < MPTCP_RM_IDS_MAX) {
1217+
alist.ids[alist.nr++] = entry->addr.id;
1218+
}
1219+
}
1220+
1221+
if (alist.nr) {
1222+
spin_lock_bh(&msk->pm.lock);
1223+
mptcp_pm_remove_addr(msk, &alist);
1224+
spin_unlock_bh(&msk->pm.lock);
1225+
}
1226+
if (slist.nr)
1227+
mptcp_pm_remove_subflow(msk, &slist);
1228+
}
1229+
1230+
static void mptcp_nl_remove_addrs_list(struct net *net,
1231+
struct list_head *rm_list)
1232+
{
1233+
long s_slot = 0, s_num = 0;
1234+
struct mptcp_sock *msk;
1235+
1236+
if (list_empty(rm_list))
1237+
return;
1238+
1239+
while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
1240+
struct sock *sk = (struct sock *)msk;
1241+
1242+
lock_sock(sk);
1243+
mptcp_pm_remove_addrs_and_subflows(msk, rm_list);
1244+
release_sock(sk);
1245+
1246+
sock_put(sk);
1247+
cond_resched();
1248+
}
1249+
}
1250+
12031251
static void __flush_addrs(struct net *net, struct list_head *list)
12041252
{
12051253
while (!list_empty(list)) {

0 commit comments

Comments
 (0)