From patchwork Wed Jun 30 10:24:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YonglongLi X-Patchwork-Id: 12351799 Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.227]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AEB529CA for ; Wed, 30 Jun 2021 10:24:28 +0000 (UTC) HMM_SOURCE_IP: 172.18.0.218:42528.526440819 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-36.111.140.9?logid-820477ffa95041328a8565b948a69907 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id 63B242800A6; Wed, 30 Jun 2021 18:24:28 +0800 (CST) X-189-SAVE-TO-SEND: +liyonglong@chinatelecom.cn Received: from ([172.18.0.218]) by app0025 with ESMTP id 47639ce69a024a67b9ac4f5c15107fdb for mptcp@lists.linux.dev; Wed Jun 30 18:24:27 2021 X-Transaction-ID: 47639ce69a024a67b9ac4f5c15107fdb X-filter-score: X-Real-From: liyonglong@chinatelecom.cn X-Receive-IP: 172.18.0.218 X-MEDUSA-Status: 0 Sender: liyonglong@chinatelecom.cn From: Yonglong Li To: mptcp@lists.linux.dev Cc: mathew.j.martineau@linux.intel.com, geliangtang@gmail.com, Yonglong Li Subject: [PATCH v7 2/5] mptcp: make MPTCP_ADD_ADDR_SIGNAL and MPTCP_ADD_ADDR_ECHO separate Date: Wed, 30 Jun 2021 18:24:10 +0800 Message-Id: <1625048653-6825-3-git-send-email-liyonglong@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625048653-6825-1-git-send-email-liyonglong@chinatelecom.cn> References: <1625048653-6825-1-git-send-email-liyonglong@chinatelecom.cn> Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 MPTCP_ADD_ADDR_SIGNAL only for action of sending ADD_ADDR MPTCP_ADD_ADDR_ECHO only for action of sending echo ADD_ADDR add a mptcp_addr_info in struct mptcp_out_options for echo ADD_ADDR to prepare for the next patch. Signed-off-by: Yonglong Li --- net/mptcp/pm.c | 16 ++++++++++------ net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/protocol.h | 6 ++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 50079e5..0dc9021 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -18,19 +18,23 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, { u8 add_addr = READ_ONCE(msk->pm.addr_signal); - pr_debug("msk=%p, local_id=%d", msk, addr->id); + pr_debug("msk=%p, local_id=%d, echo:%d", msk, addr->id, echo); lockdep_assert_held(&msk->pm.lock); - if (add_addr) { - pr_warn("addr_signal error, add_addr=%d", add_addr); + if (add_addr & + (echo ? BIT(MPTCP_ADD_ADDR_ECHO) : BIT(MPTCP_ADD_ADDR_SIGNAL))) { + pr_warn("addr_signal error, add_addr=%d, echo=%d", add_addr, echo); return -EINVAL; } - msk->pm.local = *addr; - add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL); - if (echo) + if (echo) { + msk->pm.remote = *addr; add_addr |= BIT(MPTCP_ADD_ADDR_ECHO); + } else { + msk->pm.local = *addr; + add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL); + } if (addr->family == AF_INET6) add_addr |= BIT(MPTCP_ADD_ADDR_IPV6); if (addr->port) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index d4732a4..0f302d2 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -317,14 +317,14 @@ static void mptcp_pm_add_timer(struct timer_list *timer) if (!entry->addr.id) return; - if (mptcp_pm_should_add_signal(msk)) { + if (mptcp_pm_should_add_signal_addr(msk)) { sk_reset_timer(sk, timer, jiffies + TCP_RTO_MAX / 8); goto out; } spin_lock_bh(&msk->pm.lock); - if (!mptcp_pm_should_add_signal(msk)) { + if (!mptcp_pm_should_add_signal_addr(msk)) { pr_debug("retransmit ADD_ADDR id=%d", entry->addr.id); mptcp_pm_announce_addr(msk, &entry->addr, false); mptcp_pm_add_addr_send_ack(msk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 160c2ab..a0b0ec0 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -708,6 +708,12 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) { + return READ_ONCE(msk->pm.addr_signal) & + (BIT(MPTCP_ADD_ADDR_SIGNAL) | BIT(MPTCP_ADD_ADDR_ECHO)); +} + +static inline bool mptcp_pm_should_add_signal_addr(struct mptcp_sock *msk) +{ return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_ADD_ADDR_SIGNAL); }