* [PATCH 1/2] monitor: Use genl APIs instead of open coding
@ 2024-07-26 15:08 Denis Kenzior
2024-07-26 15:08 ` [PATCH 2/2] qemu: Remove unsupported command line arguments Denis Kenzior
2024-07-30 15:53 ` [PATCH 1/2] monitor: Use genl APIs instead of open coding Denis Kenzior
0 siblings, 2 replies; 3+ messages in thread
From: Denis Kenzior @ 2024-07-26 15:08 UTC (permalink / raw)
To: iwd; +Cc: Denis Kenzior
l_genl class has nice ways of discovering and requesting families. The
genl functionality has been added after the iwmon skeleton was created,
but it is now time to migrate to using these APIs.
---
monitor/main.c | 93 ++++++--------------------------------------------
1 file changed, 11 insertions(+), 82 deletions(-)
diff --git a/monitor/main.c b/monitor/main.c
index 8f354d52607d..32f5ec4fc7f3 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -224,110 +224,39 @@ struct iwmon_interface {
char *ifname;
bool exists;
struct l_netlink *rtnl;
- struct l_netlink *genl;
+ struct l_genl *genl;
struct l_io *io;
};
static struct iwmon_interface monitor_interface = { };
-static void genl_parse(uint16_t type, const void *data, uint32_t len,
- const char *ifname)
+static void nl80211_appeared(const struct l_genl_family_info *info,
+ void *user_data)
{
- const struct genlmsghdr *genlmsg = data;
- const struct nlattr *nla;
- char name[GENL_NAMSIZ];
- uint16_t id = 0;
-
- if (nlmon)
- return;
-
- if (type != GENL_ID_CTRL)
- return;
-
- if (genlmsg->cmd != CTRL_CMD_NEWFAMILY)
- return;
-
- for (nla = data + GENL_HDRLEN; NLA_OK(nla, len);
- nla = NLA_NEXT(nla, len)) {
- switch (nla->nla_type & NLA_TYPE_MASK) {
- case CTRL_ATTR_FAMILY_ID:
- id = *((uint16_t *) NLA_DATA(nla));
- break;
- case CTRL_ATTR_FAMILY_NAME:
- strncpy(name, NLA_DATA(nla), GENL_NAMSIZ - 1);
- break;
- }
- }
-
- if (id == 0)
- return;
-
- if (strcmp(name, NL80211_GENL_NAME))
- return;
+ const char *ifname = user_data;
monitor_interface.io = open_packet(ifname);
if (!monitor_interface.io)
goto failed;
- nlmon = nlmon_open(id, writer_path, &config);
+ nlmon = nlmon_open(l_genl_family_info_get_id(info),
+ writer_path, &config);
if (!nlmon)
goto failed;
l_io_set_read_handler(monitor_interface.io, nlmon_receive, nlmon, NULL);
-
return;
failed:
l_main_quit();
}
-static void genl_notify(uint16_t type, const void *data,
- uint32_t len, void *user_data)
-{
- const char *ifname = user_data;
-
- genl_parse(type, data, len, ifname);
-}
-
-static void genl_callback(int error, uint16_t type, const void *data,
- uint32_t len, void *user_data)
-{
- const char *ifname = user_data;
-
- if (error < 0) {
- fprintf(stderr, "Failed to lookup nl80211 family\n");
- l_main_quit();
- return;
- }
-
- genl_parse(type, data, len, ifname);
-}
-
-static struct l_netlink *genl_lookup(const char *ifname)
+static struct l_genl *genl_lookup(const char *ifname)
{
- struct l_netlink *genl;
- char buf[GENL_HDRLEN + NLA_HDRLEN + GENL_NAMSIZ];
- struct genlmsghdr *genlmsg;
- struct nlattr *nla;
-
- genl = l_netlink_new(NETLINK_GENERIC);
-
- l_netlink_register(genl, GENL_ID_CTRL, genl_notify, NULL, NULL);
-
- genlmsg = (struct genlmsghdr *) buf;
- genlmsg->cmd = CTRL_CMD_GETFAMILY;
- genlmsg->version = 0;
- genlmsg->reserved = 0;
-
- nla = (struct nlattr *) (buf + GENL_HDRLEN);
- nla->nla_len = NLA_HDRLEN + GENL_NAMSIZ;
- nla->nla_type = CTRL_ATTR_FAMILY_NAME;
- strncpy(buf + GENL_HDRLEN + NLA_HDRLEN,
- NL80211_GENL_NAME, GENL_NAMSIZ);
-
- l_netlink_send(genl, GENL_ID_CTRL, 0, buf, sizeof(buf),
- genl_callback, (char *) ifname, NULL);
+ struct l_genl *genl = l_genl_new();
+ l_genl_request_family(genl, NL80211_GENL_NAME, nl80211_appeared,
+ (char *) ifname, NULL);
return genl;
}
@@ -957,7 +886,7 @@ int main(int argc, char *argv[])
l_io_destroy(monitor_interface.io);
l_netlink_destroy(monitor_interface.rtnl);
- l_netlink_destroy(monitor_interface.genl);
+ l_genl_unref(monitor_interface.genl);
l_free(monitor_interface.ifname);
nlmon_close(nlmon);
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] qemu: Remove unsupported command line arguments
2024-07-26 15:08 [PATCH 1/2] monitor: Use genl APIs instead of open coding Denis Kenzior
@ 2024-07-26 15:08 ` Denis Kenzior
2024-07-30 15:53 ` [PATCH 1/2] monitor: Use genl APIs instead of open coding Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2024-07-26 15:08 UTC (permalink / raw)
To: iwd; +Cc: Denis Kenzior
[denkenz@archdev ~]$ qemu-system-x86_64 --version
QEMU emulator version 9.0.1
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
QEMU now seems to complain that 'no-hpet' and 'no-acpi' command line
arguments are unrecognized.
---
tools/runner.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/runner.py b/tools/runner.py
index e50ba9c08d20..6b27540b8cb7 100644
--- a/tools/runner.py
+++ b/tools/runner.py
@@ -414,7 +414,7 @@ class QemuRunner(RunnerAbstract):
'-machine', 'type=q35,accel=kvm:tcg',
'-nodefaults', '-no-user-config', '-monitor', 'none',
'-display', 'none', '-m', '%dM' % ram, '-nographic', '-vga',
- 'none', '-no-acpi', '-no-hpet',
+ 'none',
'-no-reboot', '-fsdev',
'local,id=fsdev-root,path=/,readonly=on,security_model=none,multidevs=remap',
'-device',
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] monitor: Use genl APIs instead of open coding
2024-07-26 15:08 [PATCH 1/2] monitor: Use genl APIs instead of open coding Denis Kenzior
2024-07-26 15:08 ` [PATCH 2/2] qemu: Remove unsupported command line arguments Denis Kenzior
@ 2024-07-30 15:53 ` Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2024-07-30 15:53 UTC (permalink / raw)
To: iwd
On 7/26/24 10:08 AM, Denis Kenzior wrote:
> l_genl class has nice ways of discovering and requesting families. The
> genl functionality has been added after the iwmon skeleton was created,
> but it is now time to migrate to using these APIs.
> ---
> monitor/main.c | 93 ++++++--------------------------------------------
> 1 file changed, 11 insertions(+), 82 deletions(-)
>
All applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-30 15:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26 15:08 [PATCH 1/2] monitor: Use genl APIs instead of open coding Denis Kenzior
2024-07-26 15:08 ` [PATCH 2/2] qemu: Remove unsupported command line arguments Denis Kenzior
2024-07-30 15:53 ` [PATCH 1/2] monitor: Use genl APIs instead of open coding Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox