Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - tidy up error messages
details: https://anonhg.NetBSD.org/src/rev/43b9af285fdf
branches: trunk
changeset: 344610:43b9af285fdf
user: christos <christos%NetBSD.org@localhost>
date: Thu Apr 07 03:22:15 2016 +0000
description:
- tidy up error messages
- add a length argument to arpresolve()
- add KASSERT for overflow
diffstat:
sys/net/if_arcsubr.c | 7 ++--
sys/net/if_ecosubr.c | 7 ++--
sys/net/if_ethersubr.c | 7 ++--
sys/net/if_fddisubr.c | 7 ++--
sys/net/if_ieee1394subr.c | 7 ++--
sys/net/if_tokensubr.c | 6 ++--
sys/netinet/if_arp.c | 64 +++++++++++++++++++++++-----------------------
sys/netinet/if_inarp.h | 4 +-
8 files changed, 57 insertions(+), 52 deletions(-)
diffs (truncated from 366 to 300 lines):
diff -r 4bb728bc9329 -r 43b9af285fdf sys/net/if_arcsubr.c
--- a/sys/net/if_arcsubr.c Thu Apr 07 03:09:56 2016 +0000
+++ b/sys/net/if_arcsubr.c Thu Apr 07 03:22:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arcsubr.c,v 1.70 2016/02/09 14:43:16 ozaki-r Exp $ */
+/* $NetBSD: if_arcsubr.c,v 1.71 2016/04/07 03:22:15 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.70 2016/02/09 14:43:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.71 2016/04/07 03:22:15 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -151,7 +151,8 @@
adst = arcbroadcastaddr; /* ARCnet broadcast address */
else if (ifp->if_flags & IFF_NOARP)
adst = ntohl(satocsin(dst)->sin_addr.s_addr) & 0xFF;
- else if ((error = arpresolve(ifp, rt, m, dst, &adst)) != 0)
+ else if ((error = arpresolve(ifp, rt, m, dst, &adst,
+ sizeof(adst))) != 0)
return error == EWOULDBLOCK ? 0 : error;
/* If broadcasting on a simplex interface, loopback a copy */
diff -r 4bb728bc9329 -r 43b9af285fdf sys/net/if_ecosubr.c
--- a/sys/net/if_ecosubr.c Thu Apr 07 03:09:56 2016 +0000
+++ b/sys/net/if_ecosubr.c Thu Apr 07 03:22:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ecosubr.c,v 1.44 2015/08/24 22:21:26 pooka Exp $ */
+/* $NetBSD: if_ecosubr.c,v 1.45 2016/04/07 03:22:15 christos Exp $ */
/*-
* Copyright (c) 2001 Ben Harris
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.44 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.45 2016/04/07 03:22:15 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -198,7 +198,8 @@
memcpy(ehdr.eco_dhost, eco_broadcastaddr,
ECO_ADDR_LEN);
- else if (!arpresolve(ifp, rt, m, dst, ehdr.eco_dhost))
+ else if (!arpresolve(ifp, rt, m, dst, ehdr.eco_dhost,
+ sizeof(ehdr.eco_dhost)))
return (0); /* if not yet resolved */
/* If broadcasting on a simplex interface, loopback a copy */
if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
diff -r 4bb728bc9329 -r 43b9af285fdf sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c Thu Apr 07 03:09:56 2016 +0000
+++ b/sys/net/if_ethersubr.c Thu Apr 07 03:22:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.216 2016/02/09 08:32:12 ozaki-r Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.217 2016/04/07 03:22:15 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.216 2016/02/09 08:32:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.217 2016/04/07 03:22:15 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -243,7 +243,8 @@
(void)memcpy(edst, etherbroadcastaddr, sizeof(edst));
else if (m->m_flags & M_MCAST)
ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr, edst);
- else if ((error = arpresolve(ifp, rt, m, dst, edst)) != 0)
+ else if ((error = arpresolve(ifp, rt, m, dst, edst,
+ sizeof(edst))) != 0)
return error == EWOULDBLOCK ? 0 : error;
/* If broadcasting on a simplex interface, loopback a copy */
if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
diff -r 4bb728bc9329 -r 43b9af285fdf sys/net/if_fddisubr.c
--- a/sys/net/if_fddisubr.c Thu Apr 07 03:09:56 2016 +0000
+++ b/sys/net/if_fddisubr.c Thu Apr 07 03:22:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_fddisubr.c,v 1.96 2016/02/09 08:32:12 ozaki-r Exp $ */
+/* $NetBSD: if_fddisubr.c,v 1.97 2016/04/07 03:22:15 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.96 2016/02/09 08:32:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.97 2016/04/07 03:22:15 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -235,7 +235,8 @@
else if (m->m_flags & M_MCAST) {
ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr,
(char *)edst);
- } else if ((error = arpresolve(ifp, rt, m, dst, edst)) != 0)
+ } else if ((error = arpresolve(ifp, rt, m, dst, edst,
+ sizeof(edst))) != 0)
return error == EWOULDBLOCK ? 0 : error;
/* If broadcasting on a simplex interface, loopback a copy */
if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
diff -r 4bb728bc9329 -r 43b9af285fdf sys/net/if_ieee1394subr.c
--- a/sys/net/if_ieee1394subr.c Thu Apr 07 03:09:56 2016 +0000
+++ b/sys/net/if_ieee1394subr.c Thu Apr 07 03:22:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ieee1394subr.c,v 1.51 2015/10/13 12:33:07 roy Exp $ */
+/* $NetBSD: if_ieee1394subr.c,v 1.52 2016/04/07 03:22:15 christos Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.51 2015/10/13 12:33:07 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.52 2016/04/07 03:22:15 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -139,7 +139,8 @@
#ifdef INET
case AF_INET:
if (unicast &&
- (error = arpresolve(ifp, rt, m0, dst, (u_char *)hwdst)) !=0)
+ (error = arpresolve(ifp, rt, m0, dst, hwdst,
+ sizeof(*hwdst))) != 0)
return error == EWOULDBLOCK ? 0 : error;
/* if broadcasting on a simplex interface, loopback a copy */
if ((m0->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
diff -r 4bb728bc9329 -r 43b9af285fdf sys/net/if_tokensubr.c
--- a/sys/net/if_tokensubr.c Thu Apr 07 03:09:56 2016 +0000
+++ b/sys/net/if_tokensubr.c Thu Apr 07 03:22:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tokensubr.c,v 1.73 2016/02/09 08:32:12 ozaki-r Exp $ */
+/* $NetBSD: if_tokensubr.c,v 1.74 2016/04/07 03:22:15 christos Exp $ */
/*
* Copyright (c) 1982, 1989, 1993
@@ -92,7 +92,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.73 2016/02/09 08:32:12 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.74 2016/04/07 03:22:15 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -219,7 +219,7 @@
*/
else {
struct llentry *la;
- if (!arpresolve(ifp, rt, m, dst, edst))
+ if (!arpresolve(ifp, rt, m, dst, edst, sizeof(edst)))
return (0); /* if not yet resolved */
la = rt->rt_llinfo;
KASSERT(la != NULL);
diff -r 4bb728bc9329 -r 43b9af285fdf sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c Thu Apr 07 03:09:56 2016 +0000
+++ b/sys/netinet/if_arp.c Thu Apr 07 03:22:15 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_arp.c,v 1.204 2016/04/04 07:37:07 ozaki-r Exp $ */
+/* $NetBSD: if_arp.c,v 1.205 2016/04/07 03:22:15 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.204 2016/04/04 07:37:07 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.205 2016/04/07 03:22:15 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -573,7 +573,7 @@
if (gate->sa_family != AF_LINK ||
gate->sa_len < sockaddr_dl_measure(0, ifp->if_addrlen)) {
- log(LOG_DEBUG, "arp_rtrequest: bad gateway value\n");
+ log(LOG_DEBUG, "%s: bad gateway value\n", __func__);
break;
}
@@ -693,7 +693,7 @@
*/
int
arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
- const struct sockaddr *dst, u_char *desten)
+ const struct sockaddr *dst, void *desten, size_t destlen)
{
struct llentry *la;
const char *create_lookup;
@@ -708,6 +708,7 @@
if ((la->la_flags & LLE_VALID) &&
((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime)) {
+ KASSERT(destlen >= ifp->if_addrlen);
memcpy(desten, &la->ll_addr, ifp->if_addrlen);
LLE_RUNLOCK(la);
return 0;
@@ -719,7 +720,7 @@
#ifdef DIAGNOSTIC
if (rt->rt_expire == 0) {
/* This should never happen. (Should it? -gwr) */
- printf("arpresolve: unresolved and rt_expire == 0\n");
+ printf("%s: unresolved and rt_expire == 0\n", __func__);
/* Set expiration time to now (expired). */
rt->rt_expire = time_uptime;
}
@@ -767,6 +768,7 @@
if ((la->la_flags & LLE_VALID) &&
((la->la_flags & LLE_STATIC) || la->la_expire > time_uptime))
{
+ KASSERT(destlen >= ifp->if_addrlen);
memcpy(desten, &la->ll_addr, ifp->if_addrlen);
renew = false;
/*
@@ -800,8 +802,8 @@
if (la->la_flags & LLE_STATIC) { /* should not happen! */
LLE_RUNLOCK(la);
- log(LOG_DEBUG, "arpresolve: ouch, empty static llinfo for %s\n",
- inet_ntoa(satocsin(dst)->sin_addr));
+ log(LOG_DEBUG, "%s: ouch, empty static llinfo for %s\n",
+ __func__, inet_ntoa(satocsin(dst)->sin_addr));
error = EINVAL;
goto bad;
}
@@ -1225,6 +1227,7 @@
}
#endif /* NTOKEN > 0 */
+ KASSERT(sizeof(la->ll_addr) >= ifp->if_addrlen);
(void)memcpy(&la->ll_addr, ar_sha(ah), ifp->if_addrlen);
la->la_flags |= LLE_VALID;
la->la_expire = time_uptime + arpt_keep;
@@ -1431,8 +1434,8 @@
(struct sockaddr *)IA_SIN(ifa));
IF_AFDATA_WUNLOCK(ifp);
if (lle == NULL)
- log(LOG_INFO, "arp_ifinit: cannot create arp "
- "entry for interface address\n");
+ log(LOG_INFO, "%s: cannot create arp entry for"
+ " interface address\n", __func__);
else {
arp_init_llentry(ifp, lle);
LLE_RUNLOCK(lle);
@@ -1535,10 +1538,9 @@
*/
if (!(ia->ia4_flags & IN_IFF_TENTATIVE)) {
log(LOG_DEBUG,
- "arp_dad_start: called with non-tentative address "
- "%s(%s)\n",
- in_fmtaddr(ia->ia_addr.sin_addr),
- ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
+ "%s: called with non-tentative address %s(%s)\n", __func__,
+ in_fmtaddr(ia->ia_addr.sin_addr),
+ ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
return;
}
if (!ip_dad_count) {
@@ -1561,10 +1563,9 @@
dp = malloc(sizeof(*dp), M_IPARP, M_NOWAIT);
if (dp == NULL) {
- log(LOG_ERR, "arp_dad_start: memory allocation failed for "
- "%s(%s)\n",
- in_fmtaddr(ia->ia_addr.sin_addr),
- ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
+ log(LOG_ERR, "%s: memory allocation failed for %s(%s)\n",
+ __func__, in_fmtaddr(ia->ia_addr.sin_addr),
+ ifa->ifa_ifp ? if_name(ifa->ifa_ifp) : "???");
return;
}
memset(dp, 0, sizeof(*dp));
@@ -1623,33 +1624,32 @@
/* Sanity check */
if (ia == NULL) {
- log(LOG_ERR, "arp_dad_timer: called with null parameter\n");
+ log(LOG_ERR, "%s: called with null parameter\n", __func__);
goto done;
}
dp = arp_dad_find(ifa);
if (dp == NULL) {
- log(LOG_ERR, "arp_dad_timer: DAD structure not found\n");
+ log(LOG_ERR, "%s: DAD structure not found\n", __func__);
goto done;
}
Home |
Main Index |
Thread Index |
Old Index