From b79bb64dd5f781b138fe09c4b8e7485f04e8dcb4 Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Tue, 23 Oct 2018 11:22:06 +0530 Subject: [PATCH] Start IP conflict monitoring only after default profile has been updated Signed-off-by: Abhishek Sansanwal Change-Id: I113a4f033a5bb398a494195fb4de11957cd7e7ff --- src/ip-conflict-detect.c | 10 +++++++++- src/signal-handler.c | 28 +++++++++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/ip-conflict-detect.c b/src/ip-conflict-detect.c index 0490866..4f9fc98 100755 --- a/src/ip-conflict-detect.c +++ b/src/ip-conflict-detect.c @@ -226,6 +226,7 @@ static gboolean send_arp(gpointer data) int ifindex = 0; errno = 0; const char *default_ip = NULL; + const char *if_name = NULL; static int initial_send_arp_count = 0; if (initial_bursts && initial_send_arp_count >= INITIAL_BURST_ARP_COUNT) { @@ -272,7 +273,14 @@ static gboolean send_arp(gpointer data) memset(&net_ifr, 0, sizeof(net_ifr)); /* ifreq structure creation */ - size_t if_name_len = strlen(netconfig_get_default_ifname()); + if_name = netconfig_get_default_ifname(); + size_t if_name_len = strlen(if_name); + + if (if_name_len == 0) { + INFO("Error : Unable to get interface name "); + goto err; + } + if (if_name_len < sizeof(net_ifr.ifr_name)) { memcpy(net_ifr.ifr_name, netconfig_get_default_ifname(), if_name_len); net_ifr.ifr_name[if_name_len] = 0; diff --git a/src/signal-handler.c b/src/signal-handler.c index 0552b46..8d7b66b 100755 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -326,19 +326,6 @@ static void _service_signal_cb(GDBusConnection *conn, g_variant_get(variant, "s", &property); DBG("[%s] %s", property, path); - if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) { - if (g_strcmp0(property, "ready") == 0) { - for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) { - sd = start_ip_conflict_mon(); - if (sd != NULL) - break; - } - } else if (g_strcmp0(property, "online") == 0) { - // do nothing - } else { - stop_ip_conflict_mon(); - } - } if (netconfig_is_wifi_profile(path) == TRUE) { int wifi_state = 0; @@ -453,6 +440,21 @@ static void _service_signal_cb(GDBusConnection *conn, netconfig_update_default_profile(NULL); } } + + if (netconfig_is_wifi_profile(path) || netconfig_is_ethernet_profile(path)) { + if (g_strcmp0(property, "ready") == 0) { + for (idx = 0; idx < MAX_SOCKET_OPEN_RETRY; idx++) { + sd = start_ip_conflict_mon(); + if (sd != NULL) + break; + } + } else if (g_strcmp0(property, "online") == 0) { + // do nothing + } else { + stop_ip_conflict_mon(); + } + } + g_free(property); } else if (g_strcmp0(sigvalue, "Proxy") == 0) { if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0) -- 2.34.1