git: 65e7a648693c - main - genl: allow to monitor all know groups
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Oct 2024 09:49:56 UTC
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=65e7a648693cc151990688f48c190df1c1fc858b commit 65e7a648693cc151990688f48c190df1c1fc858b Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2024-10-07 09:45:21 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2024-10-07 09:46:32 +0000 genl: allow to monitor all know groups Add a special keyword "all" for the group name, which allows genl to monitor all groups in an existing family --- usr.bin/genl/genl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.bin/genl/genl.c b/usr.bin/genl/genl.c index e3acb872a39e..eaf20d20e890 100644 --- a/usr.bin/genl/genl.c +++ b/usr.bin/genl/genl.c @@ -197,6 +197,7 @@ monitor_mcast(int argc __unused, char **argv) struct _getfamily_attrs attrs; struct pollfd pfd; bool found = false; + bool all = false; void (*parser)(struct snl_state *ss, struct nlmsghdr *hdr); parser = parser_fallback; @@ -210,8 +211,10 @@ monitor_mcast(int argc __unused, char **argv) } if (!snl_get_genl_family_info(&ss, argv[0], &attrs)) errx(EXIT_FAILURE, "Unknown family '%s'", argv[0]); + if (strcmp(argv[1], "all") == 0) + all = true; for (uint32_t i = 0; i < attrs.mcast_groups.num_groups; i++) { - if (strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name, + if (all || strcmp(attrs.mcast_groups.groups[i]->mcast_grp_name, argv[1]) == 0) { found = true; if (setsockopt(ss.fd, SOL_NETLINK, @@ -221,7 +224,8 @@ monitor_mcast(int argc __unused, char **argv) == -1) err(EXIT_FAILURE, "Cannot subscribe to command " "notify"); - break; + if (!all) + break; } } if (!found)