Tue Mar 14 04:23:15 2017 UTC ()
Avoid debug printf just if DIAGNOSTIC


(ozaki-r)
diff -r1.202 -r1.203 src/sys/net/rtsock.c

cvs diff -r1.202 -r1.203 src/sys/net/rtsock.c (expand / switch to unified diff)

--- src/sys/net/rtsock.c 2017/02/21 04:00:01 1.202
+++ src/sys/net/rtsock.c 2017/03/14 04:23:15 1.203
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rtsock.c,v 1.202 2017/02/21 04:00:01 ozaki-r Exp $ */ 1/* $NetBSD: rtsock.c,v 1.203 2017/03/14 04:23:15 ozaki-r Exp $ */
2 2
3/* 3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -51,27 +51,27 @@ @@ -51,27 +51,27 @@
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE. 58 * SUCH DAMAGE.
59 * 59 *
60 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 60 * @(#)rtsock.c 8.7 (Berkeley) 10/12/95
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.202 2017/02/21 04:00:01 ozaki-r Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.203 2017/03/14 04:23:15 ozaki-r Exp $");
65 65
66#ifdef _KERNEL_OPT 66#ifdef _KERNEL_OPT
67#include "opt_inet.h" 67#include "opt_inet.h"
68#include "opt_mpls.h" 68#include "opt_mpls.h"
69#include "opt_compat_netbsd.h" 69#include "opt_compat_netbsd.h"
70#include "opt_sctp.h" 70#include "opt_sctp.h"
71#include "opt_net_mpsafe.h" 71#include "opt_net_mpsafe.h"
72#endif 72#endif
73 73
74#include <sys/param.h> 74#include <sys/param.h>
75#include <sys/systm.h> 75#include <sys/systm.h>
76#include <sys/proc.h> 76#include <sys/proc.h>
77#include <sys/socket.h> 77#include <sys/socket.h>
@@ -1054,51 +1054,51 @@ rt_getlen(int type) @@ -1054,51 +1054,51 @@ rt_getlen(int type)
1054 CTASSERT(__alignof(struct ifa_msghdr) >= sizeof(uint64_t)); 1054 CTASSERT(__alignof(struct ifa_msghdr) >= sizeof(uint64_t));
1055 CTASSERT(__alignof(struct if_msghdr) >= sizeof(uint64_t)); 1055 CTASSERT(__alignof(struct if_msghdr) >= sizeof(uint64_t));
1056 CTASSERT(__alignof(struct if_announcemsghdr) >= sizeof(uint64_t)); 1056 CTASSERT(__alignof(struct if_announcemsghdr) >= sizeof(uint64_t));
1057 CTASSERT(__alignof(struct rt_msghdr) >= sizeof(uint64_t)); 1057 CTASSERT(__alignof(struct rt_msghdr) >= sizeof(uint64_t));
1058#endif 1058#endif
1059 1059
1060 switch (type) { 1060 switch (type) {
1061 case RTM_ODELADDR: 1061 case RTM_ODELADDR:
1062 case RTM_ONEWADDR: 1062 case RTM_ONEWADDR:
1063 case RTM_OCHGADDR: 1063 case RTM_OCHGADDR:
1064#ifdef COMPAT_70 1064#ifdef COMPAT_70
1065 return sizeof(struct ifa_msghdr70); 1065 return sizeof(struct ifa_msghdr70);
1066#else 1066#else
1067#ifdef DIAGNOSTIC 1067#ifdef RTSOCK_DEBUG
1068 printf("RTM_ONEWADDR\n"); 1068 printf("%s: unsupported RTM type %d\n", __func__, type);
1069#endif 1069#endif
1070 return -1; 1070 return -1;
1071#endif 1071#endif
1072 case RTM_DELADDR: 1072 case RTM_DELADDR:
1073 case RTM_NEWADDR: 1073 case RTM_NEWADDR:
1074 case RTM_CHGADDR: 1074 case RTM_CHGADDR:
1075 return sizeof(struct ifa_xmsghdr); 1075 return sizeof(struct ifa_xmsghdr);
1076 1076
1077 case RTM_OOIFINFO: 1077 case RTM_OOIFINFO:
1078#ifdef COMPAT_14 1078#ifdef COMPAT_14
1079 return sizeof(struct if_msghdr14); 1079 return sizeof(struct if_msghdr14);
1080#else 1080#else
1081#ifdef DIAGNOSTIC 1081#ifdef RTSOCK_DEBUG
1082 printf("RTM_OOIFINFO\n"); 1082 printf("%s: unsupported RTM type RTM_OOIFINFO\n", __func__);
1083#endif 1083#endif
1084 return -1; 1084 return -1;
1085#endif 1085#endif
1086 case RTM_OIFINFO: 1086 case RTM_OIFINFO:
1087#ifdef COMPAT_50 1087#ifdef COMPAT_50
1088 return sizeof(struct if_msghdr50); 1088 return sizeof(struct if_msghdr50);
1089#else 1089#else
1090#ifdef DIAGNOSTIC 1090#ifdef RTSOCK_DEBUG
1091 printf("RTM_OIFINFO\n"); 1091 printf("%s: unsupported RTM type RTM_OIFINFO\n", __func__);
1092#endif 1092#endif
1093 return -1; 1093 return -1;
1094#endif 1094#endif
1095 1095
1096 case RTM_IFINFO: 1096 case RTM_IFINFO:
1097 return sizeof(struct if_xmsghdr); 1097 return sizeof(struct if_xmsghdr);
1098 1098
1099 case RTM_IFANNOUNCE: 1099 case RTM_IFANNOUNCE:
1100 case RTM_IEEE80211: 1100 case RTM_IEEE80211:
1101 return sizeof(struct if_xannouncemsghdr); 1101 return sizeof(struct if_xannouncemsghdr);
1102 1102
1103 default: 1103 default:
1104 return sizeof(struct rt_xmsghdr); 1104 return sizeof(struct rt_xmsghdr);
@@ -1661,28 +1661,28 @@ sysctl_iflist(int af, struct rt_walkarg  @@ -1661,28 +1661,28 @@ sysctl_iflist(int af, struct rt_walkarg
1661 cmd = RTM_OIFINFO; 1661 cmd = RTM_OIFINFO;
1662 iflist_if = compat_50_iflist; 1662 iflist_if = compat_50_iflist;
1663 iflist_addr = compat_70_iflist_addr; 1663 iflist_addr = compat_70_iflist_addr;
1664 break; 1664 break;
1665#endif 1665#endif
1666#ifdef COMPAT_70 1666#ifdef COMPAT_70
1667 case NET_RT_OIFLIST: 1667 case NET_RT_OIFLIST:
1668 cmd = RTM_IFINFO; 1668 cmd = RTM_IFINFO;
1669 iflist_if = sysctl_iflist_if; 1669 iflist_if = sysctl_iflist_if;
1670 iflist_addr = compat_70_iflist_addr; 1670 iflist_addr = compat_70_iflist_addr;
1671 break; 1671 break;
1672#endif 1672#endif
1673 default: 1673 default:
1674#ifdef DIAGNOSTIC 1674#ifdef RTSOCK_DEBUG
1675 printf("sysctl_iflist\n"); 1675 printf("%s: unsupported IFLIST type %d\n", __func__, type);
1676#endif 1676#endif
1677 return EINVAL; 1677 return EINVAL;
1678 } 1678 }
1679 1679
1680 memset(&info, 0, sizeof(info)); 1680 memset(&info, 0, sizeof(info));
1681 1681
1682 s = pserialize_read_enter(); 1682 s = pserialize_read_enter();
1683 IFNET_READER_FOREACH(ifp) { 1683 IFNET_READER_FOREACH(ifp) {
1684 if (w->w_arg && w->w_arg != ifp->if_index) 1684 if (w->w_arg && w->w_arg != ifp->if_index)
1685 continue; 1685 continue;
1686 if (IFADDR_READER_EMPTY(ifp)) 1686 if (IFADDR_READER_EMPTY(ifp))
1687 continue; 1687 continue;
1688 1688