Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec fix debugging output printfs to use __func__ so...
details: https://anonhg.NetBSD.org/src/rev/1b91c98979bc
branches: trunk
changeset: 325428:1b91c98979bc
user: christos <christos%NetBSD.org@localhost>
date: Tue Dec 24 15:48:53 2013 +0000
description:
fix debugging output printfs to use __func__ so they print the correct names.
diffstat:
sys/netipsec/ipsec.c | 317 ++++++++++++++++++++++++--------------------------
1 files changed, 150 insertions(+), 167 deletions(-)
diffs (truncated from 811 to 300 lines):
diff -r 242e3e240613 -r 1b91c98979bc sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c Tue Dec 24 15:42:56 2013 +0000
+++ b/sys/netipsec/ipsec.c Tue Dec 24 15:48:53 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.61 2013/12/24 13:57:06 degroote Exp $ */
+/* $NetBSD: ipsec.c,v 1.62 2013/12/24 15:48:53 christos Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */
/* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.61 2013/12/24 13:57:06 degroote Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.62 2013/12/24 15:48:53 christos Exp $");
/*
* IPsec controller part.
@@ -268,7 +268,7 @@
}
#ifdef DIAGNOSTIC
if (pcbsp == NULL) {
- printf("ipsec_checkpcbcache: NULL pcbsp\n");
+ printf("%s: NULL pcbsp\n", __func__);
/* XXX panic? */
return NULL;
}
@@ -320,9 +320,9 @@
pcbsp->sp_cache[dir].cachesp->lastused = time_second;
pcbsp->sp_cache[dir].cachesp->refcnt++;
KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
- printf("DP ipsec_checkpcbcache cause refcnt++:%d SP:%p\n",
- pcbsp->sp_cache[dir].cachesp->refcnt,
- pcbsp->sp_cache[dir].cachesp));
+ printf("DP %s cause refcnt++:%d SP:%p\n", __func__,
+ pcbsp->sp_cache[dir].cachesp->refcnt,
+ pcbsp->sp_cache[dir].cachesp));
return pcbsp->sp_cache[dir].cachesp;
}
@@ -354,9 +354,9 @@
if (pcbsp->sp_cache[dir].cachesp) {
pcbsp->sp_cache[dir].cachesp->refcnt++;
KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
- printf("DP ipsec_fillpcbcache cause refcnt++:%d SP:%p\n",
- pcbsp->sp_cache[dir].cachesp->refcnt,
- pcbsp->sp_cache[dir].cachesp));
+ printf("DP %s cause refcnt++:%d SP:%p\n", __func__,
+ pcbsp->sp_cache[dir].cachesp->refcnt,
+ pcbsp->sp_cache[dir].cachesp));
/*
* If the PCB is connected, we can remember a hint to
@@ -435,7 +435,7 @@
struct secpolicy *sp;
KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
- printf("DP key_allocsp_default from %s:%u\n", where, tag));
+ printf("DP %s from %s:%u\n", __func__, where, tag));
switch(af) {
case AF_INET:
@@ -448,22 +448,21 @@
#endif
default:
KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
- printf("key_allocsp_default : unexpected protocol family %u\n",
- af));
+ printf("%s: unexpected protocol family %u\n", __func__,
+ af));
return NULL;
}
if (sp->policy != IPSEC_POLICY_DISCARD &&
sp->policy != IPSEC_POLICY_NONE) {
ipseclog((LOG_INFO, "fixed system default policy: %d->%d\n",
- sp->policy, IPSEC_POLICY_NONE));
+ sp->policy, IPSEC_POLICY_NONE));
sp->policy = IPSEC_POLICY_NONE;
}
sp->refcnt++;
- KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
- printf("DP key_allocsp_default returns SP:%p (%u)\n",
- sp, sp->refcnt));
+ KEYDEBUG(KEYDEBUG_IPSEC_STAMP, printf("DP %s returns SP:%p (%u)\n",
+ __func__, sp, sp->refcnt));
return sp;
}
#define KEY_ALLOCSP_DEFAULT(af) \
@@ -486,14 +485,14 @@
{
struct secpolicy *sp;
- IPSEC_ASSERT(tdbi != NULL, ("ipsec_getpolicy: null tdbi"));
+ IPSEC_ASSERT(tdbi != NULL, ("%s: null tdbi", __func__));
IPSEC_ASSERT(dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND,
- ("ipsec_getpolicy: invalid direction %u", dir));
+ ("%s: invalid direction %u", __func__, dir));
sp = KEY_ALLOCSP2(tdbi->spi, &tdbi->dst, tdbi->proto, dir);
if (sp == NULL) /*XXX????*/
sp = KEY_ALLOCSP_DEFAULT(tdbi->dst.sa.sa_family);
- IPSEC_ASSERT(sp != NULL, ("ipsec_getpolicy: null SP"));
+ IPSEC_ASSERT(sp != NULL, ("%s: null SP", __func__));
return sp;
}
@@ -517,19 +516,18 @@
struct secpolicy *sp;
int af;
- IPSEC_ASSERT(m != NULL, ("ipsec_getpolicybysock: null mbuf"));
- IPSEC_ASSERT(inp != NULL, ("ipsec_getpolicybysock: null inpcb"));
- IPSEC_ASSERT(error != NULL, ("ipsec_getpolicybysock: null error"));
+ IPSEC_ASSERT(m != NULL, ("%s: null mbuf", __func__));
+ IPSEC_ASSERT(inp != NULL, ("%s: null inpcb", __func__));
+ IPSEC_ASSERT(error != NULL, ("%s: null error", __func__));
IPSEC_ASSERT(dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND,
- ("ipsec_getpolicybysock: invalid direction %u", dir));
+ ("%s: invalid direction %u", __func__, dir));
- IPSEC_ASSERT(PCB_SOCKET(inp) != NULL,
- ("ipsec_getppolicybysock: null socket\n"));
+ IPSEC_ASSERT(PCB_SOCKET(inp) != NULL, ("%s: null socket", __func__));
/* XXX FIXME inpcb/in6pcb vs socket*/
af = PCB_FAMILY(inp);
IPSEC_ASSERT(af == AF_INET || af == AF_INET6,
- ("ipsec_getpolicybysock: unexpected protocol family %u", af));
+ ("%s: unexpected protocol family %u", __func__, af));
#ifdef __NetBSD__
IPSEC_ASSERT(inp->inph_sp != NULL, ("null PCB policy cache"));
@@ -568,7 +566,7 @@
if (*error)
return NULL;
- IPSEC_ASSERT(pcbsp != NULL, ("ipsec_getpolicybysock: null pcbsp"));
+ IPSEC_ASSERT(pcbsp != NULL, ("%s: null pcbsp", __func__));
switch (dir) {
case IPSEC_DIR_INBOUND:
currsp = pcbsp->sp_in;
@@ -577,7 +575,7 @@
currsp = pcbsp->sp_out;
break;
}
- IPSEC_ASSERT(currsp != NULL, ("ipsec_getpolicybysock: null currsp"));
+ IPSEC_ASSERT(currsp != NULL, ("%s: null currsp", __func__));
if (pcbsp->priv) { /* when privilieged socket */
switch (currsp->policy) {
@@ -595,8 +593,8 @@
break;
default:
- ipseclog((LOG_ERR, "ipsec_getpolicybysock: "
- "Invalid policy for PCB %d\n", currsp->policy));
+ ipseclog((LOG_ERR, "%s: Invalid policy for PCB %d\n",
+ __func__, currsp->policy));
*error = EINVAL;
return NULL;
}
@@ -605,9 +603,9 @@
if (sp == NULL) { /* no SP found */
switch (currsp->policy) {
case IPSEC_POLICY_BYPASS:
- ipseclog((LOG_ERR, "ipsec_getpolicybysock: "
- "Illegal policy for non-priviliged defined %d\n",
- currsp->policy));
+ ipseclog((LOG_ERR, "%s: Illegal policy for "
+ "non-priviliged defined %d\n", __func__,
+ currsp->policy));
*error = EINVAL;
return NULL;
@@ -621,20 +619,19 @@
break;
default:
- ipseclog((LOG_ERR, "ipsec_getpolicybysock: "
- "Invalid policy for PCB %d\n", currsp->policy));
+ ipseclog((LOG_ERR, "%s: Invalid policy for "
+ "PCB %d\n", __func__, currsp->policy));
*error = EINVAL;
return NULL;
}
}
}
IPSEC_ASSERT(sp != NULL,
- ("ipsec_getpolicybysock: null SP (priv %u policy %u",
- pcbsp->priv, currsp->policy));
+ ("%s: null SP (priv %u policy %u", __func__, pcbsp->priv,
+ currsp->policy));
KEYDEBUG(KEYDEBUG_IPSEC_STAMP,
- printf("DP ipsec_getpolicybysock (priv %u policy %u) allocates "
- "SP:%p (refcnt %u)\n", pcbsp->priv, currsp->policy,
- sp, sp->refcnt));
+ printf("DP %s (priv %u policy %u) allocates SP:%p (refcnt %u)\n",
+ __func__, pcbsp->priv, currsp->policy, sp, sp->refcnt));
#ifdef __NetBSD__
ipsec_fillpcbcache(pcbsp, m, sp, dir);
#endif /* __NetBSD__ */
@@ -657,18 +654,18 @@
struct secpolicyindex spidx;
struct secpolicy *sp;
- IPSEC_ASSERT(m != NULL, ("ipsec_getpolicybyaddr: null mbuf"));
- IPSEC_ASSERT(error != NULL, ("ipsec_getpolicybyaddr: null error"));
+ IPSEC_ASSERT(m != NULL, ("%s: null mbuf", __func__));
+ IPSEC_ASSERT(error != NULL, ("%s: null error", __func__));
IPSEC_ASSERT(dir == IPSEC_DIR_INBOUND || dir == IPSEC_DIR_OUTBOUND,
- ("ipsec4_getpolicybaddr: invalid direction %u", dir));
+ ("%s: invalid direction %u", __func__, dir));
sp = NULL;
/* Make an index to look for a policy. */
*error = ipsec_setspidx(m, &spidx, (flag & IP_FORWARDING) ? 0 : 1);
if (*error != 0) {
- DPRINTF(("ipsec_getpolicybyaddr: setpidx failed,"
- " dir %u flag %u\n", dir, flag));
+ DPRINTF(("%s: setpidx failed, dir %u flag %u\n", __func__,
+ dir, flag));
memset(&spidx, 0, sizeof (spidx));
return NULL;
}
@@ -681,7 +678,7 @@
if (sp == NULL) /* no SP found, use system default */
sp = KEY_ALLOCSP_DEFAULT(spidx.dst.sa.sa_family);
- IPSEC_ASSERT(sp != NULL, ("ipsec_getpolicybyaddr: null SP"));
+ IPSEC_ASSERT(sp != NULL, ("%s: null SP", __func__));
return sp;
}
@@ -701,16 +698,16 @@
sp = ipsec_getpolicybysock(m, dir, IN4PCB_TO_PCB(inp), error);
if (sp == NULL) {
IPSEC_ASSERT(*error != 0,
- ("ipsec4_checkpolicy: getpolicy failed w/o error"));
+ ("%s: getpolicy failed w/o error", __func__));
IPSEC_STATINC(IPSEC_STAT_OUT_INVAL);
return NULL;
}
- IPSEC_ASSERT(*error == 0,
- ("ipsec4_checkpolicy: sp w/ error set to %u", *error));
+ IPSEC_ASSERT(*error == 0, ("%s: sp w/ error set to %u", __func__,
+ *error));
switch (sp->policy) {
case IPSEC_POLICY_ENTRUST:
default:
- printf("ipsec4_checkpolicy: invalid policy %u\n", sp->policy);
+ printf("%s: invalid policy %u\n", __func__, sp->policy);
/* fall thru... */
case IPSEC_POLICY_DISCARD:
IPSEC_STATINC(IPSEC_STAT_OUT_POLVIO);
@@ -950,17 +947,17 @@
} else
sp = ipsec_getpolicybysock(m, dir, IN6PCB_TO_PCB(in6p), error);
if (sp == NULL) {
- IPSEC_ASSERT(*error != 0,
- ("ipsec6_checkpolicy: getpolicy failed w/o error"));
+ IPSEC_ASSERT(*error != 0, ("%s: getpolicy failed w/o error",
+ __func__));
IPSEC_STATINC(IPSEC_STAT_OUT_INVAL);
return NULL;
}
- IPSEC_ASSERT(*error == 0,
- ("ipsec6_checkpolicy: sp w/ error set to %u", *error));
+ IPSEC_ASSERT(*error == 0, ("%s: sp w/ error set to %u", __func__,
+ *error));
switch (sp->policy) {
case IPSEC_POLICY_ENTRUST:
default:
- printf("ipsec6_checkpolicy: invalid policy %u\n", sp->policy);
+ printf("%s: invalid policy %u\n", __func__, sp->policy);
/* fall thru... */
case IPSEC_POLICY_DISCARD:
IPSEC_STATINC(IPSEC_STAT_OUT_POLVIO);
@@ -990,10 +987,10 @@
{
int error;
- IPSEC_ASSERT(pcb != NULL, ("ipsec4_setspidx_inpcb: null pcb"));
- IPSEC_ASSERT(pcb->inp_sp != NULL, ("ipsec4_setspidx_inpcb: null inp_sp"));
+ IPSEC_ASSERT(pcb != NULL, ("%s: null pcb", __func__));
+ IPSEC_ASSERT(pcb->inp_sp != NULL, ("%s: null inp_sp", __func__));
IPSEC_ASSERT(pcb->inp_sp->sp_out != NULL && pcb->inp_sp->sp_in != NULL,
- ("ipsec4_setspidx_inpcb: null sp_in || sp_out"));
+ ("%s: null sp_in || sp_out", __func__));
error = ipsec_setspidx(m, &pcb->inp_sp->sp_in->spidx, 1);
if (error == 0) {
@@ -1016,10 +1013,11 @@
struct secpolicyindex *spidx;
int error;
- IPSEC_ASSERT(pcb != NULL, ("ipsec6_setspidx_in6pcb: null pcb"));
- IPSEC_ASSERT(pcb->in6p_sp != NULL, ("ipsec6_setspidx_in6pcb: null inp_sp"));
Home |
Main Index |
Thread Index |
Old Index