From 32d735c4128ae3eb25bf5454b68948c781ba70ee Mon Sep 17 00:00:00 2001 From: Anjan Chanda <anjan.chanda@iopsys.eu> Date: Wed, 8 Nov 2023 20:44:04 +0100 Subject: [PATCH] notify ipaddress change of host --- src/neigh.c | 1 + src/neigh.h | 1 + src/netlink.c | 5 +++++ src/ubus.c | 2 ++ 4 files changed, 9 insertions(+) diff --git a/src/neigh.c b/src/neigh.c index a589226..8798592 100644 --- a/src/neigh.c +++ b/src/neigh.c @@ -1109,6 +1109,7 @@ struct neigh_entry *neigh_enqueue(void *nq, uint8_t *macaddr, uint16_t state, if (ip->family == AF_INET) { if (!ipaddr_equal(&e->ipv4, ip)) { memcpy(&e->ipv4, ip, sizeof(*ip)); + e->event_pending = 0; hostmngr_host_event(priv, HOST_EVENT_CONNECT, e); } } diff --git a/src/neigh.h b/src/neigh.h index 0049e2f..a45a033 100644 --- a/src/neigh.h +++ b/src/neigh.h @@ -86,6 +86,7 @@ struct neigh_entry { uint32_t ageing_time; /* in msecs */ struct timeval ageing_tmo; int probe_cnt; + int event_pending; uint32_t num_tcp; uint32_t num_udp; diff --git a/src/netlink.c b/src/netlink.c index 0c4bc95..8a2decb 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -201,6 +201,11 @@ static int hostmngr_handle_neigh_tbl_change(struct hostmngr_private *priv, bool if (!e) { dbg("Skip enqueue WiFi neigh through neigh table change\n"); return 0; + } else { + if (e->event_pending && !ipaddr_is_zero(&e->ipv4)) { + e->event_pending = 0; + hostmngr_host_event(priv, HOST_EVENT_CONNECT, e); + } } } diff --git a/src/ubus.c b/src/ubus.c index e0674af..1a5216c 100644 --- a/src/ubus.c +++ b/src/ubus.c @@ -1209,6 +1209,8 @@ static void hostmngr_wifi_sta_event_handler(struct hostmngr_private *p, if (!ipaddr_is_zero(&new->ipv4)) hostmngr_host_event(p, HOST_EVENT_CONNECT, new); + else + new->event_pending = 1; } } else if (del) { dbg("%s: neigh_dequeue " MACFMT " (priv = %p) >>>\n", -- GitLab