From patchwork Wed Jan 15 09:59:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13940189 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E879D1DB14D for ; Wed, 15 Jan 2025 09:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736935186; cv=none; b=IX+EPCP7d6kcD6p7wdobOrkChIHAUur4BaOM2kjzmt42xwAIW/Nf9nYg6cvsEqhs8FIIN67mvuq5xF/RkHcVGnH0E8GWtvWrcHwk3WKWWGXAhvbSgFt0FfyCfNnEwv8POCSsPTezoNheRvQynPFFZlCRA91fsMnRTzdxaruQjbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736935186; c=relaxed/simple; bh=VQTbXInIocsUug3Gaqad5FUcamm3egJMgNUOEl9m6Tg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oxPxGsH6c8aY1aqNZ/j9l4whCK06TSuruO//Hsnw9yc3mpen91JOEGiQCISOAIGBNMeO2/PqcLi1sFEB+rRwhkHzc45N1k+3tfoiHz49U3V63qqJ/op4ZL/8bya41qn4OdbxzG81EDThzJToKArjUkpmm9LD/A8Us1K6S7jQmMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ava02Ius; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ava02Ius" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7359FC4CEE1; Wed, 15 Jan 2025 09:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736935185; bh=VQTbXInIocsUug3Gaqad5FUcamm3egJMgNUOEl9m6Tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ava02IusewSXyJnzOrbAJdr/h0EWkaFRsTwI49RvO1tLir6ijLhIMx6qH/nyDVTrR 3A1TcARnbr+GPUpUgbsVQ0sIv+cH1sXtv+Xt4k8HD6x/XL9RMJ9J8N2+MQ7uCtiEkM qNGvJ71wbWaSHH2B3R60UtHa+q3LSEyh6L7e2S/n3WGBwicbk2/qPcUUK6TyzdTWmC HNIb/Se/w878iLRugdyw4YlSHO3ka4zm4LQshIttfX1zYFflu5CUxJ6hGj+yY5D6sN TA2QemleUTG4Cw2gtfPvY5WjvApBgwdHXMS5wfXDLzTEAlsLf4vIK/9x2a/T3bNGmG 4iGjVGjrdY3lg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 2/6] mptcp: add struct mptcp_pm_addr_id_bitmap Date: Wed, 15 Jan 2025 17:59:28 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang To simplify the use of bitmap in BPF, a new type for MPTCP userspace pm id bitmap, struct mptcp_pm_addr_id_bitmap is defined. Because there's no way to use DECLARE_BITMAP macro in BPF program, and it's not easy to reimplement it in BPF. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 14 ++++++-------- net/mptcp/protocol.h | 4 ++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index b50462b527bd..e53426a5fc52 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -47,7 +47,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry, bool needs_id) { - DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); + struct mptcp_pm_addr_id_bitmap id_bitmap; struct mptcp_pm_addr_entry *match = NULL; struct sock *sk = (struct sock *)msk; struct mptcp_pm_addr_entry *e; @@ -55,7 +55,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, bool id_match = false; int ret = -EINVAL; - bitmap_zero(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); + bitmap_zero(id_bitmap.map, MPTCP_PM_MAX_ADDR_ID + 1); spin_lock_bh(&msk->pm.lock); mptcp_for_each_userspace_pm_addr(msk, e) { @@ -69,7 +69,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, } else if (addr_match || id_match) { break; } - __set_bit(e->addr.id, id_bitmap); + __set_bit(e->addr.id, id_bitmap.map); } if (!match && !addr_match && !id_match) { @@ -84,7 +84,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, *e = *entry; if (!e->addr.id && needs_id) - e->addr.id = find_next_zero_bit(id_bitmap, + e->addr.id = find_next_zero_bit(id_bitmap.map, MPTCP_PM_MAX_ADDR_ID + 1, 1); list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list); @@ -633,16 +633,14 @@ int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local, int mptcp_userspace_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb) { - struct id_bitmap { - DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); - } *bitmap; const struct genl_info *info = genl_info_dump(cb); + struct mptcp_pm_addr_id_bitmap *bitmap; struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; int ret = -EINVAL; struct sock *sk; - bitmap = (struct id_bitmap *)cb->ctx; + bitmap = (struct mptcp_pm_addr_id_bitmap *)cb->ctx; msk = mptcp_userspace_pm_get_sock(info); if (!msk) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 20941405a1ea..aca3de2baf81 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -212,6 +212,10 @@ enum mptcp_addr_signal_status { /* max value of mptcp_addr_info.id */ #define MPTCP_PM_MAX_ADDR_ID U8_MAX +struct mptcp_pm_addr_id_bitmap { + DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1); +}; + struct mptcp_pm_data { struct mptcp_addr_info local; struct mptcp_addr_info remote;