treewide: align syslog tracing
[oweals/odhcpd.git] / src / netlink.c
index 56d35df86a222839dfc23efa65d709c338e09c2b..9ed91b19500c295a83940b9f970c96fe479459f2 100644 (file)
@@ -78,7 +78,7 @@ int netlink_init(void)
        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))
@@ -160,6 +160,7 @@ static void refresh_iface_addr6(struct netevent_handler_info *event_info)
        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;
@@ -167,7 +168,7 @@ static void refresh_iface_addr6(struct netevent_handler_info *event_info)
        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;
@@ -184,8 +185,8 @@ static void refresh_iface_addr6(struct netevent_handler_info *event_info)
        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);
@@ -277,8 +278,8 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg)
                                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);
@@ -291,8 +292,8 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg)
                        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);
@@ -328,8 +329,8 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg)
                        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;
@@ -500,7 +501,7 @@ static int prefix_cmp(const void *va, const void *vb)
 }
 
 
-// compare IPv6 prefixes
+/* compare IPv6 prefixes */
 static int prefix6_cmp(const void *va, const void *vb)
 {
        const struct odhcpd_ipaddr *a = va, *b = vb;
@@ -510,7 +511,7 @@ static int prefix6_cmp(const void *va, const void *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;