Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys use the new printing code.
details: https://anonhg.NetBSD.org/src/rev/01725b26e04d
branches: trunk
changeset: 334708:01725b26e04d
user: christos <christos%NetBSD.org@localhost>
date: Tue Dec 02 20:25:47 2014 +0000
description:
use the new printing code.
diffstat:
sys/net/rtsock.c | 27 +++++++++++++++------------
sys/netinet/in.h | 3 ++-
sys/netinet/ip_icmp.c | 26 ++++++++++++++++----------
sys/netinet/portalgo.c | 15 +++++++++------
sys/netinet/tcp_input.c | 40 +++++++++++++++++++---------------------
sys/netinet6/in6.h | 3 ++-
6 files changed, 63 insertions(+), 51 deletions(-)
diffs (truncated from 303 to 300 lines):
diff -r 1e7d3b1ce87c -r 01725b26e04d sys/net/rtsock.c
--- a/sys/net/rtsock.c Tue Dec 02 19:57:11 2014 +0000
+++ b/sys/net/rtsock.c Tue Dec 02 20:25:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtsock.c,v 1.164 2014/09/05 06:00:05 matt Exp $ */
+/* $NetBSD: rtsock.c,v 1.165 2014/12/02 20:25:48 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.164 2014/09/05 06:00:05 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.165 2014/12/02 20:25:48 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -131,6 +131,11 @@
#define COMPATCALL(name, args) do { } while (/*CONSTCOND*/ 0)
#endif
+#ifdef RTSOCK_DEBUG
+#define RT_IN_PRINT(b, a) (in_print((b), sizeof(b), \
+ &((const struct sockaddr_in *)info.rti_info(a))->sin_addr), (b))
+#endif /* RTSOCK_DEBUG */
+
struct route_info COMPATNAME(route_info) = {
.ri_dst = { .sa_len = 2, .sa_family = PF_XROUTE, },
.ri_src = { .sa_len = 2, .sa_family = PF_XROUTE, },
@@ -493,9 +498,9 @@
info.rti_flags = rtm->rtm_flags;
#ifdef RTSOCK_DEBUG
if (info.rti_info[RTAX_DST]->sa_family == AF_INET) {
+ char abuf[INET_ADDRSTRLEN];
printf("%s: extracted info.rti_info[RTAX_DST] %s\n", __func__,
- inet_ntoa(((const struct sockaddr_in *)
- info.rti_info[RTAX_DST])->sin_addr));
+ RT_IN_PRINT(abuf, RTAX_DST));
}
#endif /* RTSOCK_DEBUG */
if (info.rti_info[RTAX_DST] == NULL ||
@@ -577,16 +582,14 @@
#ifdef RTSOCK_DEBUG
if (info.rti_info[RTAX_IFA]->sa_family ==
AF_INET) {
+ char ibuf[INET_ADDRSTRLEN];
+ char abuf[INET_ADDRSTRLEN];
printf("%s: copying out RTAX_IFA %s ",
- __func__, inet_ntoa(
- ((const struct sockaddr_in *)
- info.rti_info[RTAX_IFA])->sin_addr)
- );
- printf("for info.rti_info[RTAX_DST] %s "
+ "for info.rti_info[RTAX_DST] %s "
"ifa_getifa %p ifa_seqno %p\n",
- inet_ntoa(
- ((const struct sockaddr_in *)
- info.rti_info[RTAX_DST])->sin_addr),
+ __func__,
+ RT_IN_PRINT(ibuf, RTAX_IFA),
+ RT_IN_PRINT(abuf, RTAX_DST),
(void *)rtifa->ifa_getifa,
rtifa->ifa_seqno);
}
diff -r 1e7d3b1ce87c -r 01725b26e04d sys/netinet/in.h
--- a/sys/netinet/in.h Tue Dec 02 19:57:11 2014 +0000
+++ b/sys/netinet/in.h Tue Dec 02 20:25:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in.h,v 1.94 2014/12/02 19:35:27 christos Exp $ */
+/* $NetBSD: in.h,v 1.95 2014/12/02 20:25:47 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -618,6 +618,7 @@
#if defined(_KERNEL) || defined(_TEST)
int in_print(char *, size_t, const struct in_addr *);
+#define IN_PRINT(b, a) (in_print((b), sizeof(b), a), (b))
int sin_print(char *, size_t, const void *);
#endif
diff -r 1e7d3b1ce87c -r 01725b26e04d sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c Tue Dec 02 19:57:11 2014 +0000
+++ b/sys/netinet/ip_icmp.c Tue Dec 02 20:25:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_icmp.c,v 1.134 2014/05/30 01:39:03 christos Exp $ */
+/* $NetBSD: ip_icmp.c,v 1.135 2014/12/02 20:25:47 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -94,7 +94,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.134 2014/05/30 01:39:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.135 2014/12/02 20:25:47 christos Exp $");
#include "opt_ipsec.h"
@@ -408,8 +408,10 @@
icmplen = ntohs(ip->ip_len) - hlen;
#ifdef ICMPPRINTFS
if (icmpprintfs) {
- printf("icmp_input from `%s' to ", inet_ntoa(ip->ip_src));
- printf("`%s', len %d\n", inet_ntoa(ip->ip_dst), icmplen);
+ char sbuf[INET_ADDRSTRLEN], dbuf[INET_ADDRSTRLEN];
+ printf("icmp_input from `%s' to `%s', len %d\n",
+ IN_PRINT(sbuf, &ip->ip_src), IN_PRINT(dbuf, &ip->ip_dst),
+ icmplen);
}
#endif
if (icmplen < ICMP_MINLEN) {
@@ -615,9 +617,10 @@
icmpdst.sin_addr = icp->icmp_gwaddr;
#ifdef ICMPPRINTFS
if (icmpprintfs) {
+ char gbuf[INET_ADDRSTRLEN], dbuf[INET_ADDRSTRLEN];
printf("redirect dst `%s' to `%s'\n",
- inet_ntoa(icp->icmp_ip.ip_dst),
- inet_ntoa(icp->icmp_gwaddr));
+ IN_PRINT(dbuf, &icp->icmp_ip.ip_dst),
+ IN_PRINT(gbuf, &icp->icmp_gwaddr));
}
#endif
icmpsrc.sin_addr = icp->icmp_ip.ip_dst;
@@ -627,11 +630,13 @@
if (rt != NULL && icmp_redirtimeout != 0) {
i = rt_timer_add(rt, icmp_redirect_timeout,
icmp_redirect_timeout_q);
- if (i)
+ if (i) {
+ char buf[INET_ADDRSTRLEN];
log(LOG_ERR, "ICMP: redirect failed to "
- "register timeout for route to %x, "
+ "register timeout for route to %s, "
"code %d\n",
- icp->icmp_ip.ip_dst.s_addr, i);
+ IN_PRINT(buf, &icp->icmp_ip.ip_dst), i);
+ }
}
if (rt != NULL)
rtfree(rt);
@@ -898,8 +903,9 @@
m->m_len += hlen;
#ifdef ICMPPRINTFS
if (icmpprintfs) {
+ char sbuf[INET_ADDRSTRLEN], dbuf[INET_ADDRSTRLEN];
printf("icmp_send to destination `%s' from `%s'\n",
- inet_ntoa(ip->ip_dst), inet_ntoa(ip->ip_src));
+ IN_PRINT(dbuf, &ip->ip_dst), IN_PRINT(sbuf, &ip->ip_src));
}
#endif
(void)ip_output(m, opts, NULL, 0, NULL, NULL);
diff -r 1e7d3b1ce87c -r 01725b26e04d sys/netinet/portalgo.c
--- a/sys/netinet/portalgo.c Tue Dec 02 19:57:11 2014 +0000
+++ b/sys/netinet/portalgo.c Tue Dec 02 20:25:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: portalgo.c,v 1.6 2014/09/08 17:40:02 joerg Exp $ */
+/* $NetBSD: portalgo.c,v 1.7 2014/12/02 20:25:47 christos Exp $ */
/*
* Copyright 2011 Vlad Balan
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.6 2014/09/08 17:40:02 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: portalgo.c,v 1.7 2014/12/02 20:25:47 christos Exp $");
#include "opt_inet.h"
@@ -796,21 +796,24 @@
switch (inp_hdr->inph_af) {
#ifdef INET
case AF_INET: {
+ char buf[INET_ADDRSTRLEN];
struct inpcb *inp = (struct inpcb *)(void *)inp_hdr;
- DPRINTF("local addr: %s\n", inet_ntoa(inp->inp_laddr));
+ DPRINTF("local addr: %s\n", IN_PRINT(buf, &inp->inp_laddr));
DPRINTF("local port: %d\n", inp->inp_lport);
- DPRINTF("foreign addr: %s\n", inet_ntoa(inp->inp_faddr));
+ DPRINTF("foreign addr: %s\n", IN_PRINT(buf, &inp->inp_faddr));
DPRINTF("foreign port: %d\n", inp->inp_fport);
break;
}
#endif
#ifdef INET6
case AF_INET6: {
+ char buf[INET6_ADDRSTRLEN];
struct in6pcb *in6p = (struct in6pcb *)(void *)inp_hdr;
- DPRINTF("local addr: %s\n", ip6_sprintf(&in6p->in6p_laddr));
+ DPRINTF("local addr: %s\n", IN6_PRINT(buf, &in6p->in6p_laddr));
DPRINTF("local port: %d\n", in6p->in6p_lport);
- DPRINTF("foreign addr: %s\n", ip6_sprintf(&in6p->in6p_faddr));
+ DPRINTF("foreign addr: %s\n", IN6_PRINT(buf,
+ &in6p->in6p_laddr));
DPRINTF("foreign port: %d\n", in6p->in6p_fport);
break;
}
diff -r 1e7d3b1ce87c -r 01725b26e04d sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c Tue Dec 02 19:57:11 2014 +0000
+++ b/sys/netinet/tcp_input.c Tue Dec 02 20:25:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_input.c,v 1.334 2014/08/08 03:05:45 rtr Exp $ */
+/* $NetBSD: tcp_input.c,v 1.335 2014/12/02 20:25:47 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.334 2014/08/08 03:05:45 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.335 2014/12/02 20:25:47 christos Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -845,12 +845,12 @@
static void
tcp4_log_refused(const struct ip *ip, const struct tcphdr *th)
{
- char src[4*sizeof "123"];
- char dst[4*sizeof "123"];
+ char src[INET_ADDRSTRLEN];
+ char dst[INET_ADDRSTRLEN];
if (ip) {
- strlcpy(src, inet_ntoa(ip->ip_src), sizeof(src));
- strlcpy(dst, inet_ntoa(ip->ip_dst), sizeof(dst));
+ in_print(src, sizeof(src), &ip->ip_src);
+ in_print(dst, sizeof(dst), &ip->ip_dst);
}
else {
strlcpy(src, "(unknown)", sizeof(src));
@@ -871,8 +871,8 @@
char dst[INET6_ADDRSTRLEN];
if (ip6) {
- strlcpy(src, ip6_sprintf(&ip6->ip6_src), sizeof(src));
- strlcpy(dst, ip6_sprintf(&ip6->ip6_dst), sizeof(dst));
+ in6_print(src, sizeof(src), &ip6->ip6_src);
+ in6_print(dst, sizeof(dst), &ip6->ip6_dst);
}
else {
strlcpy(src, "(unknown v6)", sizeof(src));
@@ -3312,27 +3312,25 @@
tp->t_flags |= TF_RCVD_SCALE;
tp->requested_s_scale = cp[2];
if (tp->requested_s_scale > TCP_MAX_WINSHIFT) {
-#if 0 /*XXX*/
- char *p;
-
+ char buf[INET6_ADDRSTRLEN];
+ struct ip *ip = mtod(m, struct ip *);
+#ifdef INET6
+ struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
+#endif
if (ip)
- p = ntohl(ip->ip_src);
+ in_print(buf, sizeof(buf),
+ &ip->ip_src);
#ifdef INET6
else if (ip6)
- p = ip6_sprintf(&ip6->ip6_src);
+ in6_print(buf, sizeof(buf),
+ &ip6->ip6_src);
#endif
else
- p = "(unknown)";
+ strlcpy(buf, "(unknown)", sizeof(buf));
log(LOG_ERR, "TCP: invalid wscale %d from %s, "
"assuming %d\n",
- tp->requested_s_scale, p,
+ tp->requested_s_scale, buf,
TCP_MAX_WINSHIFT);
-#else
- log(LOG_ERR, "TCP: invalid wscale %d, "
- "assuming %d\n",
- tp->requested_s_scale,
- TCP_MAX_WINSHIFT);
-#endif
tp->requested_s_scale = TCP_MAX_WINSHIFT;
}
break;
diff -r 1e7d3b1ce87c -r 01725b26e04d sys/netinet6/in6.h
--- a/sys/netinet6/in6.h Tue Dec 02 19:57:11 2014 +0000
+++ b/sys/netinet6/in6.h Tue Dec 02 20:25:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.h,v 1.80 2014/12/02 19:36:58 christos Exp $ */
+/* $NetBSD: in6.h,v 1.81 2014/12/02 20:25:48 christos Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
@@ -820,6 +820,7 @@
#if defined(_KERNEL) || defined(_TEST)
int in6_print(char *, size_t, const struct in6_addr *);
+#define IN6_PRINT(b, a) (in6_print((b), sizeof(b), (a)), (b))
Home |
Main Index |
Thread Index |
Old Index