From: Abhishek Sansanwal Date: Wed, 29 Nov 2017 10:42:11 +0000 (+0530) Subject: Change default period of ARP probe to 20 seconds X-Git-Tag: submit/tizen/20171130.074734^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=632fe681c69785d6476159ea4be9fc04adccca5d;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Change default period of ARP probe to 20 seconds Description: When conflict detection is first started the initial few packets are sent at a period of 3 seconds each, and after that the default period of 20 seconds will be applied. In case the conflict is detected the period is again reduced to 3 seconds. Signed-off-by: Abhishek Sansanwal Change-Id: I4e4dd870187996ab75b34de24bdf8f84ef32f68e --- diff --git a/src/ip-conflict-detect.c b/src/ip-conflict-detect.c index 53c1dd1..e538460 100755 --- a/src/ip-conflict-detect.c +++ b/src/ip-conflict-detect.c @@ -45,8 +45,11 @@ #define MAC_ADDRESS_LENGTH 6 #define WLAN_MAC_ADDR_MAX 20 #define ARP_SOURCE_IP "0.0.0.0" +#define INITIAL_BURST_ARP_COUNT 5 -#define MIN_ARP_SEND_TIME 2000 +#define CONFLICT_REMOVE_ITERATION_LIMIT 4 +#define MIN_ARP_SEND_TIME 20000 +#define BURST_ARP_SEND_TIME 3000 #define MAX_ARP_SEND_TIME 32000 #define GRATUITOUS_ARP_MAC_ADDR "00:00:00:00:00:00" #define UCHAR_TO_ADDRESS(hwaddr, buf) do {\ @@ -89,6 +92,7 @@ static struct timer_data td = { }; int ioctl_sock; +static bool initial_bursts = true; bool is_ip_conflict_detect_enabled = true; static gboolean send_arp(gpointer data); static void __netconfig_wifi_notify_ip_conflict(char *state, char *mac); @@ -125,10 +129,12 @@ static gboolean __arp_reply_timeout_cb(gpointer data) if (sd->timer_id != -1) g_source_remove(sd->timer_id); - if (conflict_state != NETCONFIG_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED && sd->iteration == 5) { + if (conflict_state != NETCONFIG_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED && + sd->iteration == CONFLICT_REMOVE_ITERATION_LIMIT) { sd->iteration = 0; conflict_state = NETCONFIG_IP_CONFLICT_STATE_CONFLICT_NOT_DETECTED; __netconfig_wifi_notify_ip_conflict("resolved", GRATUITOUS_ARP_MAC_ADDR); + initial_bursts = true; } sd->timer_id = g_timeout_add(sd->timeout, send_arp, sd); @@ -188,6 +194,7 @@ skip: INFO("ip conflict is detected !\n"); conflict_state = NETCONFIG_IP_CONFLICT_STATE_CONFLICT_DETECTED; __netconfig_wifi_notify_ip_conflict("conflict", sbuf); + sd->timeout = BURST_ARP_SEND_TIME; } if (sd->arp_reply_timer != -1) { @@ -220,6 +227,15 @@ static gboolean send_arp(gpointer data) int ifindex = 0; errno = 0; const char *default_ip = NULL; + static int initial_send_arp_count = 0; + + if (initial_bursts && initial_send_arp_count >= INITIAL_BURST_ARP_COUNT) { + initial_bursts = false; + initial_send_arp_count = 0; + } + + if (initial_bursts) + initial_send_arp_count++; const char *mac = netconfig_get_default_mac_address(); if (mac == NULL) @@ -302,7 +318,10 @@ static gboolean send_arp(gpointer data) g_source_remove(sd->timer_id); - sd->timeout = td.initial_time; + if (conflict_state == NETCONFIG_IP_CONFLICT_STATE_CONFLICT_DETECTED || initial_bursts) + sd->timeout = BURST_ARP_SEND_TIME; + else + sd->timeout = td.initial_time; /* Adding timeout callback for arp request */ sd->arp_reply_timer = g_timeout_add(1000, __arp_reply_timeout_cb, @@ -323,6 +342,7 @@ struct sock_data * start_ip_conflict_mon(void) } char error_buf[MAX_SIZE_ERROR_BUFFER] = {0, }; + initial_bursts = true; sd = g_try_malloc0(sizeof(struct sock_data)); if (sd == NULL) {