The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=c1f6b799a7647a738f2e0dfa688c54ada83abc59
commit c1f6b799a7647a738f2e0dfa688c54ada83abc59 Author: Gleb Smirnoff <gleb...@freebsd.org> AuthorDate: 2025-01-16 03:33:16 +0000 Commit: Gleb Smirnoff <gleb...@freebsd.org> 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); }