odhcpd: extra syslog tracing
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 26 Jan 2017 14:23:36 +0000 (15:23 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 26 Jan 2017 17:22:52 +0000 (18:22 +0100)
Add extra syslog tracing for trouble shooting
and make some syslog traces more self explaining

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/odhcpd.c
src/router.c

index e83a7007c36b3701f4e2ce272c4b44710d7dcec4..6a3ba868436d5c7f5eacbe02b7893858d4a66d6a 100644 (file)
@@ -219,8 +219,10 @@ ssize_t odhcpd_get_interface_addresses(int ifindex,
                struct ifaddrmsg ifa;
        } req = {{sizeof(req), RTM_GETADDR, NLM_F_REQUEST | NLM_F_DUMP,
                        ++rtnl_seq, 0}, {AF_INET6, 0, 0, 0, ifindex}};
-       if (send(rtnl_socket, &req, sizeof(req), 0) < (ssize_t)sizeof(req))
+       if (send(rtnl_socket, &req, sizeof(req), 0) < (ssize_t)sizeof(req)) {
+               syslog(LOG_WARNING, "Request failed to dump IPv6 addresses (%s)", strerror(errno));
                return 0;
+       }
 
        uint8_t buf[8192];
        ssize_t len = 0, ret = 0;
@@ -232,13 +234,16 @@ ssize_t odhcpd_get_interface_addresses(int ifindex,
                        if (len < 0 || !NLMSG_OK(nhm, (size_t)len)) {
                                if (errno == EINTR)
                                        continue;
-                               else
-                                       return ret;
+
+                               syslog(LOG_WARNING, "Failed to receive IPv6 address rtnetlink message (%s)", strerror(errno));
+                               return ret;
                        }
                }
 
-               if (nhm->nlmsg_type != RTM_NEWADDR)
+               if (nhm->nlmsg_type != RTM_NEWADDR) {
+                       syslog(LOG_WARNING, "Unexpected rtnetlink message (%d) in response to IPv6 address dump", nhm->nlmsg_type);
                        break;
+               }
 
                // Skip address but keep clearing socket buffer
                if (ret >= (ssize_t)cnt)
index c410a9ceaf74742ee5dc82f55af6a9cac5a889a4..37ba14f2de747b10dc9d4da66f97a22f00e2b9f6 100644 (file)
@@ -263,8 +263,8 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                else if (parse_routes(addrs, ipcnt))
                        adv.h.nd_ra_router_lifetime = htons(1);
 
-               syslog(LOG_INFO, "Initial router lifetime %d, %d address(es) available",
-                               ntohs(adv.h.nd_ra_router_lifetime), (int)ipcnt);
+               syslog(LOG_INFO, "Initial RA router lifetime %d, %d address(es) available on %s",
+                               ntohs(adv.h.nd_ra_router_lifetime), (int)ipcnt, iface->ifname);
        }
 
        // Construct Prefix Information options
@@ -282,8 +282,8 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                        char namebuf[INET6_ADDRSTRLEN];
 
                        inet_ntop(AF_INET6, addr, namebuf, sizeof(namebuf));
-                       syslog(LOG_INFO, "Address %s (prefix %d, valid %u) not suitable",
-                                       namebuf, addr->prefix, addr->valid);
+                       syslog(LOG_INFO, "Address %s (prefix %d, valid %u) not suitable as RA prefix on %s",
+                                       namebuf, addr->prefix, addr->valid, iface->ifname);
                        continue;
                }
 
@@ -314,7 +314,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
                                && ntohs(adv.h.nd_ra_router_lifetime) < this_lifetime) {
                        adv.h.nd_ra_router_lifetime = htons(this_lifetime);
 
-                       syslog(LOG_DEBUG, "Updating router lifetime to %d", this_lifetime);
+                       syslog(LOG_INFO, "Updating RA router lifetime to %d on %s", this_lifetime, iface->ifname);
                }
 
                odhcpd_bmemcpy(&p->nd_opt_pi_prefix, &addr->addr,