nl_socket_modify_cb(rtnl_event.sock, NL_CB_VALID, NL_CB_CUSTOM,
cb_rtnl_valid, NULL);
- // Receive IPv4 address, IPv6 address, IPv6 routes and neighbor events
+ /* Receive IPv4 address, IPv6 address, IPv6 routes and neighbor events */
if (nl_socket_add_memberships(rtnl_event.sock, RTNLGRP_IPV4_IFADDR,
RTNLGRP_IPV6_IFADDR, RTNLGRP_IPV6_ROUTE,
RTNLGRP_NEIGH, RTNLGRP_LINK, 0))
struct odhcpd_ipaddr *addr = NULL;
struct interface *iface = event_info->iface;
ssize_t len = netlink_get_interface_addrs(iface->ifindex, true, &addr);
+ time_t now = odhcpd_time();
if (len < 0)
return;
bool change = len != (ssize_t)iface->addr6_len;
for (ssize_t i = 0; !change && i < len; ++i)
if (!IN6_ARE_ADDR_EQUAL(&addr[i].addr.in6, &iface->addr6[i].addr.in6) ||
- (addr[i].preferred > 0) != (iface->addr6[i].preferred > 0) ||
+ (addr[i].preferred > (uint32_t)now) != (iface->addr6[i].preferred > (uint32_t)now) ||
addr[i].valid < iface->addr6[i].valid ||
addr[i].preferred < iface->addr6[i].preferred)
change = true;
free(event_info->addrs_old.addrs);
}
-// Handler for neighbor cache entries from the kernel. This is our source
-// to learn and unlearn hosts on interfaces.
+/* Handler for neighbor cache entries from the kernel. This is our source
+ * to learn and unlearn hosts on interfaces. */
static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg)
{
struct nlmsghdr *hdr = nlmsg_hdr(msg);
return NL_SKIP;
inet_ntop(AF_INET6, &event_info.addr, ipbuf, sizeof(ipbuf));
- syslog(LOG_DEBUG, "Netlink %s %s%%%s", add ? "newaddr" : "deladdr",
- ipbuf, event_info.iface->ifname);
+ syslog(LOG_DEBUG, "Netlink %s %s on %s", add ? "newaddr" : "deladdr",
+ ipbuf, event_info.iface->name);
call_netevent_handler_list(add ? NETEV_ADDR6_ADD : NETEV_ADDR6_DEL,
&event_info);
nla_memcpy(&event_info.addr, nla[IFA_LOCAL], sizeof(event_info.addr));
inet_ntop(AF_INET, &event_info.addr, ipbuf, sizeof(ipbuf));
- syslog(LOG_DEBUG, "Netlink %s %s%%%s", add ? "newaddr" : "deladdr",
- ipbuf, event_info.iface->ifname);
+ syslog(LOG_DEBUG, "Netlink %s %s on %s", add ? "newaddr" : "deladdr",
+ ipbuf, event_info.iface->name);
call_netevent_handler_list(add ? NETEV_ADDR_ADD : NETEV_ADDR_DEL,
&event_info);
return NL_SKIP;
inet_ntop(AF_INET6, &event_info.neigh.dst, ipbuf, sizeof(ipbuf));
- syslog(LOG_DEBUG, "Netlink %s %s%%%s", true ? "newneigh" : "delneigh",
- ipbuf, event_info.iface->ifname);
+ syslog(LOG_DEBUG, "Netlink %s %s on %s", true ? "newneigh" : "delneigh",
+ ipbuf, event_info.iface->name);
event_info.neigh.state = ndm->ndm_state;
event_info.neigh.flags = ndm->ndm_flags;
}
-// compare IPv6 prefixes
+/* compare IPv6 prefixes */
static int prefix6_cmp(const void *va, const void *vb)
{
const struct odhcpd_ipaddr *a = va, *b = vb;
}
-// Detect an IPV6-address currently assigned to the given interface
+/* Detect an IPV6-address currently assigned to the given interface */
ssize_t netlink_get_interface_addrs(int ifindex, bool v6, struct odhcpd_ipaddr **addrs)
{
struct nl_msg *msg;