From 507652a23392611a11683c795e71ff2e6ec5da3a Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 2 Nov 2018 13:44:34 +0100 Subject: [PATCH] iface_update(): On periodic refresh, only update interface addresses We periodically refresh our cache of interfaces, in case an interface did not have an address at startup/SIGHUP. On refresh we currently don't want to add new interfaces (see GitHub issue #55), only refresh the address of existing ones so we can retry failed IGMP joins. Signed-off-by: Joachim Nilsson --- src/ifvc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ifvc.c b/src/ifvc.c index bf0d79e4..c46929b9 100644 --- a/src/ifvc.c +++ b/src/ifvc.c @@ -41,6 +41,7 @@ static struct iface *iface_list = NULL; /** * iface_update - Periodic check of new interfaces or addresses + * @refresh: Only update interface addresses * * This functions is not only called by iface_init() at startup or * SIGHUP, it is also called periodically to check if known ifaces @@ -55,7 +56,7 @@ static struct iface *iface_list = NULL; * %TRUE(1), at least one interface added or updated, otherwise * %FALSE(0) if there was no change. */ -int iface_update(void) +int iface_update(int refresh) { struct ifaddrs *ifaddr, *ifa; struct iface *iface; @@ -76,6 +77,9 @@ int iface_update(void) continue; } + if (refresh) + continue; + /* Allocate more space? */ if (num_ifaces == num_ifaces_alloc) { num_ifaces_alloc *= 2; @@ -133,14 +137,14 @@ void iface_init(void) exit(255); } - iface_update(); + iface_update(0); } void iface_refresh(void *arg) { (void)arg; - if (!iface_update()) + if (!iface_update(1)) return; mcgroup_refresh();