From patchwork Thu Sep 24 00:29:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 260295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD0DAC4727E for ; Thu, 24 Sep 2020 00:39:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81C742145D for ; Thu, 24 Sep 2020 00:39:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CDI6DgVv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726743AbgIXAjE (ORCPT ); Wed, 23 Sep 2020 20:39:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgIXAjE (ORCPT ); Wed, 23 Sep 2020 20:39:04 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 478E0C0613CE; Wed, 23 Sep 2020 17:39:04 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id y14so766039pgf.12; Wed, 23 Sep 2020 17:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=zcmnEPq+YTalL7s+yxxifbO2I4SU9mxShMOziACbhrU=; b=CDI6DgVvdZITW/kHdY3bqx/ylC9XVOxejYxAGekPfcsWLUd9rOOhSrqcaIg9gvk6eC yR3s0vtKNvgBWALxKgJpeNPlSfh1UxkfDXlDp4csHhyngzCCaaQ8YiwEcYSSMzz8S1Th iawszw9zZncWOyfCPndgql6dG2bljBQRtgEg7Icagj+4xO0bf+YNlwwIr5lsd4Be0C+z Da5/ERSNUH6d9mbDPbSVpmBp0oS/W5Ziw4TuAT9qGOSKd8FBwq5gZqhQUHC7iZPsVgIm LzwJb0eIJBki9z2VVJwlvkqWm/3qy5Q4WVxqXu6Mj3oifR9de9JYIZfcFipBSwU8KLRW MeSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=zcmnEPq+YTalL7s+yxxifbO2I4SU9mxShMOziACbhrU=; b=l/SoSEg7BlSuhumJrLqF/AynP/sTLJ3xFuzv3shHBzrBYbGWku+d9MPCGWtOYZhz2P DE/qa2NwpTdi7t2HcL5zsw86fDn0fPsdKzfH3f732IKaYtxtckDFyB632eupraHNdCum tWmKlEOhaiEUWmxhAwBITDFucY9Olg6Oqbq6TShj9V9OCz2GCwrjrtwH+EW0Hr8jhVrn rR03/mdyRbgXXYwwrOkKM+0jhNFq7ZbE+EJWtzUBLwgELi+NGlocYQSMZ+AoF/8fWkLU nMY5W8Yv+adm0O9wE7PZLMPv0hp/qjXGKYzdkaT9eSpdoNOhmz5/ud2/bub6/E12H9nC 2VbQ== X-Gm-Message-State: AOAM531zgpaFVQH3ROz3CF3y3FhBbSe2KtdDgOhCNmDTslwTufUkSCmj L3/9f+WrUKhuSgfQceiOTbs= X-Google-Smtp-Source: ABdhPJy5kJhNviR72dA9ytVfXRwvJ26FP9vT0W597nnn5TVIH5bAaFUQcGUy3ETYVc2s9XjvCPtUCg== X-Received: by 2002:a05:6a00:1481:b029:142:2501:35d7 with SMTP id v1-20020a056a001481b0290142250135d7mr2211221pfu.55.1600907943791; Wed, 23 Sep 2020 17:39:03 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id v8sm900479pgg.58.2020.09.23.17.39.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2020 17:39:03 -0700 (PDT) From: Geliang Tang To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Jakub Kicinski Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.01.org, linux-kernel@vger.kernel.org Subject: [MPTCP][PATCH net-next 03/16] mptcp: add the incoming RM_ADDR support Date: Thu, 24 Sep 2020 08:29:49 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch added the RM_ADDR option parsing logic: We parsed the incoming options to find if the rm_addr option is received, and called mptcp_pm_rm_addr_received to schedule PM work to a new status, named MPTCP_PM_RM_ADDR_RECEIVED. PM work got this status, and called mptcp_pm_nl_rm_addr_received to handle it. In mptcp_pm_nl_rm_addr_received, we closed the subflow matching the rm_id, and updated PM counter. Suggested-by: Matthieu Baerts Suggested-by: Paolo Abeni Suggested-by: Mat Martineau Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau --- net/mptcp/options.c | 5 +++++ net/mptcp/pm.c | 12 ++++++++++++ net/mptcp/pm_netlink.c | 34 ++++++++++++++++++++++++++++++++++ net/mptcp/protocol.c | 12 ++++++++---- net/mptcp/protocol.h | 7 +++++++ 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index bbc124876417..a52a05effac9 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -888,6 +888,11 @@ void mptcp_incoming_options(struct sock *sk, struct sk_buff *skb, mp_opt.add_addr = 0; } + if (mp_opt.rm_addr) { + mptcp_pm_rm_addr_received(msk, mp_opt.rm_id); + mp_opt.rm_addr = 0; + } + if (!mp_opt.dss) return; diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 81b07ae213b9..558462d87eb3 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -149,6 +149,18 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, spin_unlock_bh(&pm->lock); } +void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id) +{ + struct mptcp_pm_data *pm = &msk->pm; + + pr_debug("msk=%p remote_id=%d", msk, rm_id); + + spin_lock_bh(&pm->lock); + mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED); + pm->rm_id = rm_id; + spin_unlock_bh(&pm->lock); +} + /* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining, diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index b4a9624d7bf2..4124bc581308 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -268,6 +268,40 @@ void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) spin_lock_bh(&msk->pm.lock); } +void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk) +{ + struct mptcp_subflow_context *subflow, *tmp; + struct sock *sk = (struct sock *)msk; + + pr_debug("address rm_id %d", msk->pm.rm_id); + + if (!msk->pm.rm_id) + return; + + if (list_empty(&msk->conn_list)) + return; + + list_for_each_entry_safe(subflow, tmp, &msk->conn_list, node) { + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); + int how = RCV_SHUTDOWN | SEND_SHUTDOWN; + long timeout = 0; + + if (msk->pm.rm_id != subflow->remote_id) + continue; + + spin_unlock_bh(&msk->pm.lock); + mptcp_subflow_shutdown(sk, ssk, how); + __mptcp_close_ssk(sk, ssk, subflow, timeout); + spin_lock_bh(&msk->pm.lock); + + msk->pm.add_addr_accepted--; + msk->pm.subflows--; + WRITE_ONCE(msk->pm.accept_addr, true); + + break; + } +} + static bool address_use_port(struct mptcp_pm_addr_entry *entry) { return (entry->addr.flags & diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 386cd4e60250..26b9233f247c 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1652,9 +1652,9 @@ static struct sock *mptcp_subflow_get_retrans(const struct mptcp_sock *msk) * so we need to use tcp_close() after detaching them from the mptcp * parent socket. */ -static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, - struct mptcp_subflow_context *subflow, - long timeout) +void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, + struct mptcp_subflow_context *subflow, + long timeout) { struct socket *sock = READ_ONCE(ssk->sk_socket); @@ -1685,6 +1685,10 @@ static void pm_work(struct mptcp_sock *msk) pm->status &= ~BIT(MPTCP_PM_ADD_ADDR_RECEIVED); mptcp_pm_nl_add_addr_received(msk); } + if (pm->status & BIT(MPTCP_PM_RM_ADDR_RECEIVED)) { + pm->status &= ~BIT(MPTCP_PM_RM_ADDR_RECEIVED); + mptcp_pm_nl_rm_addr_received(msk); + } if (pm->status & BIT(MPTCP_PM_ESTABLISHED)) { pm->status &= ~BIT(MPTCP_PM_ESTABLISHED); mptcp_pm_nl_fully_established(msk); @@ -1846,7 +1850,7 @@ static void mptcp_cancel_work(struct sock *sk) sock_put(sk); } -static void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how) +void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how) { lock_sock(ssk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 8929b0c7660a..837e01057544 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -152,6 +152,7 @@ struct mptcp_addr_info { enum mptcp_pm_status { MPTCP_PM_ADD_ADDR_RECEIVED, + MPTCP_PM_RM_ADDR_RECEIVED, MPTCP_PM_ESTABLISHED, MPTCP_PM_SUBFLOW_ESTABLISHED, }; @@ -362,6 +363,10 @@ void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, struct mptcp_options_received *mp_opt); bool mptcp_subflow_data_available(struct sock *sk); void __init mptcp_subflow_init(void); +void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how); +void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, + struct mptcp_subflow_context *subflow, + long timeout); /* called with sk socket lock held */ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, @@ -434,6 +439,7 @@ void mptcp_pm_subflow_established(struct mptcp_sock *msk, void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id); void mptcp_pm_add_addr_received(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); +void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id); int mptcp_pm_announce_addr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr); @@ -468,6 +474,7 @@ void mptcp_pm_nl_data_init(struct mptcp_sock *msk); void mptcp_pm_nl_fully_established(struct mptcp_sock *msk); void mptcp_pm_nl_subflow_established(struct mptcp_sock *msk); void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk); +void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk); int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); static inline struct mptcp_ext *mptcp_get_ext(struct sk_buff *skb) From patchwork Thu Sep 24 00:29:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 260294 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE5C8C2D0A8 for ; Thu, 24 Sep 2020 00:41:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 509F121D91 for ; Thu, 24 Sep 2020 00:41:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hSZja3OA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbgIXAlV (ORCPT ); Wed, 23 Sep 2020 20:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgIXAlV (ORCPT ); Wed, 23 Sep 2020 20:41:21 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A005C0613CE; Wed, 23 Sep 2020 17:41:19 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id bw23so686469pjb.2; Wed, 23 Sep 2020 17:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=vTJMIFxDOIU7wqnMWdIC+M4ZbcMyOe0P1cQikjjtIn4=; b=hSZja3OAsUUxZyB9Sk0ayT5HHHFNU6l24HQahtt32Pp0m74U9vMgRvVu//ryucKKJP Fb0soNDD5BJBOcuvId5hAIIwrjzeDqVe4+FMnjWX6+IudMBK6INtRiE+ylWUAAWIDBuk fWKR9C1goWD42/jBS7CAQV08LWWAwvx2YLoPjaA0TW1aZmzUVed2UpBmZAq2LL+J6GDp 2NxasnqyxVgO799GDFuZjVv/UaNhByrUkKBNIUElOgwK7mRa/p21OS/smwG5Q5OBjS7I pzgE7ueCWSm2MfZHRjDEsQRqWQdR+xw//Lnr0fp2zVvFYQxETjm9RJdjZj68e3MdT7Kf qXWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=vTJMIFxDOIU7wqnMWdIC+M4ZbcMyOe0P1cQikjjtIn4=; b=ks3AtzxiXU83jTNScOJJl0UMHJ/x2Nx5QlXmcbRwZyUewzSfTlZNUwgYzwruEZo4U1 GSduZ/LBJXCxmMksJnG9JYAzfyaG/C595dWkjXfd5FtEBPJdPy91gzJYE0n9rHUjP7sl wqxA4iWmI3gIATkfgkiNf4tOYKDSBiexKw3IdDfsuVsWMxWkNfWPKVAR3YRyZB8yZXy/ Nh6Z8KUQMUtUBoUQGY+VpMamO4S/mj5KcrImi/miGK8JwfYiU0zLeZp8gD8iL9j7HrKk 6o5bdoe49AWPDJF544b45Atcnm9gXNCVuEc3r5Akn+Mar34w77svl2BftDL5svQcUs3V Cm2A== X-Gm-Message-State: AOAM530awF69c+XV0G9v7RbV4Mthk/bT0PDkjhQ0GmXetdhnFexFr6iq pEQ7oSECFWRGR1dHkM/qq+k= X-Google-Smtp-Source: ABdhPJy6lpM5/qrkXqZDShfpd8qwFPyDbRUy99rRszuqTygP6C53sbvG77yFh3quBUZzLlL6ZQ1law== X-Received: by 2002:a17:902:b410:b029:d1:920c:c22b with SMTP id x16-20020a170902b410b02900d1920cc22bmr2212867plr.28.1600908079000; Wed, 23 Sep 2020 17:41:19 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id q21sm875659pgt.48.2020.09.23.17.41.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2020 17:41:18 -0700 (PDT) From: Geliang Tang To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Jakub Kicinski Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.01.org, linux-kernel@vger.kernel.org Subject: [MPTCP][PATCH net-next 04/16] mptcp: send out ADD_ADDR with echo flag Date: Thu, 24 Sep 2020 08:29:50 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When the ADD_ADDR suboption has been received, we need to send out the same ADD_ADDR suboption with echo-flag=1, and no HMAC. Suggested-by: Mat Martineau Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/options.c | 27 ++++++++++++++++----------- net/mptcp/pm.c | 18 +++++++++--------- net/mptcp/pm_netlink.c | 4 +++- net/mptcp/protocol.h | 6 ++++-- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index a52a05effac9..a41996e6c6d7 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -242,7 +242,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, mp_opt->add_addr = 1; mp_opt->port = 0; mp_opt->addr_id = *ptr++; - pr_debug("ADD_ADDR: id=%d", mp_opt->addr_id); + pr_debug("ADD_ADDR: id=%d, echo=%d", mp_opt->addr_id, mp_opt->echo); if (mp_opt->family == MPTCP_ADDR_IPVERSION_4) { memcpy((u8 *)&mp_opt->addr.s_addr, (u8 *)ptr, 4); ptr += 4; @@ -579,10 +579,11 @@ static bool mptcp_established_options_add_addr(struct sock *sk, struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); struct mptcp_sock *msk = mptcp_sk(subflow->conn); struct mptcp_addr_info saddr; + bool echo; int len; if (!mptcp_pm_should_add_signal(msk) || - !(mptcp_pm_add_addr_signal(msk, remaining, &saddr))) + !(mptcp_pm_add_addr_signal(msk, remaining, &saddr, &echo))) return false; len = mptcp_add_addr_len(saddr.family); @@ -594,22 +595,26 @@ static bool mptcp_established_options_add_addr(struct sock *sk, if (saddr.family == AF_INET) { opts->suboptions |= OPTION_MPTCP_ADD_ADDR; opts->addr = saddr.addr; - opts->ahmac = add_addr_generate_hmac(msk->local_key, - msk->remote_key, - opts->addr_id, - &opts->addr); + if (!echo) { + opts->ahmac = add_addr_generate_hmac(msk->local_key, + msk->remote_key, + opts->addr_id, + &opts->addr); + } } #if IS_ENABLED(CONFIG_MPTCP_IPV6) else if (saddr.family == AF_INET6) { opts->suboptions |= OPTION_MPTCP_ADD_ADDR6; opts->addr6 = saddr.addr6; - opts->ahmac = add_addr6_generate_hmac(msk->local_key, - msk->remote_key, - opts->addr_id, - &opts->addr6); + if (!echo) { + opts->ahmac = add_addr6_generate_hmac(msk->local_key, + msk->remote_key, + opts->addr_id, + &opts->addr6); + } } #endif - pr_debug("addr_id=%d, ahmac=%llu", opts->addr_id, opts->ahmac); + pr_debug("addr_id=%d, ahmac=%llu, echo=%d", opts->addr_id, opts->ahmac, echo); return true; } diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 558462d87eb3..39a76620d0a5 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -13,11 +13,13 @@ /* path manager command handlers */ int mptcp_pm_announce_addr(struct mptcp_sock *msk, - const struct mptcp_addr_info *addr) + const struct mptcp_addr_info *addr, + bool echo) { pr_debug("msk=%p, local_id=%d", msk, addr->id); msk->pm.local = *addr; + WRITE_ONCE(msk->pm.add_addr_echo, echo); WRITE_ONCE(msk->pm.add_addr_signal, true); return 0; } @@ -135,15 +137,11 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, pr_debug("msk=%p remote_id=%d accept=%d", msk, addr->id, READ_ONCE(pm->accept_addr)); - /* avoid acquiring the lock if there is no room for fouther addresses */ - if (!READ_ONCE(pm->accept_addr)) - return; - spin_lock_bh(&pm->lock); - /* be sure there is something to signal re-checking under PM lock */ - if (READ_ONCE(pm->accept_addr) && - mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) + if (!READ_ONCE(pm->accept_addr)) + mptcp_pm_announce_addr(msk, addr, true); + else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) pm->remote = *addr; spin_unlock_bh(&pm->lock); @@ -164,7 +162,7 @@ void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id) /* path manager helpers */ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining, - struct mptcp_addr_info *saddr) + struct mptcp_addr_info *saddr, bool *echo) { int ret = false; @@ -178,6 +176,7 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining, goto out_unlock; *saddr = msk->pm.local; + *echo = READ_ONCE(msk->pm.add_addr_echo); WRITE_ONCE(msk->pm.add_addr_signal, false); ret = true; @@ -226,6 +225,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk) WRITE_ONCE(msk->pm.rm_addr_signal, false); WRITE_ONCE(msk->pm.accept_addr, false); WRITE_ONCE(msk->pm.accept_subflow, false); + WRITE_ONCE(msk->pm.add_addr_echo, false); msk->pm.status = 0; spin_lock_init(&msk->pm.lock); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 4124bc581308..f6f96bc2046b 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -198,7 +198,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) if (local) { msk->pm.add_addr_signaled++; - mptcp_pm_announce_addr(msk, &local->addr); + mptcp_pm_announce_addr(msk, &local->addr, false); } else { /* pick failed, avoid fourther attempts later */ msk->pm.local_addr_used = msk->pm.add_addr_signal_max; @@ -266,6 +266,8 @@ void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) spin_unlock_bh(&msk->pm.lock); __mptcp_subflow_connect((struct sock *)msk, &local, &remote); spin_lock_bh(&msk->pm.lock); + + mptcp_pm_announce_addr(msk, &remote, true); } void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 837e01057544..ba253a6947b0 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -169,6 +169,7 @@ struct mptcp_pm_data { bool work_pending; bool accept_addr; bool accept_subflow; + bool add_addr_echo; u8 add_addr_signaled; u8 add_addr_accepted; u8 local_addr_used; @@ -442,7 +443,8 @@ void mptcp_pm_add_addr_received(struct mptcp_sock *msk, void mptcp_pm_rm_addr_received(struct mptcp_sock *msk, u8 rm_id); int mptcp_pm_announce_addr(struct mptcp_sock *msk, - const struct mptcp_addr_info *addr); + const struct mptcp_addr_info *addr, + bool echo); int mptcp_pm_remove_addr(struct mptcp_sock *msk, u8 local_id); int mptcp_pm_remove_subflow(struct mptcp_sock *msk, u8 remote_id); @@ -464,7 +466,7 @@ static inline unsigned int mptcp_add_addr_len(int family) } bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining, - struct mptcp_addr_info *saddr); + struct mptcp_addr_info *saddr, bool *echo); bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, u8 *rm_id); int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); From patchwork Thu Sep 24 00:29:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 260293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1F14C2D0A8 for ; Thu, 24 Sep 2020 00:48:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B63C923119 for ; Thu, 24 Sep 2020 00:48:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qazrzgmE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726714AbgIXAsB (ORCPT ); Wed, 23 Sep 2020 20:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgIXAsB (ORCPT ); Wed, 23 Sep 2020 20:48:01 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D674CC0613CE; Wed, 23 Sep 2020 17:48:00 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id d13so798803pgl.6; Wed, 23 Sep 2020 17:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=IeSXMBVcVqOJv+ick5hpJlRuUlPUh1dEBXZ1ahX+5iQ=; b=qazrzgmEz80xNxddpR8Ymwev6mBT9p1Gd//S9xmd/LufiF1CERFfGj5PtdccwRv78S 1sP3FOfQWXHM4Wt9V+qFTib5icZjrlDuKUeqFXGgfwDjpqy53DIHwm3taMwi1tUXN3aR EXCPBtVQgDBVhn7p+jnj2C5Tn//tntVHn5YSmNMPl8CgmocUlufQk0+L4EU8oeAi08xf WN1q9ZEz570rnwvv8+nyeLjlJNdf24x2n68udhYpRECVn/6+syTGiyz7euVG2Y/jQT4W CbwC0MPjz4KqHRwKcGKgRP2l0Pv3cvj6+iw6TZc2hx7XksY9YHZpWmtLme4957hBRfG0 WXYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=IeSXMBVcVqOJv+ick5hpJlRuUlPUh1dEBXZ1ahX+5iQ=; b=s8B3/ZApwoj5312790VdcAyI9uxXQznyGA7jpbzkwQqQRK+upDpv8dcTIx5zypYdHd F95Su+UlgfLuxQujfrMmjZkwo++AiwVSRvoBArc9/m4zDUjqkVWvia1hH+g6HZy7vZTr Njtf4aV0XIZq5IZnYEHDJQsKqMAR/2NsRMLg5gBmISSEjo71cQB5/bDkxZPLiNI8fmjS TrSKntjJgMKsAaRTmPaWJtL0e1ssi5F3XNECMv8Ov01GcXd7bKCjBjtsCu5vRzjkiidN 3+sMcXcxgYW4RIKTSoOazkEqNlRUyq4Ab7dOn2zVr5oBTUw9yHfehSiRLuUp8v2ZNM7l EJQA== X-Gm-Message-State: AOAM533B/MP8pajzu/1gd4OtjR5kniMavHLAqPA4pbmnLolEsgK6Kr74 yveVb2g2cBWbgSE3Cj4Qdz0= X-Google-Smtp-Source: ABdhPJwTXwvZmpuuH0Dohsw8+m3zb/qXZWYKtOXMNtxNyDebN16JVnpjXeNu6RXcgz8x+zxpLvk3cA== X-Received: by 2002:a62:3706:0:b029:142:2501:39e5 with SMTP id e6-20020a6237060000b0290142250139e5mr2346642pfa.52.1600908480415; Wed, 23 Sep 2020 17:48:00 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id v1sm5724363pjn.1.2020.09.23.17.47.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2020 17:47:59 -0700 (PDT) From: Geliang Tang To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Jakub Kicinski Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.01.org, linux-kernel@vger.kernel.org Subject: [MPTCP][PATCH net-next 07/16] mptcp: add accept_subflow re-check Date: Thu, 24 Sep 2020 08:29:53 +0800 Message-Id: <98bcc56283c482c294bd6ae9ce1476821ddc6837.1600853093.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: <7b0898eff793dde434464b5fac2629739d9546fd.1600853093.git.geliangtang@gmail.com> References: <430dd4f9c241ae990a5cfa6809276b36993ce91b.1600853093.git.geliangtang@gmail.com> <7b0898eff793dde434464b5fac2629739d9546fd.1600853093.git.geliangtang@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The re-check of pm->accept_subflow with pm->lock held was missing, this patch fixed it. Suggested-by: Mat Martineau Reviewed-by: Mat Martineau Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 39a76620d0a5..be4157279e15 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -48,7 +48,7 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, int server_side) bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) { struct mptcp_pm_data *pm = &msk->pm; - int ret; + int ret = 0; pr_debug("msk=%p subflows=%d max=%d allow=%d", msk, pm->subflows, pm->subflows_max, READ_ONCE(pm->accept_subflow)); @@ -58,9 +58,11 @@ bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) return false; spin_lock_bh(&pm->lock); - ret = pm->subflows < pm->subflows_max; - if (ret && ++pm->subflows == pm->subflows_max) - WRITE_ONCE(pm->accept_subflow, false); + if (READ_ONCE(pm->accept_subflow)) { + ret = pm->subflows < pm->subflows_max; + if (ret && ++pm->subflows == pm->subflows_max) + WRITE_ONCE(pm->accept_subflow, false); + } spin_unlock_bh(&pm->lock); return ret; From patchwork Thu Sep 24 00:29:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 260292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30314C4727E for ; Thu, 24 Sep 2020 00:54:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE6902311E for ; Thu, 24 Sep 2020 00:54:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nogsSSOC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgIXAyq (ORCPT ); Wed, 23 Sep 2020 20:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbgIXAyq (ORCPT ); Wed, 23 Sep 2020 20:54:46 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17DBC0613CE; Wed, 23 Sep 2020 17:54:45 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id u3so650795pjr.3; Wed, 23 Sep 2020 17:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=h+H677fkWThjqWv2k9jNPc3lZ9kp0KrAb1xLKLcz9BA=; b=nogsSSOCdMjFc+PToVlsGPxrG2nVDj10fZT+0VlxtD5cG8yHeHti53rneht0xkgFXG wv5fFgsDEXCs8eJbe8zvFowZe/2oGnz6Vq7+FmBIPA6ysZyRLlr6yADru/LdVJcjZnW3 X516h6RfP6YOJwn5v1X4dVqucD5u2SUNbgib3JlGQ4W2RjPKayAdlMeRoZo/PPfg0aqR JR74cnFn2On2ZbpYx2/9yzO828uFMOmm5mR1DFiSzLKZk6/Y8YWPZd5NEZbpyhf5b1Pw YbQaQdSoQt9rSV59chUmWRHZK2TDbPXE3U5HI32ZDOSQUwdF0cs9BgDpipBmbxBVbn8d f+Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=h+H677fkWThjqWv2k9jNPc3lZ9kp0KrAb1xLKLcz9BA=; b=hkaypzBLdmVWUJcVS49RLXLb2WXbtkxSUVSN9dqa5MfpORJNkrdSgl6f/df3Y3nyFh 8gJC6iM5Lm5oL8U6Ah4bYZcDIA0eQdcUEWuilBRZtkJFxcSvXS+eXY0kaCEFJKWZixNn AlH8IWa6N1ws/7KKbJNLQRzU6AJAZ93xbtMCptHn79VR2KS6F7A4CzUHkf1yIB/BY8+a Hh1dTgJXh8sgwdCwujbIVRS3uvvMWmU9+uMIVuKLJY4IlsupbNyg1qXOkUOEiFwytXiI bfCQbXEI/re1qZQGwp+cSBVckqvQdle0nlYnMluSYIAw8YaeE+5HXBWs8PbPk6Hv1Vhx agYg== X-Gm-Message-State: AOAM533YXvl1HuT4ipNuxWCl8QKFnU79aNcIpiqpODiy1PFFi97L40qz Leoa1SrSpIpPrM+kLRo4rTQ= X-Google-Smtp-Source: ABdhPJzwTqKFjG9yq7G0NjnVK48XB1bjfHCLpowt1E9AvBVyhNuDgX3eXiWUDAYYkJMMTN9h7zd3+Q== X-Received: by 2002:a17:90b:905:: with SMTP id bo5mr1599772pjb.73.1600908885602; Wed, 23 Sep 2020 17:54:45 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id r1sm876431pgl.66.2020.09.23.17.54.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2020 17:54:44 -0700 (PDT) From: Geliang Tang To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Jakub Kicinski Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.01.org, linux-kernel@vger.kernel.org Subject: [MPTCP][PATCH net-next 10/16] mptcp: add RM_ADDR related mibs Date: Thu, 24 Sep 2020 08:29:56 +0800 Message-Id: <644420f22ba6f0b9f9f3509c081d8d639ff4bbf3.1600853093.git.geliangtang@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: <5018fd495529e058ea866e8d8edbe0bb98ec733a.1600853093.git.geliangtang@gmail.com> References: <430dd4f9c241ae990a5cfa6809276b36993ce91b.1600853093.git.geliangtang@gmail.com> <7b0898eff793dde434464b5fac2629739d9546fd.1600853093.git.geliangtang@gmail.com> <98bcc56283c482c294bd6ae9ce1476821ddc6837.1600853093.git.geliangtang@gmail.com> <37f2befac450fb46367f62446a4bb2c9d0a5986a.1600853093.git.geliangtang@gmail.com> <5018fd495529e058ea866e8d8edbe0bb98ec733a.1600853093.git.geliangtang@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch added two new mibs for RM_ADDR, named MPTCP_MIB_RMADDR and MPTCP_MIB_RMSUBFLOW, when the RM_ADDR suboption is received, increase the first mib counter, when the local subflow is removed, increase the second mib counter. Suggested-by: Matthieu Baerts Suggested-by: Paolo Abeni Suggested-by: Mat Martineau Acked-by: Paolo Abeni Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau --- net/mptcp/mib.c | 2 ++ net/mptcp/mib.h | 2 ++ net/mptcp/pm_netlink.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index a33bf719ce6f..84d119436b22 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -29,6 +29,8 @@ static const struct snmp_mib mptcp_snmp_list[] = { SNMP_MIB_ITEM("DuplicateData", MPTCP_MIB_DUPDATA), SNMP_MIB_ITEM("AddAddr", MPTCP_MIB_ADDADDR), SNMP_MIB_ITEM("EchoAdd", MPTCP_MIB_ECHOADD), + SNMP_MIB_ITEM("RmAddr", MPTCP_MIB_RMADDR), + SNMP_MIB_ITEM("RmSubflow", MPTCP_MIB_RMSUBFLOW), SNMP_MIB_SENTINEL }; diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index cdeea3732ddf..47bcecce1106 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -22,6 +22,8 @@ enum linux_mptcp_mib_field { MPTCP_MIB_DUPDATA, /* Segments discarded due to duplicate DSS */ MPTCP_MIB_ADDADDR, /* Received ADD_ADDR with echo-flag=0 */ MPTCP_MIB_ECHOADD, /* Received ADD_ADDR with echo-flag=1 */ + MPTCP_MIB_RMADDR, /* Received RM_ADDR */ + MPTCP_MIB_RMSUBFLOW, /* Remove a subflow */ __MPTCP_MIB_MAX }; diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 9064c8098521..b33aebd85bd5 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -15,6 +15,7 @@ #include #include "protocol.h" +#include "mib.h" /* forward declaration */ static struct genl_family mptcp_genl_family; @@ -346,6 +347,8 @@ void mptcp_pm_nl_rm_addr_received(struct mptcp_sock *msk) msk->pm.subflows--; WRITE_ONCE(msk->pm.accept_addr, true); + __MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMADDR); + break; } } @@ -379,6 +382,8 @@ void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, u8 rm_id) msk->pm.local_addr_used--; msk->pm.subflows--; + __MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RMSUBFLOW); + break; } } From patchwork Thu Sep 24 00:29:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 260291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE473C4727E for ; Thu, 24 Sep 2020 00:59:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79EB42311E for ; Thu, 24 Sep 2020 00:59:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A+w9Rw6S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbgIXA7Q (ORCPT ); Wed, 23 Sep 2020 20:59:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgIXA7Q (ORCPT ); Wed, 23 Sep 2020 20:59:16 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB78C0613CE; Wed, 23 Sep 2020 17:59:16 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id k133so808432pgc.7; Wed, 23 Sep 2020 17:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=caeOrIOiWzUnYpp7IiQWCVx7AsBLB7hgOndSGgrX5Gk=; b=A+w9Rw6SyEI43czzAmd7oHvoRqydl8clyM3C8ClOVgQCfO74S02EvNMxY3TfslPQLF YOC81YxdMeaMkgtMyP2Ulij/i5WgZxMrC4BbW9ZfkX0y4Lj2ebnXjrD5vgsH6qCcWr7L qIyiSIDEwetm3DU67z+HvVvhYmNn7AdoJEr8k0KD9tYGNzTTztl3zka86trlRf7J7Jvx 5v99NtLLnNg8lo0xFnJ733bPl1jSt+coGYWPWwMun1rO0+5OQNcJ8RUtTbK2IszZo7ft JJ3kxiBdMU5br4h+NGZyycsgGDhwYKWnnlup3bZ7mDT6G84evJfEmfsYlUeWbrT6+UHH BQAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=caeOrIOiWzUnYpp7IiQWCVx7AsBLB7hgOndSGgrX5Gk=; b=g1swsDvvCcvDdqoemT9fZVKKYAuYdzYaEJHONc93z7t3D2AX4y9pIqMrFybR9Gq9Ly JYDcJrcxqMWuJxRhJyVrP9FLV2BoGlTlq+5ViL1y5t6nsVt1EBaqoSOaN0KclaEKDIQq c+1i6eIwu76yKaIIWltySRGFoyDaajcQXnG5+qStXBbRkST9sVwUrQ3WELozOszPW/PL dsFpOIIn6Ay8J/48iBvgEd00TlpgYprbZbfLvNswQd9iE4lK2OfKtCv0m8Mo6f2/LEE+ +lwxu6o8vcQNHQY46Ni0ZKy89rQhJqgfckRJrnQV0sihHNx9czqrnXSZF8vyHfl7a0Rn 4aDg== X-Gm-Message-State: AOAM5326OoOQdN3LaxDgaHz8PivB54WylcXM0gtr9y4tCvG5jW4Ch7TS LtrouryiPyHi1xsST3IfnQU= X-Google-Smtp-Source: ABdhPJytDZ8UoWMFGkes4Q/X0vLr/CJXZP9ZSSTfzJTY62QE6UHAyGz0adcgCIEaMPTORUEY1c0lhQ== X-Received: by 2002:a63:4e0a:: with SMTP id c10mr1845032pgb.369.1600909155791; Wed, 23 Sep 2020 17:59:15 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id 27sm889290pgy.26.2020.09.23.17.59.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2020 17:59:15 -0700 (PDT) From: Geliang Tang To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Jakub Kicinski Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.01.org, linux-kernel@vger.kernel.org Subject: [MPTCP][PATCH net-next 12/16] selftests: mptcp: add remove cfg in mptcp_connect Date: Thu, 24 Sep 2020 08:29:58 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: <430dd4f9c241ae990a5cfa6809276b36993ce91b.1600853093.git.geliangtang@gmail.com> <7b0898eff793dde434464b5fac2629739d9546fd.1600853093.git.geliangtang@gmail.com> <98bcc56283c482c294bd6ae9ce1476821ddc6837.1600853093.git.geliangtang@gmail.com> <37f2befac450fb46367f62446a4bb2c9d0a5986a.1600853093.git.geliangtang@gmail.com> <5018fd495529e058ea866e8d8edbe0bb98ec733a.1600853093.git.geliangtang@gmail.com> <644420f22ba6f0b9f9f3509c081d8d639ff4bbf3.1600853093.git.geliangtang@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch added a new cfg, named cfg_remove in mptcp_connect. This new cfg_remove is copied from cfg_join. The only difference between them is in the do_rnd_write function. Here we slow down the transfer process of all data to let the RM_ADDR suboption can be sent and received completely. Otherwise the remove address and subflow test cases don't work. Suggested-by: Matthieu Baerts Suggested-by: Paolo Abeni Suggested-by: Mat Martineau Acked-by: Paolo Abeni Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau --- .../selftests/net/mptcp/mptcp_connect.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c index a54966531a64..77bb62feb872 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -54,6 +54,7 @@ static int pf = AF_INET; static int cfg_sndbuf; static int cfg_rcvbuf; static bool cfg_join; +static bool cfg_remove; static int cfg_wait; static void die_usage(void) @@ -271,6 +272,9 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len) if (cfg_join && first && do_w > 100) do_w = 100; + if (cfg_remove && do_w > 50) + do_w = 50; + bw = write(fd, buf, do_w); if (bw < 0) perror("write"); @@ -281,6 +285,9 @@ static size_t do_rnd_write(const int fd, char *buf, const size_t len) first = false; } + if (cfg_remove) + usleep(200000); + return bw; } @@ -428,7 +435,7 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd) } /* leave some time for late join/announce */ - if (cfg_join) + if (cfg_join || cfg_remove) usleep(cfg_wait); close(peerfd); @@ -686,7 +693,7 @@ static void maybe_close(int fd) { unsigned int r = rand(); - if (!cfg_join && (r & 1)) + if (!(cfg_join || cfg_remove) && (r & 1)) close(fd); } @@ -822,13 +829,18 @@ static void parse_opts(int argc, char **argv) { int c; - while ((c = getopt(argc, argv, "6jlp:s:hut:m:S:R:w:")) != -1) { + while ((c = getopt(argc, argv, "6jrlp:s:hut:m:S:R:w:")) != -1) { switch (c) { case 'j': cfg_join = true; cfg_mode = CFG_MODE_POLL; cfg_wait = 400000; break; + case 'r': + cfg_remove = true; + cfg_mode = CFG_MODE_POLL; + cfg_wait = 400000; + break; case 'l': listen_mode = true; break; From patchwork Thu Sep 24 00:29:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 260288 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00FB8C4727E for ; Thu, 24 Sep 2020 01:01:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA1D12145D for ; Thu, 24 Sep 2020 01:01:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pgBgJ09+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbgIXBBd (ORCPT ); Wed, 23 Sep 2020 21:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbgIXBBc (ORCPT ); Wed, 23 Sep 2020 21:01:32 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B4AC0613CE; Wed, 23 Sep 2020 18:01:32 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id x22so777102pfo.12; Wed, 23 Sep 2020 18:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=oZPkJS2+leQsW9xRtSE0zAO9xlb/IRjPMYUZOW6oH+s=; b=pgBgJ09+m44ICXVlIgT0CVm0TjP5oFws/u5wkXXLHXtW8Nb92K6s/pu4Nw4o0+mIOT 3p1c9MTAUGws8rnSLOylEJUusmikIpdV0XDwubUjkuAsNbrZLub5u7jdq/e/FcO0neT3 Z/OLK0uCOdGrp2In8yiHGauNPCTMR/lLWtyhLlu7dDN3cKJKXBb5osNP3TtokKYcC+cp ssa7UpBl8Qyzs9IMnPcqnaD5eJZz9cVX2hv7ydIGISLY/9HrVTTgz6MRfhkVa+G0LFZH nWVJooP+W8jIIyFJ4jrr1hLKYChtlkAo/Uw+l35WA9Zm61G0HvMsG5m44gDJiuDTLoD4 cUQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=oZPkJS2+leQsW9xRtSE0zAO9xlb/IRjPMYUZOW6oH+s=; b=dLKKS9OjkGEmGi2lWzG08F/Hadlo1KsurbVevef4eSPrw9PNDoNkv1wy9cYlSphInw sIn8wpnJ1R0JHey7L2N48IwQWBLZrh6MSH79vxHZn0wPi9E9ZCrvjEktclE1pntTSN00 ZYwuOcso1HaLQNqpG1nbzlqTvY+PF9atwL6s98dhNFION5AzgDC9pTZNPCuwuPRiICGl eVJLGQtB26TpOGbaQDkKjBrk7cgsTIxN/z5xVIHb43MHmD/U6XKSbuzzC0Hro9Sj/Isb pjFhITAwsZGIZBBtBMw+Ps9LoEQOrdyhaGNcRgPE35O4uaDcWeDk2QmhydiZxQe3PacV 8RBA== X-Gm-Message-State: AOAM5332YCJNEC5auqKu1dxcxhNSmGkWr+jhmHv7GoaYTBpHoEdsJF6r pvYxX1DnetTmi+pEqdIWb8k= X-Google-Smtp-Source: ABdhPJybXhpq7Z2EtpNKQyj2w+sbEKt6ATyAYAvGNQF3tcpaLwM+ne4vhHS21Yzs0KfdKI/Q2mROsg== X-Received: by 2002:a05:6a00:22d2:b029:142:2501:3966 with SMTP id f18-20020a056a0022d2b029014225013966mr2277631pfj.43.1600909291454; Wed, 23 Sep 2020 18:01:31 -0700 (PDT) Received: from localhost ([43.224.245.180]) by smtp.gmail.com with ESMTPSA id z7sm889240pgc.35.2020.09.23.18.01.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2020 18:01:30 -0700 (PDT) From: Geliang Tang To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Jakub Kicinski Cc: Geliang Tang , netdev@vger.kernel.org, mptcp@lists.01.org, linux-kernel@vger.kernel.org Subject: [MPTCP][PATCH net-next 13/16] selftests: mptcp: add remove addr and subflow test cases Date: Thu, 24 Sep 2020 08:29:59 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: <430dd4f9c241ae990a5cfa6809276b36993ce91b.1600853093.git.geliangtang@gmail.com> <7b0898eff793dde434464b5fac2629739d9546fd.1600853093.git.geliangtang@gmail.com> <98bcc56283c482c294bd6ae9ce1476821ddc6837.1600853093.git.geliangtang@gmail.com> <37f2befac450fb46367f62446a4bb2c9d0a5986a.1600853093.git.geliangtang@gmail.com> <5018fd495529e058ea866e8d8edbe0bb98ec733a.1600853093.git.geliangtang@gmail.com> <644420f22ba6f0b9f9f3509c081d8d639ff4bbf3.1600853093.git.geliangtang@gmail.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch added the remove addr and subflow test cases and two new functions. The first function run_remove_tests calls do_transfer with two new arguments, rm_nr_ns1 and rm_nr_ns2, for the numbers of addresses should be removed during the transfer process in namespace 1 and namespace 2. If both these two arguments are 0, we do the join test cases with "mptcp_connect -j" command. Otherwise, do the remove test cases with "mptcp_connect -r" command. The second function chk_rm_nr checks the RM_ADDR related mibs's counters. The output of the test cases looks like this: 11 remove single subflow syn[ ok ] - synack[ ok ] - ack[ ok ] rm [ ok ] - sf [ ok ] 12 remove multiple subflows syn[ ok ] - synack[ ok ] - ack[ ok ] rm [ ok ] - sf [ ok ] 13 remove single address syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] rm [ ok ] - sf [ ok ] 14 remove subflow and signal syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] rm [ ok ] - sf [ ok ] 15 remove subflows and signal syn[ ok ] - synack[ ok ] - ack[ ok ] add[ ok ] - echo [ ok ] rm [ ok ] - sf [ ok ] Suggested-by: Matthieu Baerts Suggested-by: Paolo Abeni Suggested-by: Mat Martineau Acked-by: Paolo Abeni Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau --- .../testing/selftests/net/mptcp/mptcp_join.sh | 145 +++++++++++++++++- 1 file changed, 142 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 9d64abdde146..08f53d86dedc 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -8,6 +8,7 @@ cin="" cout="" ksft_skip=4 timeout=30 +mptcp_connect="" capture=0 TEST_COUNT=0 @@ -132,6 +133,8 @@ do_transfer() cl_proto="$3" srv_proto="$4" connect_addr="$5" + rm_nr_ns1="$6" + rm_nr_ns2="$7" port=$((10000+$TEST_COUNT)) TEST_COUNT=$((TEST_COUNT+1)) @@ -156,14 +159,44 @@ do_transfer() sleep 1 fi - ip netns exec ${listener_ns} ./mptcp_connect -j -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" & + if [[ $rm_nr_ns1 -eq 0 && $rm_nr_ns2 -eq 0 ]]; then + mptcp_connect="./mptcp_connect -j" + else + mptcp_connect="./mptcp_connect -r" + fi + + ip netns exec ${listener_ns} $mptcp_connect -t $timeout -l -p $port -s ${srv_proto} 0.0.0.0 < "$sin" > "$sout" & spid=$! sleep 1 - ip netns exec ${connector_ns} ./mptcp_connect -j -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & + ip netns exec ${connector_ns} $mptcp_connect -t $timeout -p $port -s ${cl_proto} $connect_addr < "$cin" > "$cout" & cpid=$! + if [ $rm_nr_ns1 -gt 0 ]; then + counter=1 + sleep 1 + + while [ $counter -le $rm_nr_ns1 ] + do + ip netns exec ${listener_ns} ./pm_nl_ctl del $counter + sleep 1 + let counter+=1 + done + fi + + if [ $rm_nr_ns2 -gt 0 ]; then + counter=1 + sleep 1 + + while [ $counter -le $rm_nr_ns2 ] + do + ip netns exec ${connector_ns} ./pm_nl_ctl del $counter + sleep 1 + let counter+=1 + done + fi + wait $cpid retc=$? wait $spid @@ -219,7 +252,24 @@ run_tests() connect_addr="$3" lret=0 - do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} 0 0 + lret=$? + if [ $lret -ne 0 ]; then + ret=$lret + return + fi +} + +run_remove_tests() +{ + listener_ns="$1" + connector_ns="$2" + connect_addr="$3" + rm_nr_ns1="$4" + rm_nr_ns2="$5" + lret=0 + + do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr} ${rm_nr_ns1} ${rm_nr_ns2} lret=$? if [ $lret -ne 0 ]; then ret=$lret @@ -313,6 +363,43 @@ chk_add_nr() fi } +chk_rm_nr() +{ + local rm_addr_nr=$1 + local rm_subflow_nr=$2 + local count + local dump_stats + + printf "%-39s %s" " " "rm " + count=`ip netns exec $ns1 nstat -as | grep MPTcpExtRmAddr | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$rm_addr_nr" ]; then + echo "[fail] got $count RM_ADDR[s] expected $rm_addr_nr" + ret=1 + dump_stats=1 + else + echo -n "[ ok ]" + fi + + echo -n " - sf " + count=`ip netns exec $ns2 nstat -as | grep MPTcpExtRmSubflow | awk '{print $2}'` + [ -z "$count" ] && count=0 + if [ "$count" != "$rm_subflow_nr" ]; then + echo "[fail] got $count RM_SUBFLOW[s] expected $rm_subflow_nr" + ret=1 + dump_stats=1 + else + echo "[ ok ]" + fi + + if [ "${dump_stats}" = 1 ]; then + echo Server ns stats + ip netns exec $ns1 nstat -as | grep MPTcp + echo Client ns stats + ip netns exec $ns2 nstat -as | grep MPTcp + fi +} + sin=$(mktemp) sout=$(mktemp) cin=$(mktemp) @@ -404,6 +491,58 @@ run_tests $ns1 $ns2 10.0.1.1 chk_join_nr "multiple subflows and signal" 3 3 3 chk_add_nr 1 1 +# single subflow, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl limits 0 1 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_remove_tests $ns1 $ns2 10.0.1.1 0 1 +chk_join_nr "remove single subflow" 1 1 1 +chk_rm_nr 1 1 + +# multiple subflows, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl limits 0 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.2.2 flags subflow +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_remove_tests $ns1 $ns2 10.0.1.1 0 2 +chk_join_nr "remove multiple subflows" 2 2 2 +chk_rm_nr 2 2 + +# single address, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 1 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns2 ./pm_nl_ctl limits 1 1 +run_remove_tests $ns1 $ns2 10.0.1.1 1 0 +chk_join_nr "remove single address" 1 1 1 +chk_add_nr 1 1 +chk_rm_nr 0 0 + +# subflow and signal, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 2 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns2 ./pm_nl_ctl limits 1 2 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +run_remove_tests $ns1 $ns2 10.0.1.1 1 1 +chk_join_nr "remove subflow and signal" 2 2 2 +chk_add_nr 1 1 +chk_rm_nr 1 1 + +# subflows and signal, remove +reset +ip netns exec $ns1 ./pm_nl_ctl limits 0 3 +ip netns exec $ns1 ./pm_nl_ctl add 10.0.2.1 flags signal +ip netns exec $ns2 ./pm_nl_ctl limits 1 3 +ip netns exec $ns2 ./pm_nl_ctl add 10.0.3.2 flags subflow +ip netns exec $ns2 ./pm_nl_ctl add 10.0.4.2 flags subflow +run_remove_tests $ns1 $ns2 10.0.1.1 1 2 +chk_join_nr "remove subflows and signal" 3 3 3 +chk_add_nr 1 1 +chk_rm_nr 2 2 + # single subflow, syncookies reset_with_cookies ip netns exec $ns1 ./pm_nl_ctl limits 0 1