Commit 14da0d25 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'mptcp-fixes-and-cleanup-for-v6-7'

Mat Martineau says:

====================
mptcp: Fixes and cleanup for v6.7

This series includes three initial patches that we had queued in our
mptcp-net branch, but given the likely timing of net/net-next syncs this
week, the need to avoid introducing branch conflicts, and another batch
of net-next patches pending in the mptcp tree, the most practical route
is to send everything for net-next.

Patches 1 & 2 fix some intermittent selftest failures by adjusting timing.

Patch 3 removes an unneccessary userspace path manager restriction on
the removal of subflows with subflow ID 0.

The remainder of the patches are all cleanup or selftest changes:

Patches 4-8 clean up kernel code by removing unused parameters, making
more consistent use of existing helper functions, and reducing extra
casting of socket pointers.

Patch 9 removes an unused variable in a selftest script.

Patch 10 adds a little more detail to some mptcp_join test output.
====================

Link: https://lore.kernel.org/r/20231025-send-net-next-20231025-v1-0-db8f25f798eb@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 79fa2957 629b35a2
......@@ -184,7 +184,7 @@ void mptcp_pm_subflow_established(struct mptcp_sock *msk)
spin_unlock_bh(&pm->lock);
}
void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock *ssk,
void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
const struct mptcp_subflow_context *subflow)
{
struct mptcp_pm_data *pm = &msk->pm;
......
......@@ -152,6 +152,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
struct mptcp_pm_addr_entry addr_val;
struct mptcp_sock *msk;
int err = -EINVAL;
struct sock *sk;
u32 token_val;
if (!addr || !token) {
......@@ -167,6 +168,8 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
sk = (struct sock *)msk;
if (!mptcp_pm_is_userspace(msk)) {
GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
goto announce_err;
......@@ -190,7 +193,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
goto announce_err;
}
lock_sock((struct sock *)msk);
lock_sock(sk);
spin_lock_bh(&msk->pm.lock);
if (mptcp_pm_alloc_anno_list(msk, &addr_val.addr)) {
......@@ -200,11 +203,45 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info)
}
spin_unlock_bh(&msk->pm.lock);
release_sock((struct sock *)msk);
release_sock(sk);
err = 0;
announce_err:
sock_put((struct sock *)msk);
sock_put(sk);
return err;
}
static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,
struct genl_info *info)
{
struct mptcp_rm_list list = { .nr = 0 };
struct mptcp_subflow_context *subflow;
struct sock *sk = (struct sock *)msk;
bool has_id_0 = false;
int err = -EINVAL;
lock_sock(sk);
mptcp_for_each_subflow(msk, subflow) {
if (subflow->local_id == 0) {
has_id_0 = true;
break;
}
}
if (!has_id_0) {
GENL_SET_ERR_MSG(info, "address with id 0 not found");
goto remove_err;
}
list.ids[list.nr++] = 0;
spin_lock_bh(&msk->pm.lock);
mptcp_pm_remove_addr(msk, &list);
spin_unlock_bh(&msk->pm.lock);
err = 0;
remove_err:
release_sock(sk);
return err;
}
......@@ -217,6 +254,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
struct mptcp_sock *msk;
LIST_HEAD(free_list);
int err = -EINVAL;
struct sock *sk;
u32 token_val;
u8 id_val;
......@@ -234,12 +272,19 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
sk = (struct sock *)msk;
if (!mptcp_pm_is_userspace(msk)) {
GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
goto remove_err;
}
lock_sock((struct sock *)msk);
if (id_val == 0) {
err = mptcp_userspace_pm_remove_id_zero_address(msk, info);
goto remove_err;
}
lock_sock(sk);
list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
if (entry->addr.id == id_val) {
......@@ -250,7 +295,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
if (!match) {
GENL_SET_ERR_MSG(info, "address with specified id not found");
release_sock((struct sock *)msk);
release_sock(sk);
goto remove_err;
}
......@@ -258,15 +303,15 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
mptcp_pm_remove_addrs(msk, &free_list);
release_sock((struct sock *)msk);
release_sock(sk);
list_for_each_entry_safe(match, entry, &free_list, list) {
sock_kfree_s((struct sock *)msk, match, sizeof(*match));
sock_kfree_s(sk, match, sizeof(*match));
}
err = 0;
remove_err:
sock_put((struct sock *)msk);
sock_put(sk);
return err;
}
......@@ -296,6 +341,8 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
sk = (struct sock *)msk;
if (!mptcp_pm_is_userspace(msk)) {
GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
goto create_err;
......@@ -313,8 +360,6 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
goto create_err;
}
sk = (struct sock *)msk;
if (!mptcp_pm_addr_families_match(sk, &addr_l, &addr_r)) {
GENL_SET_ERR_MSG(info, "families mismatch");
err = -EINVAL;
......@@ -342,7 +387,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info)
spin_unlock_bh(&msk->pm.lock);
create_err:
sock_put((struct sock *)msk);
sock_put(sk);
return err;
}
......@@ -419,6 +464,8 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
return err;
}
sk = (struct sock *)msk;
if (!mptcp_pm_is_userspace(msk)) {
GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
goto destroy_err;
......@@ -448,7 +495,6 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
goto destroy_err;
}
sk = (struct sock *)msk;
lock_sock(sk);
ssk = mptcp_nl_find_ssk(msk, &addr_l, &addr_r);
if (ssk) {
......@@ -468,7 +514,7 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
release_sock(sk);
destroy_err:
sock_put((struct sock *)msk);
sock_put(sk);
return err;
}
......@@ -478,6 +524,7 @@ int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token,
{
struct mptcp_sock *msk;
int ret = -EINVAL;
struct sock *sk;
u32 token_val;
token_val = nla_get_u32(token);
......@@ -486,6 +533,8 @@ int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token,
if (!msk)
return ret;
sk = (struct sock *)msk;
if (!mptcp_pm_is_userspace(msk))
goto set_flags_err;
......@@ -493,11 +542,11 @@ int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token,
rem->addr.family == AF_UNSPEC)
goto set_flags_err;
lock_sock((struct sock *)msk);
lock_sock(sk);
ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc->addr, &rem->addr, bkup);
release_sock((struct sock *)msk);
release_sock(sk);
set_flags_err:
sock_put((struct sock *)msk);
sock_put(sk);
return ret;
}
......@@ -1267,7 +1267,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
* queue management operation, to avoid breaking the ext <->
* SSN association set here
*/
mpext = skb_ext_find(skb, SKB_EXT_MPTCP);
mpext = mptcp_get_ext(skb);
if (!mptcp_skb_can_collapse_to(data_seq, skb, mpext)) {
TCP_SKB_CB(skb)->eor = 1;
goto alloc_skb;
......@@ -1289,7 +1289,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
i = skb_shinfo(skb)->nr_frags;
reuse_skb = false;
mpext = skb_ext_find(skb, SKB_EXT_MPTCP);
mpext = mptcp_get_ext(skb);
}
/* Zero window and all data acked? Probe. */
......@@ -2490,7 +2490,7 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
/* subflow aborted before reaching the fully_established status
* attempt the creation of the next subflow
*/
mptcp_pm_subflow_check_next(mptcp_sk(sk), ssk, subflow);
mptcp_pm_subflow_check_next(mptcp_sk(sk), subflow);
__mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_PUSH);
}
......
......@@ -888,7 +888,7 @@ bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk);
void mptcp_pm_connection_closed(struct mptcp_sock *msk);
void mptcp_pm_subflow_established(struct mptcp_sock *msk);
bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk);
void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct sock *ssk,
void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
const struct mptcp_subflow_context *subflow);
void mptcp_pm_add_addr_received(const struct sock *ssk,
const struct mptcp_addr_info *addr);
......@@ -1065,7 +1065,7 @@ static inline bool mptcp_check_fallback(const struct sock *sk)
static inline void __mptcp_do_fallback(struct mptcp_sock *msk)
{
if (test_bit(MPTCP_FALLBACK_DONE, &msk->flags)) {
if (__mptcp_check_fallback(msk)) {
pr_debug("TCP fallback already done (msk=%p)", msk);
return;
}
......
......@@ -916,7 +916,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
mptcp_pm_get_local_addr_max(msk);
}
if (test_bit(MPTCP_FALLBACK_DONE, &msk->flags))
if (__mptcp_check_fallback(msk))
flags |= MPTCP_INFO_FLAG_FALLBACK;
if (READ_ONCE(msk->can_ack))
flags |= MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED;
......
......@@ -1770,7 +1770,10 @@ chk_rm_nr()
# in case of simult flush, the subflow removal count on each side is
# unreliable
count=$((count + cnt))
[ "$count" != "$rm_subflow_nr" ] && suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]"
if [ "$count" != "$rm_subflow_nr" ]; then
suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]"
extra_msg="$extra_msg simult"
fi
if [ $count -ge "$rm_subflow_nr" ] && \
[ "$count" -le "$((rm_subflow_nr *2 ))" ]; then
print_ok "$suffix"
......@@ -3289,6 +3292,7 @@ userspace_pm_rm_sf_addr_ns1()
local addr=$1
local id=$2
local tk sp da dp
local cnt_addr cnt_sf
tk=$(grep "type:1," "$evts_ns1" |
sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q')
......@@ -3298,11 +3302,13 @@ userspace_pm_rm_sf_addr_ns1()
sed -n 's/.*\(daddr6:\)\([0-9a-f:.]*\).*$/\2/p;q')
dp=$(grep "type:10" "$evts_ns1" |
sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q')
cnt_addr=$(rm_addr_count ${ns1})
cnt_sf=$(rm_sf_count ${ns1})
ip netns exec $ns1 ./pm_nl_ctl rem token $tk id $id
ip netns exec $ns1 ./pm_nl_ctl dsf lip "::ffff:$addr" \
lport $sp rip $da rport $dp token $tk
wait_rm_addr $ns1 1
wait_rm_sf $ns1 1
wait_rm_addr $ns1 "${cnt_addr}"
wait_rm_sf $ns1 "${cnt_sf}"
}
userspace_pm_add_sf()
......@@ -3324,17 +3330,20 @@ userspace_pm_rm_sf_addr_ns2()
local addr=$1
local id=$2
local tk da dp sp
local cnt_addr cnt_sf
tk=$(sed -n 's/.*\(token:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
da=$(sed -n 's/.*\(daddr4:\)\([0-9.]*\).*$/\2/p;q' "$evts_ns2")
dp=$(sed -n 's/.*\(dport:\)\([[:digit:]]*\).*$/\2/p;q' "$evts_ns2")
sp=$(grep "type:10" "$evts_ns2" |
sed -n 's/.*\(sport:\)\([[:digit:]]*\).*$/\2/p;q')
cnt_addr=$(rm_addr_count ${ns2})
cnt_sf=$(rm_sf_count ${ns2})
ip netns exec $ns2 ./pm_nl_ctl rem token $tk id $id
ip netns exec $ns2 ./pm_nl_ctl dsf lip $addr lport $sp \
rip $da rport $dp token $tk
wait_rm_addr $ns2 1
wait_rm_sf $ns2 1
wait_rm_addr $ns2 "${cnt_addr}"
wait_rm_sf $ns2 "${cnt_sf}"
}
userspace_tests()
......@@ -3417,7 +3426,7 @@ userspace_tests()
continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
set_userspace_pm $ns1
pm_nl_set_limits $ns2 1 1
speed=10 \
speed=5 \
run_tests $ns1 $ns2 10.0.1.1 &
local tests_pid=$!
wait_mpj $ns1
......@@ -3438,7 +3447,7 @@ userspace_tests()
continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
set_userspace_pm $ns2
pm_nl_set_limits $ns1 0 1
speed=10 \
speed=5 \
run_tests $ns1 $ns2 10.0.1.1 &
local tests_pid=$!
wait_mpj $ns2
......
......@@ -11,7 +11,6 @@ cout=""
ksft_skip=4
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
mptcp_connect=""
iptables="iptables"
ip6tables="ip6tables"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment