From nobody Tue Dec 03 20:04:55 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Y2s7r29v9z5ggKs; Tue, 03 Dec 2024 20:04:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y2s7r0YSBz4lGD; Tue, 3 Dec 2024 20:04:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733256296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Uyu3njc1NtAhoGVSBfXJ+r4wylAAd3aTcRECoiOBE7E=; b=liua/fFFXpI0g8354OMI+kyyJOVKg+UJDlrYy6uufeiA40f+Z320GM6rw6J3lQpLI3TRYG nQBFoCF4+DXmWJqu3C1Syx+CIxLz958U6MthOFhmhyT9HgSnu+mIIhG+oCWQpcpdVTcBWL wU3oSguRuoLcPVf6/PESsjPEvnHQU3OTXnmXp1dE+ee8b6/HqaKPKq+53NW/nbIPh/JVZw KawM31x42d3RgrUdh+uplWd3VHZIOz9JthwgR4HT8ScLf5r7/+jkYZg1U0EmgtNf75NB1C r4ODgKrbgtNonYpy6joEb67iInk1WTQ/QvEOpV4aNoCoMul/AUcf03ExW54sJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733256296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Uyu3njc1NtAhoGVSBfXJ+r4wylAAd3aTcRECoiOBE7E=; b=etGMTTq3kJkpFFw5MSe+Cwwt767FOuBMX3zNiwWNzG4VZFZKaAVQuTt/lBioRt2ug7XVp9 oc/Be7jvyf95fupkL2DJli3tKgriA6rnok3Zv3bKzYcpGOysJCOmLi7BIpcDOwsIWG2xF+ 8a676rrEjHw4xsw7ezwQ+5C+SU++Nh0FuCN2niQPqwTb16liNOjVAr5jyFGERo/AkxDhQe n5VQSipJFe2jZpye4bW2UNpImXW8L5evubqF8bsa16gOpr4+8y0DGs9+8BOAEocZwexrgT gRlJcZXUtMODWkY6VnjCAoCol4/vktyNQ28y6JQeIdZx1rmlxRgGtdyw28NNkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733256296; a=rsa-sha256; cv=none; b=yUq7wgC2Q+7UHnaBY9UrgFUob1PQMMfruHDxMIk9C+JpCEjCpd1wp9ZMJ7Ej/aj5GfC1bu XZQzGWXSIdgQ/eqrrdppz9v227YgrKuTMV3kj5AZH/cLKcklebw7ooy/SHmRMekKD1TSn7 ji9oGLK5RiyaYx4rnMoohNTMzaWB5NFO1r//Oe5kc5wUIHVTTV0wqmUcRcH/v3TnOAMZFr +gkeflGcVGM9V+otTdLSN0ZrUocY7Od10fQ8xN2md6PcjzpwuMVbJDdQzar4REOh/uPmtI BkueFkPBejBZB/s7UXYRr2gtOydAnh2aLOrfOLzytkvendaekhWarDtNitk6Bw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Y2s7q6zqGzcl0; Tue, 3 Dec 2024 20:04:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4B3K4tbw061583; Tue, 3 Dec 2024 20:04:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B3K4tTJ061580; Tue, 3 Dec 2024 20:04:55 GMT (envelope-from git) Date: Tue, 3 Dec 2024 20:04:55 GMT Message-Id: <202412032004.4B3K4tTJ061580@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: edf5608bfef3 - main - netlink: use bitset(9) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: edf5608bfef3840718bf31b453efb714ef290f31 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=edf5608bfef3840718bf31b453efb714ef290f31 commit edf5608bfef3840718bf31b453efb714ef290f31 Author: Gleb Smirnoff AuthorDate: 2024-12-03 20:04:14 +0000 Commit: Gleb Smirnoff CommitDate: 2024-12-03 20:04:14 +0000 netlink: use bitset(9) Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D47548 --- sys/netlink/netlink_domain.c | 6 +++--- sys/netlink/netlink_var.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netlink/netlink_domain.c b/sys/netlink/netlink_domain.c index 7bd58e63b65a..67ca16d59009 100644 --- a/sys/netlink/netlink_domain.c +++ b/sys/netlink/netlink_domain.c @@ -145,7 +145,7 @@ nl_add_group_locked(struct nlpcb *nlp, unsigned int group_id) if (!nlp_unconstrained_vnet(nlp)) return; - nlp->nl_groups[group_id / 64] |= (uint64_t)1 << (group_id % 64); + BIT_SET(NLP_MAX_GROUPS, group_id, &nlp->nl_groups); } static void @@ -154,7 +154,7 @@ nl_del_group_locked(struct nlpcb *nlp, unsigned int group_id) MPASS(group_id <= NLP_MAX_GROUPS); --group_id; - nlp->nl_groups[group_id / 64] &= ~((uint64_t)1 << (group_id % 64)); + BIT_CLR(NLP_MAX_GROUPS, group_id, &nlp->nl_groups); } static bool @@ -163,7 +163,7 @@ nl_isset_group_locked(struct nlpcb *nlp, unsigned int group_id) MPASS(group_id <= NLP_MAX_GROUPS); --group_id; - return (nlp->nl_groups[group_id / 64] & ((uint64_t)1 << (group_id % 64))); + return (BIT_ISSET(NLP_MAX_GROUPS, group_id, &nlp->nl_groups)); } static uint32_t diff --git a/sys/netlink/netlink_var.h b/sys/netlink/netlink_var.h index 51b0045b1430..7557bd2c06a5 100644 --- a/sys/netlink/netlink_var.h +++ b/sys/netlink/netlink_var.h @@ -53,9 +53,10 @@ struct nl_buf { #define NLP_MAX_GROUPS 128 +BITSET_DEFINE(nl_groups, NLP_MAX_GROUPS); struct nlpcb { struct socket *nl_socket; - uint64_t nl_groups[NLP_MAX_GROUPS / 64]; + struct nl_groups nl_groups; uint32_t nl_port; uint32_t nl_flags; uint32_t nl_process_id;