Skip to content

Commit

Permalink
iface_update(): On periodic refresh, only update interface addresses
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
troglobit committed Nov 2, 2018
1 parent 914db4b commit 507652a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ifvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 507652a

Please sign in to comment.