Author: bz
Date: Sun Jan 12 17:41:09 2020
New Revision: 356662
URL: https://svnweb.freebsd.org/changeset/base/356662

Log:
  nd6_rtr: constantly use __func__ for nd6log()
  
  Over time one or two hard coded function names did not match the
  actual function anymore.  Consistently use __func__ for nd6log() calls
  and re-wrap/re-format some messages for consitency.
  
  MFC after:    2 weeks

Modified:
  head/sys/netinet6/nd6_rtr.c

Modified: head/sys/netinet6/nd6_rtr.c
==============================================================================
--- head/sys/netinet6/nd6_rtr.c Sun Jan 12 16:58:21 2020        (r356661)
+++ head/sys/netinet6/nd6_rtr.c Sun Jan 12 17:41:09 2020        (r356662)
@@ -177,7 +177,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
        ip6 = mtod(m, struct ip6_hdr *);
        if (ip6->ip6_hlim != 255) {
                nd6log((LOG_ERR,
-                   "nd6_rs_input: invalid hlim (%d) from %s to %s on %s\n",
+                   "%s: invalid hlim (%d) from %s to %s on %s\n", __func__,
                    ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
                    ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
                goto bad;
@@ -205,7 +205,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
        nd6_option_init(nd_rs + 1, icmp6len, &ndopts);
        if (nd6_options(&ndopts) < 0) {
                nd6log((LOG_INFO,
-                   "nd6_rs_input: invalid ND option, ignored\n"));
+                   "%s: invalid ND option, ignored\n", __func__));
                /* nd6_options have incremented stats */
                goto freeit;
        }
@@ -219,9 +219,8 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len)
 
        if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
                nd6log((LOG_INFO,
-                   "nd6_rs_input: lladdrlen mismatch for %s "
-                   "(if %d, RS packet %d)\n",
-                   ip6_sprintf(ip6bufs, &saddr6),
+                   "%s: lladdrlen mismatch for %s (if %d, RS packet %d)\n",
+                   __func__, ip6_sprintf(ip6bufs, &saddr6),
                    ifp->if_addrlen, lladdrlen - 2));
                goto bad;
        }
@@ -377,7 +376,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
        ip6 = mtod(m, struct ip6_hdr *);
        if (ip6->ip6_hlim != 255) {
                nd6log((LOG_ERR,
-                   "nd6_ra_input: invalid hlim (%d) from %s to %s on %s\n",
+                   "%s: invalid hlim (%d) from %s to %s on %s\n", __func__,
                    ip6->ip6_hlim, ip6_sprintf(ip6bufs, &ip6->ip6_src),
                    ip6_sprintf(ip6bufd, &ip6->ip6_dst), if_name(ifp)));
                goto bad;
@@ -386,7 +385,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
        saddr6 = ip6->ip6_src;
        if (!IN6_IS_ADDR_LINKLOCAL(&saddr6)) {
                nd6log((LOG_ERR,
-                   "nd6_ra_input: src %s is not link-local\n",
+                   "%s: src %s is not link-local\n", __func__,
                    ip6_sprintf(ip6bufs, &saddr6)));
                goto bad;
        }
@@ -405,7 +404,7 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
        nd6_option_init(nd_ra + 1, icmp6len, &ndopts);
        if (nd6_options(&ndopts) < 0) {
                nd6log((LOG_INFO,
-                   "nd6_ra_input: invalid ND option, ignored\n"));
+                   "%s: invalid ND option, ignored\n", __func__));
                /* nd6_options have incremented stats */
                goto freeit;
        }
@@ -482,26 +481,25 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
 
                        if (pi->nd_opt_pi_len != 4) {
                                nd6log((LOG_INFO,
-                                   "nd6_ra_input: invalid option "
-                                   "len %d for prefix information option, "
-                                   "ignored\n", pi->nd_opt_pi_len));
+                                   "%s: invalid option len %d for prefix "
+                                   "information option, ignored\n", __func__,
+                                   pi->nd_opt_pi_len));
                                continue;
                        }
 
                        if (128 < pi->nd_opt_pi_prefix_len) {
                                nd6log((LOG_INFO,
-                                   "nd6_ra_input: invalid prefix "
-                                   "len %d for prefix information option, "
-                                   "ignored\n", pi->nd_opt_pi_prefix_len));
+                                   "%s: invalid prefix len %d for prefix "
+                                   "information option, ignored\n", __func__,
+                                   pi->nd_opt_pi_prefix_len));
                                continue;
                        }
 
                        if (IN6_IS_ADDR_MULTICAST(&pi->nd_opt_pi_prefix)
                         || IN6_IS_ADDR_LINKLOCAL(&pi->nd_opt_pi_prefix)) {
                                nd6log((LOG_INFO,
-                                   "nd6_ra_input: invalid prefix "
-                                   "%s, ignored\n",
-                                   ip6_sprintf(ip6bufs,
+                                   "%s: invalid prefix %s, ignored\n",
+                                   __func__, ip6_sprintf(ip6bufs,
                                        &pi->nd_opt_pi_prefix)));
                                continue;
                        }
@@ -538,8 +536,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
 
                /* lower bound */
                if (mtu < IPV6_MMTU) {
-                       nd6log((LOG_INFO, "nd6_ra_input: bogus mtu option "
-                           "mtu=%lu sent from %s, ignoring\n",
+                       nd6log((LOG_INFO, "%s: bogus mtu option mtu=%lu sent "
+                           "from %s, ignoring\n", __func__,
                            mtu, ip6_sprintf(ip6bufs, &ip6->ip6_src)));
                        goto skip;
                }
@@ -557,9 +555,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
                                rt_updatemtu(ifp);
                        }
                } else {
-                       nd6log((LOG_INFO, "nd6_ra_input: bogus mtu "
-                           "mtu=%lu sent from %s; "
-                           "exceeds maxmtu %lu, ignoring\n",
+                       nd6log((LOG_INFO, "%s: bogus mtu=%lu sent from %s; "
+                           "exceeds maxmtu %lu, ignoring\n", __func__,
                            mtu, ip6_sprintf(ip6bufs, &ip6->ip6_src), maxmtu));
                }
        }
@@ -580,8 +577,8 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len)
 
        if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
                nd6log((LOG_INFO,
-                   "nd6_ra_input: lladdrlen mismatch for %s "
-                   "(if %d, RA packet %d)\n", ip6_sprintf(ip6bufs, &saddr6),
+                   "%s: lladdrlen mismatch for %s (if %d, RA packet %d)\n",
+                   __func__, ip6_sprintf(ip6bufs, &saddr6),
                    ifp->if_addrlen, lladdrlen - 2));
                goto bad;
        }
@@ -1223,9 +1220,9 @@ in6_ifadd(struct nd_prefixctl *pr, int mcast)
        plen0 = in6_mask2len(&ib->ia_prefixmask.sin6_addr, NULL);
        if (prefixlen != plen0) {
                ifa_free(ifa);
-               nd6log((LOG_INFO, "in6_ifadd: wrong prefixlen for %s "
-                   "(prefix=%d ifid=%d)\n",
-                   if_name(ifp), prefixlen, 128 - plen0));
+               nd6log((LOG_INFO,
+                   "%s: wrong prefixlen for %s (prefix=%d ifid=%d)\n",
+                   __func__, if_name(ifp), prefixlen, 128 - plen0));
                return NULL;
        }
 
@@ -1278,7 +1275,7 @@ in6_ifadd(struct nd_prefixctl *pr, int mcast)
                updateflags |= IN6_IFAUPDATE_DADDELAY;
        if ((error = in6_update_ifa(ifp, &ifra, NULL, updateflags)) != 0) {
                nd6log((LOG_ERR,
-                   "in6_ifadd: failed to make ifaddr %s on %s (errno=%d)\n",
+                   "%s: failed to make ifaddr %s on %s (errno=%d)\n", __func__,
                    ip6_sprintf(ip6buf, &ifra.ifra_addr.sin6_addr),
                    if_name(ifp), error));
                return (NULL);  /* ifaddr must not have been allocated. */
@@ -1383,8 +1380,8 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_def
                ND6_ONLINK_LOCK();
                NET_EPOCH_ENTER(et);
                if ((error = nd6_prefix_onlink(new)) != 0) {
-                       nd6log((LOG_ERR, "nd6_prelist_add: failed to make "
-                           "the prefix %s/%d on-link on %s (errno=%d)\n",
+                       nd6log((LOG_ERR, "%s: failed to make the prefix %s/%d "
+                           "on-link on %s (errno=%d)\n", __func__,
                            ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
                            pr->ndpr_plen, if_name(pr->ndpr_ifp), error));
                        /* proceed anyway. XXX: is it correct? */
@@ -1441,8 +1438,8 @@ nd6_prefix_del(struct nd_prefix *pr)
                ND6_ONLINK_LOCK();
                if ((e = nd6_prefix_offlink(pr)) != 0) {
                        nd6log((LOG_ERR,
-                           "nd6_prefix_del: failed to make %s/%d offlink "
-                           "on %s, errno=%d\n",
+                           "%s: failed to make the prefix %s/%d offlink on %s "
+                           "(errno=%d)\n", __func__,
                            ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
                            pr->ndpr_plen, if_name(pr->ndpr_ifp), e));
                        /* what should we do? */
@@ -1515,9 +1512,8 @@ prelist_update(struct nd_prefixctl *new, struct nd_def
                        ND6_ONLINK_LOCK();
                        if ((error = nd6_prefix_onlink(pr)) != 0) {
                                nd6log((LOG_ERR,
-                                   "prelist_update: failed to make "
-                                   "the prefix %s/%d on-link on %s "
-                                   "(errno=%d)\n",
+                                   "%s: failed to make the prefix %s/%d "
+                                   "on-link on %s (errno=%d)\n", __func__,
                                    ip6_sprintf(ip6buf,
                                        &pr->ndpr_prefix.sin6_addr),
                                    pr->ndpr_plen, if_name(pr->ndpr_ifp),
@@ -1537,8 +1533,8 @@ prelist_update(struct nd_prefixctl *new, struct nd_def
 
                error = nd6_prelist_add(new, dr, &pr);
                if (error != 0) {
-                       nd6log((LOG_NOTICE, "prelist_update: "
-                           "nd6_prelist_add failed for %s/%d on %s errno=%d\n",
+                       nd6log((LOG_NOTICE, "%s: nd6_prelist_add() failed for "
+                           "the prefix %s/%d on %s (errno=%d)\n", __func__,
                            ip6_sprintf(ip6buf, &new->ndpr_prefix.sin6_addr),
                            new->ndpr_plen, if_name(new->ndpr_ifp), error));
                        goto end; /* we should just give up in this case. */
@@ -1736,9 +1732,8 @@ prelist_update(struct nd_prefixctl *new, struct nd_def
                }
                if (ifidlen + pr->ndpr_plen != 128) {
                        nd6log((LOG_INFO,
-                           "prelist_update: invalid prefixlen "
-                           "%d for %s, ignored\n",
-                           pr->ndpr_plen, if_name(ifp)));
+                           "%s: invalid prefixlen %d for %s, ignored\n",
+                           __func__, pr->ndpr_plen, if_name(ifp)));
                        goto end;
                }
 
@@ -1764,10 +1759,9 @@ prelist_update(struct nd_prefixctl *new, struct nd_def
                        if (V_ip6_use_tempaddr) {
                                int e;
                                if ((e = in6_tmpifadd(ia6, 1, 1)) != 0) {
-                                       nd6log((LOG_NOTICE, "prelist_update: "
-                                           "failed to create a temporary "
-                                           "address, errno=%d\n",
-                                           e));
+                                       nd6log((LOG_NOTICE, "%s: failed to "
+                                           "create a temporary address "
+                                           "(errno=%d)\n", __func__, e));
                                }
                        }
                        ifa_free(&ia6->ia_ifa);
@@ -1931,16 +1925,16 @@ restart:
                        if ((flags & NDPRF_ONLINK) != 0 &&
                            (e = nd6_prefix_offlink(pr)) != 0) {
                                nd6log((LOG_ERR,
-                                   "pfxlist_onlink_check: failed to "
-                                   "make %s/%d offlink, errno=%d\n",
+                                   "%s: failed to make %s/%d offlink "
+                                   "(errno=%d)\n", __func__, 
                                    ip6_sprintf(ip6buf,
                                            &pr->ndpr_prefix.sin6_addr),
                                            pr->ndpr_plen, e));
                        } else if ((flags & NDPRF_ONLINK) == 0 &&
                            (e = nd6_prefix_onlink(pr)) != 0) {
                                nd6log((LOG_ERR,
-                                   "pfxlist_onlink_check: failed to "
-                                   "make %s/%d onlink, errno=%d\n",
+                                   "%s: failed to make %s/%d onlink "
+                                   "(errno=%d)\n", __func__,
                                    ip6_sprintf(ip6buf,
                                            &pr->ndpr_prefix.sin6_addr),
                                            pr->ndpr_plen, e));
@@ -2065,9 +2059,9 @@ nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, stru
                        struct sockaddr_in6 *sin6;
 
                        sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
-                       nd6log((LOG_ERR, "nd6_prefix_onlink: failed to add "
+                       nd6log((LOG_ERR, "%s: failed to add "
                            "route for a prefix (%s/%d) on %s, gw=%s, mask=%s, "
-                           "flags=%lx errno = %d\n",
+                           "flags=%lx errno = %d\n", __func__,
                            ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
                            pr->ndpr_plen, if_name(pr->ndpr_ifp),
                            ip6_sprintf(ip6bufg, &sin6->sin6_addr),
@@ -2159,8 +2153,8 @@ nd6_prefix_onlink(struct nd_prefix *pr)
                 * interface.  This should, of course, be rare though.
                 */
                nd6log((LOG_NOTICE,
-                   "nd6_prefix_onlink: failed to find any ifaddr"
-                   " to add route for a prefix(%s/%d) on %s\n",
+                   "%s: failed to find any ifaddr to add route for a "
+                   "prefix(%s/%d) on %s\n", __func__,
                    ip6_sprintf(ip6buf, &pr->ndpr_prefix.sin6_addr),
                    pr->ndpr_plen, if_name(ifp)));
                return (0);
@@ -2259,10 +2253,9 @@ restart:
                                ND6_RUNLOCK();
                                if ((e = nd6_prefix_onlink(opr)) != 0) {
                                        nd6log((LOG_ERR,
-                                           "nd6_prefix_offlink: failed to "
-                                           "recover a prefix %s/%d from %s "
-                                           "to %s (errno = %d)\n",
-                                           ip6_sprintf(ip6buf,
+                                           "%s: failed to recover a prefix "
+                                           "%s/%d from %s to %s (errno=%d)\n",
+                                           __func__, ip6_sprintf(ip6buf,
                                                &opr->ndpr_prefix.sin6_addr),
                                            opr->ndpr_plen, if_name(ifp),
                                            if_name(opr->ndpr_ifp), e));
@@ -2277,10 +2270,9 @@ restart:
        } else {
                /* XXX: can we still set the NDPRF_ONLINK flag? */
                nd6log((LOG_ERR,
-                   "nd6_prefix_offlink: failed to delete route: "
-                   "%s/%d on %s (errno = %d)\n",
-                   ip6_sprintf(ip6buf, &sa6.sin6_addr), pr->ndpr_plen,
-                   if_name(ifp), error));
+                   "%s: failed to delete route: %s/%d on %s (errno=%d)\n",
+                   __func__, ip6_sprintf(ip6buf, &sa6.sin6_addr),
+                   pr->ndpr_plen, if_name(ifp), error));
        }
 
        if (a_failure)
@@ -2316,8 +2308,8 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcege
   again:
        if (in6_get_tmpifid(ifp, (u_int8_t *)randid,
            (const u_int8_t *)&ia0->ia_addr.sin6_addr.s6_addr[8], forcegen)) {
-               nd6log((LOG_NOTICE, "in6_tmpifadd: failed to find a good "
-                   "random IFID\n"));
+               nd6log((LOG_NOTICE, "%s: failed to find a good random IFID\n",
+                   __func__));
                return (EINVAL);
        }
        ifra.ifra_addr.sin6_addr.s6_addr32[2] |=
@@ -2339,8 +2331,8 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcege
                }
 
                /* Give up.  Something strange should have happened.  */
-               nd6log((LOG_NOTICE, "in6_tmpifadd: failed to "
-                   "find a unique random IFID\n"));
+               nd6log((LOG_NOTICE, "%s: failed to find a unique random IFID\n",
+                   __func__));
                return (EEXIST);
        }
 
@@ -2393,8 +2385,8 @@ in6_tmpifadd(const struct in6_ifaddr *ia0, int forcege
        newia = in6ifa_ifpwithaddr(ifp, &ifra.ifra_addr.sin6_addr);
        if (newia == NULL) {    /* XXX: can it happen? */
                nd6log((LOG_ERR,
-                   "in6_tmpifadd: ifa update succeeded, but we got "
-                   "no ifaddr\n"));
+                   "%s: ifa update succeeded, but we got no ifaddr\n",
+                   __func__));
                return (EINVAL); /* XXX */
        }
        newia->ia6_ndpr = ia0->ia6_ndpr;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to