netconfig: Print addresses added and removed to debug log
PATCH 1/1 netconfig: Print addresses added and removed to debug log
--- src/netconfig-commit.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
src/netconfig-commit.c +23 -0
@@ -92,9 +92,32 @@ void netconfig_commit_free(struct netconfig *netconfig, const char *reasonstr)l_queue_destroy (l_steal_ptr (netconfig_list),NULL ); } +static void netconfig_commit_print_addrs (const char *verb, +const struct l_queue_entry *addrs) +{ +for (; addrs; addrs = addrs->next) { +const struct l_rtnl_address *addr = addrs->data; +char str[INET6_ADDRSTRLEN ]; + +if (l_rtnl_address_get_address (addr, str)) +l_debug ("%s address: %s" , verb, str); + } +} +void netconfig_commit (struct netconfig *netconfig,uint8_t family,enum l_netconfig_event event) { +const struct l_queue_entry *added; +const struct l_queue_entry *removed; +const struct l_queue_entry *expired; + +l_netconfig_get_addresses (netconfig->nc, &added,NULL , &removed, &expired); + +/* Only print IP additions and removals to avoid cluttering the log */ +netconfig_commit_print_addrs ("installing" , added); +netconfig_commit_print_addrs ("removing" , removed); +netconfig_commit_print_addrs ("expired" , expired); + commit_ops->commit (netconfig, family, event);if (event ==L_NETCONFIG_EVENT_CONFIGURE ) {
Signature · 1 line
2.34.1
PATCH 1/1 netconfig: Avoid generating events after netconfig_reset
Similarly to l_netconfig track whether IWD's netconfig is active (from the moment of netconfig_configure() till netconfig_reset()) using a "started" flag and avoid handling or emitting any events after "started" is cleared.
This fixes an occasional issue with the Netconfig Agent backend where station would reset netconfig, netconfig would issue DBus calls to clear addresses and routes, station would go into DISCONNECTING, perhaps finish and go into DISCONNECTED and after a while the DBus calls would come back with an error which would cause a NETCONFIG_EVENT_FAILED causing station to call netdev_disconnct() for a second time and transition to and get stuck in DISCONNECTING.
--- src/netconfig-commit.c | 3 +++ src/netconfig.c | 15 +++++++++++++++ src/netconfig.h | 1 + 3 files changed, 19 insertions(+)
src/netconfig-commit.c +3 -0
@@ -400,6 +400,9 @@ static void netconfig_agent_receive_reply(struct l_dbus_message *reply, data->pending_id[INDEX_FOR_AF (cd->family)] =0 ; +if (!cd->netconfig->started) +return ; +if (l_dbus_message_get_error (reply, &error, &text)) { success = false; l_error("netconfig agent call returned %s(\"%s\")",
src/netconfig.c +15 -0
@@ -507,6 +507,9 @@ static bool netconfig_load_fils_settings(struct netconfig *netconfig,bool netconfig_configure (struct netconfig *netconfig,netconfig_notify_func_t notify,void *user_data) { +if (netconfig->started) +return false; + netconfig->notify = notify; netconfig->user_data = user_data;
@@ -521,11 +524,15 @@ bool netconfig_configure(struct netconfig *netconfig,if (unlikely (!l_netconfig_start (netconfig->nc)))return false; + netconfig->started = true;return true; }bool netconfig_reconfigure (struct netconfig *netconfig,bool set_arp_gw) { +if (!netconfig->started) +return false; +/* * Starting with kernel 4.20, ARP cache is flushed when the netdev * detects NO CARRIER. This can result in unnecessarily long delays
@@ -558,6 +565,10 @@ bool netconfig_reconfigure(struct netconfig *netconfig, bool set_arp_gw)bool netconfig_reset (struct netconfig *netconfig) { +if (!netconfig->started) +return false; + + netconfig->started = false;l_netconfig_unconfigure (netconfig->nc);l_netconfig_stop (netconfig->nc);
@@ -620,6 +631,10 @@ static void netconfig_event_handler(struct l_netconfig *nc, uint8_t family, {struct netconfig *netconfig = user_data; +/* Once stopped, only commit a final L_NETCONFIG_EVENT_UNCONFIGURE */ +if (!netconfig->started && event !=L_NETCONFIG_EVENT_UNCONFIGURE ) +return ; +l_debug ("l_netconfig event %d" , event);netconfig_commit (netconfig, family, event);
src/netconfig.h +1 -0
@@ -43,6 +43,7 @@ struct netconfig {bool static_config[2 ];bool gateway_overridden[2 ];bool dns_overridden[2 ]; +bool started;bool connected[2 ];char **dns_list;char **domains;
Signature · 1 line
2.34.1
Denis Kenzior
AppliedRe: [PATCH] netconfig: Avoid generating events after netconfig_reset
Hi Andrew,
Quoted 12 lines · Andrew Zaborowski
Similarly to
l_netconfigtrack whether IWD's netconfig is active (from the moment ofnetconfig_configure()tillnetconfig_reset()) using a "started" flag and avoid handling or emitting any events after "started" is cleared.This fixes an occasional issue with the Netconfig Agent backend where station would reset netconfig, netconfig would issue DBus calls to clear addresses and routes, station would go into DISCONNECTING, perhaps finish and go into DISCONNECTED and after a while the DBus calls would come back with an error which would cause a
NETCONFIG_EVENT_FAILEDcausing station to callnetdev_disconnct()for a second time and transition to and get stuck in DISCONNECTING.
Quoted 6 lines
--- src/netconfig-commit.c | 3 +++ src/netconfig.c | 15 +++++++++++++++ src/netconfig.h | 1 + 3 files changed, 19 insertions(+)
Applied, thanks.
Regards,
-Denis
Denis Kenzior
AppliedHi Andrew,
Quoted 4 lines · Andrew Zaborowski
--- src/netconfig-commit.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
Applied, thanks.
Regards,
-Denis