Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/rtadvd PR/52618: Shinichi Doyashiki: Don't exit if ...



details:   https://anonhg.NetBSD.org/src/rev/ff9d25392369
branches:  trunk
changeset: 827109:ff9d25392369
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 14 19:16:26 2017 +0000

description:
PR/52618: Shinichi Doyashiki: Don't exit if adding interface to multicast
group fails. This happens with empty vlan interfaces

- make syscalls checks against -1
- fix errors to print %s: instead of <%s>

XXX: if_vlan is the only pseudo interface in net/ that returns such an
error..

diffstat:

 usr.sbin/rtadvd/rtadvd.c |  207 +++++++++++++++++++++++-----------------------
 1 files changed, 103 insertions(+), 104 deletions(-)

diffs (truncated from 806 to 300 lines):

diff -r 73bebda27176 -r ff9d25392369 usr.sbin/rtadvd/rtadvd.c
--- a/usr.sbin/rtadvd/rtadvd.c  Sat Oct 14 18:41:44 2017 +0000
+++ b/usr.sbin/rtadvd/rtadvd.c  Sat Oct 14 19:16:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtadvd.c,v 1.55 2017/09/11 14:12:28 christos Exp $     */
+/*     $NetBSD: rtadvd.c,v 1.56 2017/10/14 19:16:26 christos Exp $     */
 /*     $KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $    */
 
 /*
@@ -316,7 +316,7 @@
 
                if (do_reconf) { /* SIGHUP */
                        do_reconf = 0;
-                       syslog(LOG_INFO, "<%s> reloading config on SIGHUP",
+                       syslog(LOG_INFO, "%s: reloading config on SIGHUP",
                               __func__);
                        argc = if_argc;
                        argv = if_argv;
@@ -334,22 +334,22 @@
 
                if (timeout != NULL) {
                        syslog(LOG_DEBUG,
-                           "<%s> set timer to %jd:%jd. waiting for "
+                           "%s: set timer to %jd:%jd. waiting for "
                            "inputs or timeout", __func__,
                            (intmax_t)timeout->tv_sec,
                            (intmax_t)timeout->tv_nsec);
                } else {
                        syslog(LOG_DEBUG,
-                           "<%s> there's no timer. waiting for inputs",
+                           "%s: there's no timer. waiting for inputs",
                            __func__);
                }
 
                if ((i = prog_poll(set, 2, timeout ? (timeout->tv_sec * 1000 +
-                   (timeout->tv_nsec + 999999) / 1000000) : INFTIM)) < 0)
+                   (timeout->tv_nsec + 999999) / 1000000) : INFTIM)) == -1)
                {
                        /* EINTR would occur upon SIGUSR1 for status dump */
                        if (errno != EINTR)
-                               syslog(LOG_ERR, "<%s> poll: %m", __func__);
+                               syslog(LOG_ERR, "%s: poll: %m", __func__);
                        continue;
                }
                if (i == 0)     /* timeout */
@@ -394,11 +394,11 @@
        if (waiting) {
                if (TAILQ_FIRST(&ralist)) {
                        syslog(LOG_INFO,
-                              "<%s> waiting for expiration of all RA timers",
+                              "%s: waiting for expiration of all RA timers",
                               __func__);
                        return;
                }
-               syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
+               syslog(LOG_NOTICE, "%s: gracefully terminated", __func__);
                free(rcvcmsgbuf);
                free(sndcmsgbuf);
                exit(EXIT_SUCCESS);
@@ -406,13 +406,13 @@
        }
 
        if (TAILQ_FIRST(&ralist) == NULL) {
-               syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
+               syslog(LOG_NOTICE, "%s: gracefully terminated", __func__);
                exit(EXIT_SUCCESS);
                /* NOT REACHED */
        }
 
        waiting = 1;
-       syslog(LOG_NOTICE, "<%s> final RA transmission started", __func__);
+       syslog(LOG_NOTICE, "%s: final RA transmission started", __func__);
 
        TAILQ_FOREACH_SAFE(rai, &ralist, next, ran) {
                if (rai->leaving) {
@@ -467,7 +467,7 @@
 
        msg = buffer.data;
        if (dflag > 1) {
-               syslog(LOG_DEBUG, "<%s> received a routing message "
+               syslog(LOG_DEBUG, "%s: received a routing message "
                    "(type = %d, len = %d)", __func__, rtmsg_type(msg),
                    rtmsg_len(msg));
        }
@@ -478,7 +478,7 @@
                 */
                if (dflag > 1)
                        syslog(LOG_DEBUG,
-                           "<%s> received data length is larger than "
+                           "%s: received data length is larger than "
                            "1st routing message len. multiple messages? "
                            "read %d bytes, but 1st msg len = %d",
                            __func__, n, rtmsg_len(msg));
@@ -518,7 +518,7 @@
                        ifindex = get_ifan_ifindex(next);
                        if (get_ifan_what(next) == IFAN_ARRIVAL) {
                                syslog(LOG_DEBUG,
-                                      "<%s> interface %s arrived",
+                                      "%s: interface %s arrived",
                                       __func__,
                                       if_indextoname(ifindex, ifname));
                                if (if_argc == 0) {
@@ -543,9 +543,8 @@
                default:
                        /* should not reach here */
                        if (dflag > 1) {
-                               syslog(LOG_DEBUG,
-                                      "<%s:%d> unknown rtmsg %d on %s",
-                                      __func__, __LINE__, type,
+                               syslog(LOG_DEBUG, "%s: unknown rtmsg %d on %s",
+                                      __func__, type,
                                       if_indextoname(ifindex, ifname));
                        }
                        continue;
@@ -554,7 +553,7 @@
                if ((rai = if_indextorainfo(ifindex)) == NULL) {
                        if (dflag > 1) {
                                syslog(LOG_DEBUG,
-                                      "<%s> route changed on "
+                                      "%s: route changed on "
                                       "non advertising interface %s (%d)",
                                       __func__,
                                       if_indextoname(ifindex, ifname),
@@ -577,7 +576,7 @@
                        /* sanity check for plen */
                        /* as RFC2373, prefixlen is at least 4 */
                        if (plen < 4 || plen > 127) {
-                               syslog(LOG_INFO, "<%s> new interface route's"
+                               syslog(LOG_INFO, "%s: new interface route's"
                                    "plen %d is invalid for a prefix",
                                    __func__, plen);
                                break;
@@ -593,7 +592,7 @@
                                        prefixchange = 1;
                                } else if (dflag > 1) {
                                        syslog(LOG_DEBUG,
-                                           "<%s> new prefix(%s/%d) "
+                                           "%s: new prefix(%s/%d) "
                                            "added on %s, "
                                            "but it was already in list",
                                            __func__,
@@ -619,7 +618,7 @@
                        /* as RFC2373, prefixlen is at least 4 */
                        if (plen < 4 || plen > 127) {
                                syslog(LOG_INFO,
-                                   "<%s> deleted interface route's "
+                                   "%s: deleted interface route's "
                                    "plen %d is invalid for a prefix",
                                    __func__, plen);
                                break;
@@ -628,7 +627,7 @@
                        if (prefix == NULL) {
                                if (dflag > 1) {
                                        syslog(LOG_DEBUG,
-                                           "<%s> prefix(%s/%d) was "
+                                           "%s: prefix(%s/%d) was "
                                            "deleted on %s, "
                                            "but it was not in list",
                                            __func__,
@@ -653,7 +652,7 @@
                case RTM_IFANNOUNCE:
                        if (get_ifan_what(next) == IFAN_DEPARTURE) {
                                syslog(LOG_DEBUG,
-                                      "<%s> interface %s departed",
+                                      "%s: interface %s departed",
                                       __func__, rai->ifname);
                                TAILQ_REMOVE(&ralist, rai, next);
                                if (rai->leaving)
@@ -667,8 +666,8 @@
                        /* should not reach here */
                        if (dflag > 1) {
                                syslog(LOG_DEBUG,
-                                   "<%s:%d> unknown rtmsg %d on %s",
-                                   __func__, __LINE__, type,
+                                   "%s: unknown rtmsg %d on %s",
+                                   __func__, type,
                                    if_indextoname(ifindex, ifname));
                        }
                        return;
@@ -678,13 +677,13 @@
                if ((oldifflags & IFF_UP) != 0 &&       /* UP to DOWN */
                    (rai->ifflags & IFF_UP) == 0) {
                        syslog(LOG_INFO,
-                           "<%s> interface %s becomes down. stop timer.",
+                           "%s: interface %s becomes down. stop timer.",
                            __func__, rai->ifname);
                        rtadvd_remove_timer(&rai->timer);
                } else if ((oldifflags & IFF_UP) == 0 && /* DOWN to UP */
                         (rai->ifflags & IFF_UP) != 0) {
                        syslog(LOG_INFO,
-                           "<%s> interface %s becomes up. restart timer.",
+                           "%s: interface %s becomes up. restart timer.",
                            __func__, rai->ifname);
 
                        rai->initcounter = 0; /* reset the counter */
@@ -729,7 +728,7 @@
         * receive options.
         */
        rcvmhdr.msg_controllen = rcvcmsgbuflen;
-       if ((i = prog_recvmsg(sock, &rcvmhdr, 0)) < 0)
+       if ((i = prog_recvmsg(sock, &rcvmhdr, 0)) == -1)
                return;
 
        /* We read the buffer first to clear the FD */
@@ -754,13 +753,13 @@
        }
        if (ifindex == 0) {
                syslog(LOG_ERR,
-                      "<%s> failed to get receiving interface",
+                      "%s: failed to get receiving interface",
                       __func__);
                return;
        }
        if (hlimp == NULL) {
                syslog(LOG_ERR,
-                      "<%s> failed to get receiving hop limit",
+                      "%s: failed to get receiving hop limit",
                       __func__);
                return;
        }
@@ -768,7 +767,7 @@
        if ((rai = if_indextorainfo(pi->ipi6_ifindex)) == NULL) {
                if (dflag > 1) {
                        syslog(LOG_DEBUG,
-                              "<%s> received data for non advertising "
+                              "%s: received data for non advertising "
                               "interface (%s)",
                               __func__,
                               if_indextoname(pi->ipi6_ifindex, ifnamebuf));
@@ -781,7 +780,7 @@
         */
        if ((rai->ifflags & IFF_UP) == 0) {
                syslog(LOG_INFO,
-                      "<%s> received data on a disabled interface (%s)",
+                      "%s: received data on a disabled interface (%s)",
                       __func__,
                       if_indextoname(pi->ipi6_ifindex, ifnamebuf));
                return;
@@ -790,7 +789,7 @@
 #ifdef OLDRAWSOCKET
        if ((size_t)i < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) {
                syslog(LOG_ERR,
-                      "<%s> packet size(%d) is too short",
+                      "%s: packet size(%d) is too short",
                       __func__, i);
                return;
        }
@@ -800,7 +799,7 @@
 #else
        if ((size_t)i < sizeof(struct icmp6_hdr)) {
                syslog(LOG_ERR,
-                      "<%s> packet size(%zd) is too short",
+                      "%s: packet size(%zd) is too short",
                       __func__, i);
                return;
        }
@@ -817,7 +816,7 @@
                 */
                if (*hlimp != 255) {
                        syslog(LOG_NOTICE,
-                           "<%s> RS with invalid hop limit(%d) "
+                           "%s: RS with invalid hop limit(%d) "
                            "received from %s on %s",
                            __func__, *hlimp,
                            inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf,
@@ -827,7 +826,7 @@
                }
                if (icp->icmp6_code) {
                        syslog(LOG_NOTICE,
-                           "<%s> RS with invalid ICMP6 code(%d) "
+                           "%s: RS with invalid ICMP6 code(%d) "
                            "received from %s on %s",
                            __func__, icp->icmp6_code,
                            inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf,
@@ -837,7 +836,7 @@
                }
                if ((size_t)i < sizeof(struct nd_router_solicit)) {
                        syslog(LOG_NOTICE,
-                           "<%s> RS from %s on %s does not have enough "
+                           "%s: RS from %s on %s does not have enough "
                            "length (len = %zd)",
                            __func__,
                            inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf,
@@ -854,7 +853,7 @@
                 */
                if (*hlimp != 255) {
                        syslog(LOG_NOTICE,
-                           "<%s> RA with invalid hop limit(%d) "
+                           "%s: RA with invalid hop limit(%d) "
                            "received from %s on %s",
                            __func__, *hlimp,
                            inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf,
@@ -864,7 +863,7 @@
                }
                if (icp->icmp6_code) {
                        syslog(LOG_NOTICE,
-                           "<%s> RA with invalid ICMP6 code(%d) "
+                           "%s: RA with invalid ICMP6 code(%d) "
                            "received from %s on %s",
                            __func__, icp->icmp6_code,



Home | Main Index | Thread Index | Old Index