Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet replace in_fmtaddr() by IN_PRINT(), and delete f...



details:   https://anonhg.NetBSD.org/src/rev/fa6a78907ee1
branches:  trunk
changeset: 823878:fa6a78907ee1
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri May 12 17:53:53 2017 +0000

description:
replace in_fmtaddr() by IN_PRINT(), and delete function in_fmtaddr()

diffstat:

 sys/netinet/if_arp.c    |  34 +++++++++++++++++-----------------
 sys/netinet/in.c        |  22 ++--------------------
 sys/netinet/in_var.h    |   5 ++---
 sys/netinet/ip_carp.c   |   6 +++---
 sys/netinet/ip_output.c |   6 +++---
 5 files changed, 27 insertions(+), 46 deletions(-)

diffs (275 lines):

diff -r e3ff81495d68 -r fa6a78907ee1 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Fri May 12 12:18:37 2017 +0000
+++ b/sys/netinet/if_arp.c      Fri May 12 17:53:53 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.248 2017/04/04 09:53:02 ozaki-r Exp $     */
+/*     $NetBSD: if_arp.c,v 1.249 2017/05/12 17:53:53 ryo Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.248 2017/04/04 09:53:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.249 2017/05/12 17:53:53 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -688,7 +688,7 @@
        struct in_addr *ip = &IA_SIN(ifa)->sin_addr;
 
        if (ia->ia4_flags & (IN_IFF_NOTREADY | IN_IFF_DETACHED)) {
-               ARPLOG(LOG_DEBUG, "%s not ready\n", ARPLOGADDR(*ip));
+               ARPLOG(LOG_DEBUG, "%s not ready\n", ARPLOGADDR(ip));
                return;
        }
        arprequest(ifp, ip, ip, enaddr);
@@ -1111,7 +1111,7 @@
                ARP_STATINC(ARP_STAT_RCVBADLEN);
                log(LOG_WARNING,
                    "arp from %s: addr len: new %d, i/f %d (ignored)\n",
-                   in_fmtaddr(ipbuf, isaddr), ah->ar_hln, ifp->if_addrlen);
+                   IN_PRINT(ipbuf, &isaddr), ah->ar_hln, ifp->if_addrlen);
                goto out;
        }
 
@@ -1142,7 +1142,7 @@
                ARP_STATINC(ARP_STAT_RCVBCASTSHA);
                log(LOG_ERR,
                    "%s: arp: link address is broadcast for IP address %s!\n",
-                   ifp->if_xname, in_fmtaddr(ipbuf, isaddr));
+                   ifp->if_xname, IN_PRINT(ipbuf, &isaddr));
                goto out;
        }
 
@@ -1204,7 +1204,7 @@
                            "%s tried to overwrite permanent arp info"
                            " for %s\n",
                            lla_snprintf(llabuf, ar_sha(ah), ah->ar_hln),
-                           in_fmtaddr(ipbuf, isaddr));
+                           IN_PRINT(ipbuf, &isaddr));
                        goto out;
                } else if (la->lle_tbl->llt_ifp != ifp) {
                        /* XXX should not happen? */
@@ -1215,7 +1215,7 @@
                            "%s on %s tried to overwrite "
                            "arp info for %s on %s\n",
                            lla_snprintf(llabuf, ar_sha(ah), ah->ar_hln),
-                           ifp->if_xname, in_fmtaddr(ipbuf, isaddr),
+                           ifp->if_xname, IN_PRINT(ipbuf, &isaddr),
                            la->lle_tbl->llt_ifp->if_xname);
                                goto out;
                } else {
@@ -1223,7 +1223,7 @@
                        if (log_movements)
                                log(LOG_INFO, "arp info overwritten "
                                    "for %s by %s\n",
-                                   in_fmtaddr(ipbuf, isaddr),
+                                   IN_PRINT(ipbuf, &isaddr),
                                    lla_snprintf(llabuf, ar_sha(ah),
                                    ah->ar_hln));
                }
@@ -1240,7 +1240,7 @@
                ARP_STATINC(ARP_STAT_RCVLENCHG);
                log(LOG_WARNING,
                    "arp from %s: new addr len %d, was %d\n",
-                   in_fmtaddr(ipbuf, isaddr), ah->ar_hln, sdl->sdl_alen);
+                   IN_PRINT(ipbuf, &isaddr), ah->ar_hln, sdl->sdl_alen);
        }
 #endif
 
@@ -1613,7 +1613,7 @@
        if (!(ia->ia4_flags & IN_IFF_TENTATIVE)) {
                log(LOG_DEBUG,
                    "%s: called with non-tentative address %s(%s)\n", __func__,
-                   in_fmtaddr(ipbuf, ia->ia_addr.sin_addr),
+                   IN_PRINT(ipbuf, &ia->ia_addr.sin_addr),
                    ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
                return;
        }
@@ -1641,7 +1641,7 @@
        if (dp == NULL) {
                mutex_exit(&arp_dad_lock);
                log(LOG_ERR, "%s: memory allocation failed for %s(%s)\n",
-                   __func__, in_fmtaddr(ipbuf, ia->ia_addr.sin_addr),
+                   __func__, IN_PRINT(ipbuf, &ia->ia_addr.sin_addr),
                    ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
                return;
        }
@@ -1659,7 +1659,7 @@
        TAILQ_INSERT_TAIL(&dadq, (struct dadq *)dp, dad_list);
 
        ARPLOG(LOG_DEBUG, "%s: starting DAD for %s\n", if_name(ifa->ifa_ifp),
-           ARPLOGADDR(ia->ia_addr.sin_addr));
+           ARPLOGADDR(&ia->ia_addr.sin_addr));
 
        arp_dad_starttimer(dp, cprng_fast32() % (PROBE_WAIT * hz));
 
@@ -1721,14 +1721,14 @@
        }
        if (ia->ia4_flags & IN_IFF_DUPLICATED) {
                log(LOG_ERR, "%s: called with duplicate address %s(%s)\n",
-                   __func__, in_fmtaddr(ipbuf, ia->ia_addr.sin_addr),
+                   __func__, IN_PRINT(ipbuf, &ia->ia_addr.sin_addr),
                    ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
                goto done;
        }
        if ((ia->ia4_flags & IN_IFF_TENTATIVE) == 0 && dp->dad_arp_acount == 0)
        {
                log(LOG_ERR, "%s: called with non-tentative address %s(%s)\n",
-                   __func__, in_fmtaddr(ipbuf, ia->ia_addr.sin_addr),
+                   __func__, IN_PRINT(ipbuf, &ia->ia_addr.sin_addr),
                    ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
                goto done;
        }
@@ -1768,7 +1768,7 @@
                rt_newaddrmsg(RTM_NEWADDR, ifa, 0, NULL);
                ARPLOG(LOG_DEBUG,
                    "%s: DAD complete for %s - no duplicates found\n",
-                   if_name(ifa->ifa_ifp), ARPLOGADDR(ia->ia_addr.sin_addr));
+                   if_name(ifa->ifa_ifp), ARPLOGADDR(&ia->ia_addr.sin_addr));
                dp->dad_arp_announce = ANNOUNCE_NUM;
                goto announce;
        } else if (dp->dad_arp_acount < dp->dad_arp_announce) {
@@ -1784,7 +1784,7 @@
                }
                ARPLOG(LOG_DEBUG,
                    "%s: ARP announcement complete for %s\n",
-                   if_name(ifa->ifa_ifp), ARPLOGADDR(ia->ia_addr.sin_addr));
+                   if_name(ifa->ifa_ifp), ARPLOGADDR(&ia->ia_addr.sin_addr));
        }
 
        TAILQ_REMOVE(&dadq, dp, dad_list);
@@ -1811,7 +1811,7 @@
        char ipbuf[INET_ADDRSTRLEN];
        const char *iastr;
 
-       iastr = in_fmtaddr(ipbuf, ia->ia_addr.sin_addr);
+       iastr = IN_PRINT(ipbuf, &ia->ia_addr.sin_addr);
 
        if (ia->ia4_flags & (IN_IFF_TENTATIVE|IN_IFF_DUPLICATED)) {
                log(LOG_ERR,
diff -r e3ff81495d68 -r fa6a78907ee1 sys/netinet/in.c
--- a/sys/netinet/in.c  Fri May 12 12:18:37 2017 +0000
+++ b/sys/netinet/in.c  Fri May 12 17:53:53 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in.c,v 1.200 2017/04/28 05:56:33 ozaki-r Exp $ */
+/*     $NetBSD: in.c,v 1.201 2017/05/12 17:53:53 ryo Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.200 2017/04/28 05:56:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.201 2017/05/12 17:53:53 ryo Exp $");
 
 #include "arp.h"
 
@@ -295,24 +295,6 @@
 }
 
 /*
- *  Routine to take an Internet address and convert into a
- *  "dotted quad" representation for printing.
- *  Caller has to make sure that buf is at least INET_ADDRSTRLEN long.
- */
-const char *
-in_fmtaddr(char *buf, struct in_addr addr)
-{
-       addr.s_addr = ntohl(addr.s_addr);
-
-       snprintf(buf, INET_ADDRSTRLEN, "%d.%d.%d.%d",
-           (addr.s_addr >> 24) & 0xFF,
-           (addr.s_addr >> 16) & 0xFF,
-           (addr.s_addr >>  8) & 0xFF,
-           (addr.s_addr >>  0) & 0xFF);
-       return buf;
-}
-
-/*
  * Maintain the "in_maxmtu" variable, which is the largest
  * mtu for non-local interfaces with AF_INET addresses assigned
  * to them that are up.
diff -r e3ff81495d68 -r fa6a78907ee1 sys/netinet/in_var.h
--- a/sys/netinet/in_var.h      Fri May 12 12:18:37 2017 +0000
+++ b/sys/netinet/in_var.h      Fri May 12 17:53:53 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_var.h,v 1.94 2017/01/16 15:44:05 christos Exp $     */
+/*     $NetBSD: in_var.h,v 1.95 2017/05/12 17:53:54 ryo Exp $  */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -380,7 +380,7 @@
 extern int ip_dad_count;               /* Duplicate Address Detection probes */
 #if defined(INET) && NARP > 0
 extern int arp_debug;
-#define ARPLOGADDR(a) in_fmtaddr(_ipbuf, a)
+#define ARPLOGADDR(a) IN_PRINT(_ipbuf, a)
 #define ARPLOG(level, fmt, args...)                                    \
        do {                                                            \
                char _ipbuf[INET_ADDRSTRLEN];                           \
@@ -420,7 +420,6 @@
 void   in_restoremkludge(struct in_ifaddr *, struct ifnet *);
 void   in_purgemkludge(struct ifnet *);
 void   in_setmaxmtu(void);
-const char *in_fmtaddr(char *, struct in_addr);
 int    in_control(struct socket *, u_long, void *, struct ifnet *);
 void   in_purgeaddr(struct ifaddr *);
 void   in_purgeif(struct ifnet *);
diff -r e3ff81495d68 -r fa6a78907ee1 sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c     Fri May 12 12:18:37 2017 +0000
+++ b/sys/netinet/ip_carp.c     Fri May 12 17:53:53 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_carp.c,v 1.88 2017/05/12 09:22:01 roy Exp $ */
+/*     $NetBSD: ip_carp.c,v 1.89 2017/05/12 17:53:54 ryo Exp $ */
 /*     $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $   */
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.88 2017/05/12 09:22:01 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.89 2017/05/12 17:53:54 ryo Exp $");
 
 /*
  * TODO:
@@ -725,7 +725,7 @@
                case AF_INET:
                        ip = mtod(m, struct ip *);
                        CARP_LOG(sc, ("incorrect hash from %s", 
-                           in_fmtaddr(ipbuf, ip->ip_src)));
+                           IN_PRINT(ipbuf, &ip->ip_src)));
                        break;
 
 #ifdef INET6
diff -r e3ff81495d68 -r fa6a78907ee1 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Fri May 12 12:18:37 2017 +0000
+++ b/sys/netinet/ip_output.c   Fri May 12 17:53:53 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_output.c,v 1.278 2017/05/10 09:34:51 ozaki-r Exp $  */
+/*     $NetBSD: ip_output.c,v 1.279 2017/05/12 17:53:54 ryo Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.278 2017/05/10 09:34:51 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.279 2017/05/12 17:53:54 ryo Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -624,7 +624,7 @@
        {
                ARPLOG(LOG_ERR,
                    "refusing to send from invalid address %s (pid %d)\n",
-                   ARPLOGADDR(ip->ip_src), curproc->p_pid);
+                   ARPLOGADDR(&ip->ip_src), curproc->p_pid);
                IP_STATINC(IP_STAT_ODROPPED);
                if (error == 1)
                        /*



Home | Main Index | Thread Index | Old Index