Skip to content

Commit

Permalink
mptcp: flush userspace addrs list
Browse files Browse the repository at this point in the history
This patch adds a new function mptcp_userspace_pm_flush_addrs_list() to
free the userspace local addresses list. Invoke it when flushing addresses
from netlink commands.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Nov 1, 2023
1 parent cc1777f commit 3e51741
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,8 @@ int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info)
mptcp_nl_remove_addrs_list(sock_net(skb->sk), &free_list);
synchronize_rcu();
__flush_addrs(&free_list);

mptcp_userspace_pm_flush_addrs_list(sock_net(skb->sk));
return 0;
}

Expand Down
19 changes: 19 additions & 0 deletions net/mptcp/pm_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,22 @@ int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token,
sock_put(sk);
return ret;
}

void mptcp_userspace_pm_flush_addrs_list(struct net *net)
{
long s_slot = 0, s_num = 0;
struct mptcp_sock *msk;

while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
struct sock *sk = (struct sock *)msk;

if (mptcp_pm_is_userspace(msk)) {
lock_sock(sk);
mptcp_free_local_addr_list(msk);
release_sock(sk);
}

sock_put(sk);
cond_resched();
}
}
1 change: 1 addition & 0 deletions net/mptcp/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
struct list_head *rm_list);

void mptcp_free_local_addr_list(struct mptcp_sock *msk);
void mptcp_userspace_pm_flush_addrs_list(struct net *net);

void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
const struct sock *ssk, gfp_t gfp);
Expand Down

0 comments on commit 3e51741

Please sign in to comment.