ia->mask = *mask;
ia->brd = *bcast;
+#ifdef IP_LIFETIME
ia->vltime = vltime;
ia->pltime = pltime;
+#else
+ UNUSED(vltime);
+ UNUSED(pltime);
+#endif
snprintf(ia->saddr, sizeof(ia->saddr), "%s/%d",
inet_ntoa(*addr), inet_ntocidr(*mask));
return;
}
-#if __linux__
- /* If the netmask or broadcast is different, re-add the addresss */
ia = ipv4_iffindaddr(ifp, &lease->addr, NULL);
- if (ia != NULL &&
+ /* If the netmask or broadcast is different, re-add the addresss.
+ * If IP addresses do not have lifetimes, there is a very real chance
+ * that re-adding them will scrub the subnet route temporarily
+ * which is a bad thing, so avoid it. */
+ if (ia == NULL &&
(ia->mask.s_addr != lease->mask.s_addr ||
ia->brd.s_addr != lease->brd.s_addr))
- ipv4_deladdr(ia, 0);
+ {
+#ifdef __linux__
+ if (ia != NULL)
+ ipv4_deladdr(ia, 0);
+#elif !defined(IP_LIFETIME)
+ if (ipv4_daddaddr(ifp, lease) == -1 && errno != EEXIST)
+ return;
#endif
+ }
+#if IP_LIFETIME
if (ipv4_daddaddr(ifp, lease) == -1 && errno != EEXIST)
return;
+#endif
ia = ipv4_iffindaddr(ifp, &lease->addr, NULL);
if (ia == NULL) {
#define IN_ARE_ADDR_EQUAL(a, b) ((a)->s_addr == (b)->s_addr)
#define IN_IS_ADDR_UNSPECIFIED(a) ((a)->s_addr == INADDR_ANY)
+#ifdef __linux__
+#define IP_LIFETIME
+#endif
+
struct ipv4_addr {
TAILQ_ENTRY(ipv4_addr) next;
struct in_addr addr;
struct interface *iface;
int addr_flags;
unsigned int flags;
+#ifdef IP_LIFETIME
uint32_t vltime;
uint32_t pltime;
+#endif
char saddr[INET_ADDRSTRLEN + 3];
#ifdef ALIAS_ADDR
char alias[IF_NAMESIZE];