From nobody Thu Jan 16 07:30:19 2025 X-Original-To: dev-commits-src-all@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 4YYZJq3shWz5lJty; Thu, 16 Jan 2025 07:30:19 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YYZJq2jnDz3bH8; Thu, 16 Jan 2025 07:30:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737012619; 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=94vCJ1BQKu4v0FzkWb9XNaf1vOSjM6KVFWokynYbBeQ=; b=Z6LNYtGwIf+fv1jNVDlFhm2MeSGCAU6u2pCShGq5rtuwlRCCoBQilTTTzdDkKlzRo8UX0Z gFjlEt9ZWF9Kn4ssVGOOZ2ZKv60P+RO5LKLf9NsqENmu3lTNuZdV+Aq44Rd7nZMYLP5zA8 yKGWfGR3SuguRbRaNi1t23KPGoHG+dOPQZKVx/Tm0x1IwhndFIk4yQ05KztJVFJ8XdhIU5 ig8DbxM/nJe05k85+ClGBJOyNVNs8kNmkcvh3Z+yTx7Ep0SYeYVo9sQvZ2QbQAcBeecnGJ V5HYDOKR34L7NTFljvee/ghM+Ap4dGsMg9E2ywF/YQRbpoomWT5nU2wlwmUJmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737012619; 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=94vCJ1BQKu4v0FzkWb9XNaf1vOSjM6KVFWokynYbBeQ=; b=jFw+6H9HECH2sa8b5cLjq0a7r3ybgsmRmmX1GmTO9WMq92bF5du7WUU1yF4kbg7pt9Zq6s 9HPd/f+yLmyjcPUSjF3OO7GXbZ/7mfGix4mLDJJSc3auy2rTkopDBOswOvXtWcwGJ6y1R8 2heRWehI0Ri8c1es12GtW6RDZMWU023Kcg0zKiUtuv0OUL1gLozlBQQ19hVDkC/kiZudYc 0j2EVz7/rg3ZQzmNgzSyJhG6D68Qe/TTWot4NwIv3aUhsReVgGzVvE9aVjJB1kNSrskJm2 5WMvzOGkPWqh3p5aSVIqQchYlTrBx3f9vhFhrEPGBral6MkvFsEUf6m+lIPOMQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737012619; a=rsa-sha256; cv=none; b=y3ViNAqoSiLIxCyyFphaftpXVpS6LTjTD04NRgkxUQ6COY2SaYHJelXO/gy/iAKxw5XQZr 5ImcvEQVPbSFPeKaTp5XhfDzkF7WO2ud3YzVxSoOLKvqvyO+j4J1CTZl3QmZMZwj4kR8q5 P9GR1YSoZzBmxrSwRIlCQ9pDwYNynZNUK+3E5FBDPQnbwVAhw9K79U1hEfiaQkF0SWc76d JcUjSyELTRG4f3H5BDJxShDFewPOTNR/S5LmwJeKKg9YkGfpfvFlSQO98svSNGXtCwyqtW +pyCweDJUaHPDOyvhZmBQ1rbC9Tm+jblMVio3oBJ8Eca4urFB0rlryXopDoEfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YYZJq22Psz7FQ; Thu, 16 Jan 2025 07:30:19 +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 50G7UJMj098584; Thu, 16 Jan 2025 07:30:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50G7UJcq098581; Thu, 16 Jan 2025 07:30:19 GMT (envelope-from git) Date: Thu, 16 Jan 2025 07:30:19 GMT Message-Id: <202501160730.50G7UJcq098581@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: c1f6b799a764 - main - powerd: use snl_get_genl_mcast_group() API List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: c1f6b799a7647a738f2e0dfa688c54ada83abc59 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=c1f6b799a7647a738f2e0dfa688c54ada83abc59 commit c1f6b799a7647a738f2e0dfa688c54ada83abc59 Author: Gleb Smirnoff AuthorDate: 2025-01-16 03:33:16 +0000 Commit: Gleb Smirnoff CommitDate: 2025-01-16 07:20:57 +0000 powerd: use snl_get_genl_mcast_group() API --- usr.sbin/powerd/powerd.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/usr.sbin/powerd/powerd.c b/usr.sbin/powerd/powerd.c index 7be24e0c01ad..7eab9a630411 100644 --- a/usr.sbin/powerd/powerd.c +++ b/usr.sbin/powerd/powerd.c @@ -464,31 +464,23 @@ acline_read(int rfds) bool netlink_init(void) { - struct _getfamily_attrs attrs; + uint32_t group; if (modfind("nlsysevent") < 0) kldload("nlsysevent"); if (modfind("nlsysevent") < 0) return (false); - if (!snl_init(&ss, NETLINK_GENERIC)) + if (!snl_init(&ss, NETLINK_GENERIC) || (group = + snl_get_genl_mcast_group(&ss, "nlsysevent", "ACPI", NULL)) == 0) { + warnx("Cannot find \"nlsysevent\" family \"ACPI\" group"); return (false); + } - if (!snl_get_genl_family_info(&ss, "nlsysevent", &attrs)) + if (setsockopt(ss.fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group, + sizeof(group)) == -1) { + warnx("Cannot subscribe to \"ACPI\""); return (false); - - for (unsigned int i = 0; i < attrs.mcast_groups.num_groups; i++) { - if (strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name, - "ACPI") == 0) { - if (setsockopt(ss.fd, SOL_NETLINK, - NETLINK_ADD_MEMBERSHIP, - &attrs.mcast_groups.groups[i]->mcast_grp_id, - sizeof(attrs.mcast_groups.groups[i]->mcast_grp_id)) - == -1) { - warnx("Cannot subscribe to \"ACPI\""); - return (false); - } - } } return (true); }