git: 8a8d095718cb - main - netlink: add snl(3) primitive to obtain group ID
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 11 Jan 2025 05:00:25 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=8a8d095718cb4e3ce84bef1cd61c20b518b8d047 commit 8a8d095718cb4e3ce84bef1cd61c20b518b8d047 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2025-01-11 04:55:50 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2025-01-11 04:55:50 +0000 netlink: add snl(3) primitive to obtain group ID using the family name and the group name as lookup arguments. Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D48308 --- sys/netlink/netlink_snl_generic.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/netlink/netlink_snl_generic.h b/sys/netlink/netlink_snl_generic.h index 0a2913c9155e..32b460c612bd 100644 --- a/sys/netlink/netlink_snl_generic.h +++ b/sys/netlink/netlink_snl_generic.h @@ -127,6 +127,24 @@ snl_get_genl_family(struct snl_state *ss, const char *family_name) return (attrs.family_id); } +static inline uint16_t +snl_get_genl_mcast_group(struct snl_state *ss, const char *family_name, + const char *group_name, uint16_t *family_id) +{ + struct _getfamily_attrs attrs = {}; + + snl_get_genl_family_info(ss, family_name, &attrs); + if (attrs.family_id == 0) + return (0); + if (family_id != NULL) + *family_id = attrs.family_id; + for (u_int i = 0; i < attrs.mcast_groups.num_groups; i++) + if (strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name, + group_name) == 0) + return (attrs.mcast_groups.groups[i]->mcast_grp_id); + return (0); +} + static const struct snl_hdr_parser *snl_all_genl_parsers[] = { &_genl_ctrl_getfam_parser, &_genl_ctrl_mc_parser, };