Skip to content
Permalink
Browse files

netlink.c: recognize new interfaces coming up

Compared to the 1.x release the 2.x release lost the ability to
immediately setup new interfaces coming up. This patch adds code
to make it work again.
  • Loading branch information
Volker Rümelin authored and reubenhwk committed Dec 31, 2014
1 parent f82de63 commit 4a32c5e4392bb85955bea70a445a68f47945742a
Showing with 31 additions and 4 deletions.
  1. +20 −2 interface.c
  2. +10 −2 netlink.c
  3. +1 −0 radvd.h
@@ -17,6 +17,8 @@
#include "radvd.h"
#include "defaults.h"

#define IFACE_SETUP_DELAY 1

void iface_init_defaults(struct Interface *iface)
{
memset(iface, 0, sizeof(struct Interface));
@@ -280,6 +282,21 @@ struct Interface *find_iface_by_index(struct Interface *iface, int index)
return 0;
}

struct Interface *find_iface_by_name(struct Interface *iface, const char *name)
{
if (!name) {
return 0;
}

for (; iface; iface = iface->next) {
if (strcmp(iface->props.name, name) == 0) {
return iface;
}
}

return 0;
}

struct Interface *find_iface_by_time(struct Interface *iface)
{
if (!iface) {
@@ -305,8 +322,9 @@ void reschedule_iface(struct Interface *iface, double next)
#ifdef HAVE_NETLINK
if (!iface->state_info.changed && !iface->state_info.ready) {
next = 10 * iface->MaxRtrAdvInterval;
}
else
} else if (next == 0) {
next = IFACE_SETUP_DELAY;
} else
#endif
if (iface->state_info.racount < MAX_INITIAL_RTR_ADVERTISEMENTS) {
next = min(MAX_INITIAL_RTR_ADVERT_INTERVAL, iface->MaxRtrAdvInterval);
@@ -76,8 +76,16 @@ void process_netlink_msg(int sock, struct Interface * ifaces)
}
}

/* Reinit the interfaces which needs it. */
struct Interface *iface = find_iface_by_index(ifaces, ifinfo->ifi_index);
/* Reinit the interfaces which need it. */
struct Interface *iface;
switch (nh->nlmsg_type) {
case RTM_NEWLINK:
iface = find_iface_by_name(ifaces, ifname);
break;
default:
iface = find_iface_by_index(ifaces, ifinfo->ifi_index);
break;
}
if (iface) {
touch_iface(iface);
}
@@ -279,6 +279,7 @@ int update_device_info(int sock, struct Interface *);
int check_iface(struct Interface *);
int setup_iface(int sock, struct Interface *iface);
struct Interface *find_iface_by_index(struct Interface *iface, int index);
struct Interface *find_iface_by_name(struct Interface *iface, const char *name);
struct Interface *find_iface_by_time(struct Interface *iface_list);
void dnssl_init_defaults(struct AdvDNSSL *, struct Interface *);
void for_each_iface(struct Interface *ifaces, void (*foo) (struct Interface * iface, void *), void *data);

0 comments on commit 4a32c5e

Please sign in to comment.