Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netipsec Use IPSECLOG instead of ipseclog



details:   https://anonhg.NetBSD.org/src/rev/6409e020b27a
branches:  trunk
changeset: 824021:6409e020b27a
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri May 19 06:24:03 2017 +0000

description:
Use IPSECLOG instead of ipseclog

diffstat:

 sys/netipsec/key.c |  393 +++++++++++++++++++++++++---------------------------
 1 files changed, 189 insertions(+), 204 deletions(-)

diffs (truncated from 1276 to 300 lines):

diff -r 7618200a470f -r 6409e020b27a sys/netipsec/key.c
--- a/sys/netipsec/key.c        Fri May 19 04:39:25 2017 +0000
+++ b/sys/netipsec/key.c        Fri May 19 06:24:03 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: key.c,v 1.133 2017/05/19 04:39:25 ozaki-r Exp $        */
+/*     $NetBSD: key.c,v 1.134 2017/05/19 06:24:03 ozaki-r Exp $        */
 /*     $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $        */
 /*     $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $   */
 
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.133 2017/05/19 04:39:25 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.134 2017/05/19 06:24:03 ozaki-r Exp $");
 
 /*
  * This code is referd to RFC 2367
@@ -312,21 +312,22 @@
        }\
 } while (0)
 
-#define KEY_CHKSASTATE(head, sav, name) \
+#define KEY_CHKSASTATE(head, sav) \
 /* do */ { \
        if ((head) != (sav)) {                                          \
-               ipseclog((LOG_DEBUG, "%s: state mismatched (TREE=%d SA=%d)\n", \
-                       (name), (head), (sav)));                        \
+               IPSECLOG(LOG_DEBUG,                                     \
+                   "state mismatched (TREE=%d SA=%d)\n",               \
+                   (head), (sav));                                     \
                continue;                                               \
        }                                                               \
 } /* while (0) */
 
-#define KEY_CHKSPDIR(head, sp, name) \
+#define KEY_CHKSPDIR(head, sp) \
 do { \
        if ((head) != (sp)) {                                           \
-               ipseclog((LOG_DEBUG, "%s: direction mismatched (TREE=%d SP=%d), " \
-                       "anyway continue.\n",                           \
-                       (name), (head), (sp)));                         \
+               IPSECLOG(LOG_DEBUG,                                     \
+                   "direction mismatched (TREE=%d SP=%d), anyway continue.\n",\
+                   (head), (sp));                                      \
        }                                                               \
 } while (0)
 
@@ -525,8 +526,8 @@
 
 #ifdef IPSEC_REF_DEBUG
 #define REFLOG(label, p, where, tag)                                   \
-       ipseclog((LOG_DEBUG, "%s:%d: " label " : refcnt=%d (%p)\n.",    \
-           (where), (tag), (p)->refcnt, (p)))
+       log(LOG_DEBUG, "%s:%d: " label " : refcnt=%d (%p)\n.",          \
+           (where), (tag), (p)->refcnt, (p))
 #else
 #define REFLOG(label, p, where, tag)   do {} while (0)
 #endif
@@ -647,7 +648,7 @@
 found:
        if (sp) {
                /* sanity check */
-               KEY_CHKSPDIR(sp->spidx.dir, dir, "key_allocsp");
+               KEY_CHKSPDIR(sp->spidx.dir, dir);
 
                /* found a SPD entry */
                sp->lastused = time_uptime;
@@ -711,7 +712,7 @@
 found:
        if (sp) {
                /* sanity check */
-               KEY_CHKSPDIR(sp->spidx.dir, dir, "key_allocsp2");
+               KEY_CHKSPDIR(sp->spidx.dir, dir);
 
                /* found a SPD entry */
                sp->lastused = time_uptime;
@@ -745,8 +746,8 @@
        KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP, "DP from %s:%u\n", where, tag);
 
        if (isrc->sa_family != idst->sa_family) {
-               ipseclog((LOG_ERR, "protocol family mismatched %d != %d\n.",
-                       isrc->sa_family, idst->sa_family));
+               IPSECLOG(LOG_ERR, "protocol family mismatched %d != %d\n.",
+                   isrc->sa_family, idst->sa_family);
                sp = NULL;
                goto done;
        }
@@ -881,8 +882,8 @@
        error = key_acquire(saidx, isr->sp);
        if (error != 0) {
                /* XXX What should I do ? */
-               ipseclog((LOG_DEBUG, "key_checkrequest: error %d returned "
-                       "from key_acquire.\n", error));
+               IPSECLOG(LOG_DEBUG, "error %d returned from key_acquire.\n",
+                   error);
                return error;
        }
 
@@ -965,7 +966,7 @@
 
        LIST_FOREACH(sav, &sah->savtree[state], chain) {
                /* sanity check */
-               KEY_CHKSASTATE(sav->state, state, "key_do_allocsa_policy");
+               KEY_CHKSASTATE(sav->state, state);
 
                /* initialize */
                if (candidate == NULL) {
@@ -1167,7 +1168,7 @@
                                    "try match spi %#x, %#x\n",
                                    ntohl(spi), ntohl(sav->spi));
                                /* sanity check */
-                               KEY_CHKSASTATE(sav->state, state, "key_allocsav");
+                               KEY_CHKSASTATE(sav->state, state);
                                /* do not return entries w/ unusable state */
                                if (sav->state != SADB_SASTATE_MATURE &&
                                    sav->state != SADB_SASTATE_DYING) {
@@ -1295,8 +1296,8 @@
                break;
 #endif /* INET6 */
        default:
-               ipseclog((LOG_DEBUG, "key_freeso: unknown address family=%d.\n",
-                   so->so_proto->pr_domain->dom_family));
+               IPSECLOG(LOG_DEBUG, "unknown address family=%d.\n",
+                   so->so_proto->pr_domain->dom_family);
                return;
        }
 }
@@ -1463,7 +1464,7 @@
        KASSERT(len >= sizeof(*xpl0));
 
        if (len != PFKEY_EXTLEN(xpl0)) {
-               ipseclog((LOG_DEBUG, "key_msg2sp: Invalid msg length.\n"));
+               IPSECLOG(LOG_DEBUG, "Invalid msg length.\n");
                *error = EINVAL;
                return NULL;
        }
@@ -1490,7 +1491,7 @@
                /* Continued */
                break;
        default:
-               ipseclog((LOG_DEBUG, "key_msg2sp: invalid policy type.\n"));
+               IPSECLOG(LOG_DEBUG, "invalid policy type.\n");
                KEY_FREESP(&newsp);
                *error = EINVAL;
                return NULL;
@@ -1505,8 +1506,7 @@
 
        /* validity check */
        if (PFKEY_EXTLEN(xpl0) < sizeof(*xpl0)) {
-               ipseclog((LOG_DEBUG,
-                   "key_msg2sp: Invalid msg length.\n"));
+               IPSECLOG(LOG_DEBUG, "Invalid msg length.\n");
                *error = EINVAL;
                goto free_exit;
        }
@@ -1517,8 +1517,7 @@
        while (tlen > 0) {
                /* length check */
                if (xisr->sadb_x_ipsecrequest_len < sizeof(*xisr)) {
-                       ipseclog((LOG_DEBUG, "key_msg2sp: "
-                               "invalid ipsecrequest length.\n"));
+                       IPSECLOG(LOG_DEBUG, "invalid ipsecrequest length.\n");
                        *error = EINVAL;
                        goto free_exit;
                }
@@ -1535,9 +1534,8 @@
                case IPPROTO_IPCOMP:
                        break;
                default:
-                       ipseclog((LOG_DEBUG,
-                           "key_msg2sp: invalid proto type=%u\n",
-                           xisr->sadb_x_ipsecrequest_proto));
+                       IPSECLOG(LOG_DEBUG, "invalid proto type=%u\n",
+                           xisr->sadb_x_ipsecrequest_proto);
                        *error = EPROTONOSUPPORT;
                        goto free_exit;
                }
@@ -1549,9 +1547,8 @@
                        break;
                case IPSEC_MODE_ANY:
                default:
-                       ipseclog((LOG_DEBUG,
-                           "key_msg2sp: invalid mode=%u\n",
-                           xisr->sadb_x_ipsecrequest_mode));
+                       IPSECLOG(LOG_DEBUG, "invalid mode=%u\n",
+                           xisr->sadb_x_ipsecrequest_mode);
                        *error = EINVAL;
                        goto free_exit;
                }
@@ -1570,10 +1567,10 @@
                         * update it, don't refuse it.
                         */
                        if (xisr_reqid > IPSEC_MANUAL_REQID_MAX) {
-                               ipseclog((LOG_DEBUG,
-                                   "key_msg2sp: reqid=%d range "
+                               IPSECLOG(LOG_DEBUG,
+                                   "reqid=%d range "
                                    "violation, updated by kernel.\n",
-                                   xisr_reqid));
+                                   xisr_reqid);
                                xisr_reqid = 0;
                        }
 
@@ -1592,8 +1589,8 @@
                        break;
 
                default:
-                       ipseclog((LOG_DEBUG, "key_msg2sp: invalid level=%u\n",
-                               xisr->sadb_x_ipsecrequest_level));
+                       IPSECLOG(LOG_DEBUG, "invalid level=%u\n",
+                           xisr->sadb_x_ipsecrequest_level);
                        *error = EINVAL;
                        goto free_exit;
                }
@@ -1608,8 +1605,8 @@
                        /* validity check */
                        if (paddr->sa_len
                            > sizeof((*p_isr)->saidx.src)) {
-                               ipseclog((LOG_DEBUG, "key_msg2sp: invalid request "
-                                       "address length.\n"));
+                               IPSECLOG(LOG_DEBUG, "invalid request "
+                                   "address length.\n");
                                *error = EINVAL;
                                goto free_exit;
                        }
@@ -1621,8 +1618,8 @@
                        /* validity check */
                        if (paddr->sa_len
                            > sizeof((*p_isr)->saidx.dst)) {
-                               ipseclog((LOG_DEBUG, "key_msg2sp: invalid request "
-                                       "address length.\n"));
+                               IPSECLOG(LOG_DEBUG, "invalid request "
+                                   "address length.\n");
                                *error = EINVAL;
                                goto free_exit;
                        }
@@ -1638,7 +1635,7 @@
 
                /* validity check */
                if (tlen < 0) {
-                       ipseclog((LOG_DEBUG, "key_msg2sp: becoming tlen < 0.\n"));
+                       IPSECLOG(LOG_DEBUG, "becoming tlen < 0.\n");
                        *error = EINVAL;
                        goto free_exit;
                }
@@ -1844,19 +1841,19 @@
        if (mhp->ext[SADB_EXT_ADDRESS_SRC] == NULL ||
            mhp->ext[SADB_EXT_ADDRESS_DST] == NULL ||
            mhp->ext[SADB_X_EXT_POLICY] == NULL) {
-               ipseclog((LOG_DEBUG, "key_spdadd: invalid message is passed.\n"));
+               IPSECLOG(LOG_DEBUG, "invalid message is passed.\n");
                return key_senderror(so, m, EINVAL);
        }
        if (mhp->extlen[SADB_EXT_ADDRESS_SRC] < sizeof(struct sadb_address) ||
            mhp->extlen[SADB_EXT_ADDRESS_DST] < sizeof(struct sadb_address) ||
            mhp->extlen[SADB_X_EXT_POLICY] < sizeof(struct sadb_x_policy)) {
-               ipseclog((LOG_DEBUG, "key_spdadd: invalid message is passed.\n"));
+               IPSECLOG(LOG_DEBUG, "invalid message is passed.\n");
                return key_senderror(so, m, EINVAL);
        }
        if (mhp->ext[SADB_EXT_LIFETIME_HARD] != NULL) {
                if (mhp->extlen[SADB_EXT_LIFETIME_HARD]
                        < sizeof(struct sadb_lifetime)) {
-                       ipseclog((LOG_DEBUG, "key_spdadd: invalid message is passed.\n"));
+                       IPSECLOG(LOG_DEBUG, "invalid message is passed.\n");
                        return key_senderror(so, m, EINVAL);
                }
                lft = (struct sadb_lifetime *)mhp->ext[SADB_EXT_LIFETIME_HARD];
@@ -1882,7 +1879,7 @@
        case IPSEC_DIR_OUTBOUND:
                break;
        default:
-               ipseclog((LOG_DEBUG, "key_spdadd: Invalid SP direction.\n"));
+               IPSECLOG(LOG_DEBUG, "Invalid SP direction.\n");
                mhp->msg->sadb_msg_errno = EINVAL;
                return 0;
        }
@@ -1891,7 +1888,7 @@
        /* key_spdadd() accepts DISCARD, NONE and IPSEC. */
        if (xpl0->sadb_x_policy_type == IPSEC_POLICY_ENTRUST
         || xpl0->sadb_x_policy_type == IPSEC_POLICY_BYPASS) {
-               ipseclog((LOG_DEBUG, "key_spdadd: Invalid policy type.\n"));
+               IPSECLOG(LOG_DEBUG, "Invalid policy type.\n");
                return key_senderror(so, m, EINVAL);
        }
 
@@ -1899,7 +1896,7 @@
        if (mhp->msg->sadb_msg_type != SADB_X_SPDSETIDX &&
            xpl0->sadb_x_policy_type == IPSEC_POLICY_IPSEC &&
            mhp->extlen[SADB_X_EXT_POLICY] <= sizeof(*xpl0)) {
-               ipseclog((LOG_DEBUG, "key_spdadd: some policy requests part required.\n"));
+               IPSECLOG(LOG_DEBUG, "some policy requests part required.\n");
                return key_senderror(so, m, EINVAL);
        }
 
@@ -1920,7 +1917,7 @@
        } else {
                if (newsp != NULL) {
                        KEY_FREESP(&newsp);



Home | Main Index | Thread Index | Old Index