From 14d69873b0c93c286d1fa8e41d478f1555fa01ec Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Sat, 20 Apr 2019 22:29:06 +0200 Subject: [PATCH] wiphy: Add wiphy_create_complete Let manager.c signal to wiphy.c when the wiphy parsing from the genl messages is complete. When we query for existing wiphy using the GET_WIPHY dump command we get many genl messages per wiphy, on a notification we only get one message. So after wiphy_create there may be one or many calls to wiphy_update_from_genl. wiphy_create_complete is called after all of them, so wiphy.c can be sure it's done with parsing the wiphy attributes when in prints the new wiphy summary log message, like it did before manager.c was added. I had wrongly assumed that all the important wiphy attributes were in the first message in the dump, but NL80211_ATTR_EXT_FEATURES was not and wasn't being parsed which was breaking at least testRSSIAgent. --- src/manager.c | 9 ++++++++- src/wiphy.c | 11 ++++++----- src/wiphy.h | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/manager.c b/src/manager.c index 2c0e481c..132ac188 100644 --- a/src/manager.c +++ b/src/manager.c @@ -449,6 +449,8 @@ static void manager_new_wiphy_event(struct l_genl_msg *msg) if (!state) return; + wiphy_create_complete(state->wiphy); + /* Setup a timer just in case a default interface is not created */ state->setup_timeout = l_timeout_create(1, manager_wiphy_setup_timeout, state, NULL); @@ -605,7 +607,12 @@ static void manager_interface_dump_done(void *user_data) struct wiphy_setup_state *state = entry->data; /* phy might have been detected after the initial dump */ - if (state->setup_timeout || state->pending_cmd_count) + if (state->setup_timeout) + continue; + + wiphy_create_complete(state->wiphy); + + if (state->pending_cmd_count) continue; /* If we are here, then there are no interfaces for this phy */ diff --git a/src/wiphy.c b/src/wiphy.c index 299ba0bf..54b6de63 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -751,11 +751,12 @@ void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg) IWD_WIPHY_INTERFACE, "Name"); } - if (!wiphy->supported_iftypes) { - /* Most likely a new wiphy, set all the parameters */ - wiphy_parse_attributes(wiphy, &attr); - wiphy_print_basic_info(wiphy); - } + wiphy_parse_attributes(wiphy, &attr); +} + +void wiphy_create_complete(struct wiphy *wiphy) +{ + wiphy_print_basic_info(wiphy); } bool wiphy_destroy(struct wiphy *wiphy) diff --git a/src/wiphy.h b/src/wiphy.h index 0da447d0..792602c8 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -49,6 +49,7 @@ bool wiphy_parse_id_and_name(struct l_genl_attr *attr, uint32_t *out_id, struct wiphy *wiphy_find(int wiphy_id); struct wiphy *wiphy_create(uint32_t wiphy_id, const char *name); +void wiphy_create_complete(struct wiphy *wiphy); bool wiphy_destroy(struct wiphy *wiphy); void wiphy_update_from_genl(struct wiphy *wiphy, struct l_genl_msg *msg);