Module Name: src Committed By: christos Date: Mon Jan 16 15:14:16 UTC 2017
Modified Files: src/sys/netinet: if_arp.c in_var.h ip_output.c Log Message: rename arplog -> ARPLOG to make it clear that it is a macro and tuck-in the buffer used for address formatting. To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/netinet/if_arp.c cvs rdiff -u -r1.92 -r1.93 src/sys/netinet/in_var.h cvs rdiff -u -r1.268 -r1.269 src/sys/netinet/ip_output.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/if_arp.c diff -u src/sys/netinet/if_arp.c:1.234 src/sys/netinet/if_arp.c:1.235 --- src/sys/netinet/if_arp.c:1.234 Mon Jan 16 02:33:36 2017 +++ src/sys/netinet/if_arp.c Mon Jan 16 10:14:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.234 2017/01/16 07:33:36 ryo Exp $ */ +/* $NetBSD: if_arp.c,v 1.235 2017/01/16 15:14:16 christos 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.234 2017/01/16 07:33:36 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.235 2017/01/16 15:14:16 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -689,10 +689,9 @@ arpannounce(struct ifnet *ifp, struct if { struct in_ifaddr *ia = ifatoia(ifa); struct in_addr *ip = &IA_SIN(ifa)->sin_addr; - char ipbuf[INET_ADDRSTRLEN]; if (ia->ia4_flags & (IN_IFF_NOTREADY | IN_IFF_DETACHED)) { - arplog(LOG_DEBUG, "%s not ready\n", in_fmtaddr(ipbuf, *ip)); + ARPLOG(LOG_DEBUG, "%s not ready\n", ARPLOGADDR(*ip)); return; } arprequest(ifp, ip, ip, enaddr); @@ -1631,8 +1630,8 @@ arp_dad_start(struct ifaddr *ifa) dp->dad_arp_acount = dp->dad_arp_ocount = dp->dad_arp_tcount = 0; TAILQ_INSERT_TAIL(&dadq, (struct dadq *)dp, dad_list); - arplog(LOG_DEBUG, "%s: starting DAD for %s\n", if_name(ifa->ifa_ifp), - in_fmtaddr(ipbuf, ia->ia_addr.sin_addr)); + ARPLOG(LOG_DEBUG, "%s: starting DAD for %s\n", if_name(ifa->ifa_ifp), + ARPLOGADDR(ia->ia_addr.sin_addr)); arp_dad_starttimer(dp, cprng_fast32() % (PROBE_WAIT * hz)); @@ -1706,7 +1705,7 @@ arp_dad_timer(struct ifaddr *ifa) /* timeouted with IFF_{RUNNING,UP} check */ if (dp->dad_arp_tcount > dad_maxtry) { - arplog(LOG_INFO, "%s: could not run DAD, driver problem?\n", + ARPLOG(LOG_INFO, "%s: could not run DAD, driver problem?\n", if_name(ifa->ifa_ifp)); TAILQ_REMOVE(&dadq, dp, dad_list); @@ -1739,10 +1738,9 @@ arp_dad_timer(struct ifaddr *ifa) */ ia->ia4_flags &= ~IN_IFF_TENTATIVE; rt_newaddrmsg(RTM_NEWADDR, ifa, 0, NULL); - arplog(LOG_DEBUG, + ARPLOG(LOG_DEBUG, "%s: DAD complete for %s - no duplicates found\n", - if_name(ifa->ifa_ifp), - in_fmtaddr(ipbuf, 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) { @@ -1756,10 +1754,9 @@ announce: arp_dad_starttimer(dp, ANNOUNCE_INTERVAL * hz); goto done; } - arplog(LOG_DEBUG, + ARPLOG(LOG_DEBUG, "%s: ARP announcement complete for %s\n", - if_name(ifa->ifa_ifp), - in_fmtaddr(ipbuf, ia->ia_addr.sin_addr)); + if_name(ifa->ifa_ifp), ARPLOGADDR(ia->ia_addr.sin_addr)); } TAILQ_REMOVE(&dadq, dp, dad_list); Index: src/sys/netinet/in_var.h diff -u src/sys/netinet/in_var.h:1.92 src/sys/netinet/in_var.h:1.93 --- src/sys/netinet/in_var.h:1.92 Mon Jan 16 02:33:36 2017 +++ src/sys/netinet/in_var.h Mon Jan 16 10:14:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: in_var.h,v 1.92 2017/01/16 07:33:36 ryo Exp $ */ +/* $NetBSD: in_var.h,v 1.93 2017/01/16 15:14:16 christos Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -380,10 +380,15 @@ extern pktqueue_t *ip_pktq; extern int ip_dad_count; /* Duplicate Address Detection probes */ #if defined(INET) && NARP > 0 extern int arp_debug; -#define arplog(level, fmt, args...) \ - do { if (arp_debug) log(level, "%s: " fmt, __func__, ##args);} while (0) +#define ARPLOGADDR(a) in_fmtaddr(_ipbuf, a) +#define ARPLOG(level, fmt, args...) \ + do { \ + char _ipbuf[INET_ADDRSTRLEN] __used; \ + if (arp_debug) \ + log(level, "%s: " fmt, __func__, ##args); \ + } while (/*CONSTCOND*/0) #else -#define arplog(level, fmt, args...) +#define ARPLOG(level, fmt, args...) #endif /* Index: src/sys/netinet/ip_output.c diff -u src/sys/netinet/ip_output.c:1.268 src/sys/netinet/ip_output.c:1.269 --- src/sys/netinet/ip_output.c:1.268 Mon Jan 16 02:33:36 2017 +++ src/sys/netinet/ip_output.c Mon Jan 16 10:14:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_output.c,v 1.268 2017/01/16 07:33:36 ryo Exp $ */ +/* $NetBSD: ip_output.c,v 1.269 2017/01/16 15:14:16 christos 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.268 2017/01/16 07:33:36 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.269 2017/01/16 15:14:16 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -620,10 +620,9 @@ sendit: if ((ia != NULL || (flags & IP_FORWARDING) == 0) && (error = ip_ifaddrvalid(ia)) != 0) { - char ipbuf[INET_ADDRSTRLEN]; - arplog(LOG_ERR, + ARPLOG(LOG_ERR, "refusing to send from invalid address %s (pid %d)\n", - in_fmtaddr(ipbuf, ip->ip_src), curproc->p_pid); + ARPLOGADDR(ip->ip_src), curproc->p_pid); IP_STATINC(IP_STAT_ODROPPED); if (error == 1) /*