Source-Changes-HG archive

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

[src/trunk]: src/sys/netkey correct ordering mistake in SADB_DUMP.



details:   https://anonhg.NetBSD.org/src/rev/ec4551608afc
branches:  trunk
changeset: 487930:ec4551608afc
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Jun 15 12:37:07 2000 +0000

description:
correct ordering mistake in SADB_DUMP.
correct bug in key length management in SA database.
improbe mbuf printing (for debugging only).

diffstat:

 sys/netkey/key.c       |  16 +++++-----------
 sys/netkey/key_debug.c |  17 +++++++++--------
 sys/netkey/keydb.h     |   6 ++----
 3 files changed, 16 insertions(+), 23 deletions(-)

diffs (116 lines):

diff -r 223cb9d37eda -r ec4551608afc sys/netkey/key.c
--- a/sys/netkey/key.c  Thu Jun 15 12:12:05 2000 +0000
+++ b/sys/netkey/key.c  Thu Jun 15 12:37:07 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: key.c,v 1.21 2000/06/15 05:50:22 itojun Exp $  */
-/*     $KAME: key.c,v 1.130 2000/06/15 05:46:06 sakane Exp $   */
+/*     $NetBSD: key.c,v 1.22 2000/06/15 12:37:07 itojun Exp $  */
+/*     $KAME: key.c,v 1.131 2000/06/15 12:20:50 sakane Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -2717,9 +2717,6 @@
                        error = ENOBUFS;
                        goto fail;
                }
-
-               /* make length shift up for kernel*/
-               sav->key_auth->sadb_key_len = len;
        }
 
        /* Encryption key */
@@ -2761,9 +2758,6 @@
                        error = ENOBUFS;
                        goto fail;
                }
-
-               /* make length shift up for kernel*/
-               sav->key_enc->sadb_key_len = len;
        }
 
        /* set iv */
@@ -3194,7 +3188,7 @@
                goto fail;
        result = m;
 
-       for (i = SADB_EXT_MAX; i >= 0; i--) {
+       for (i = sizeof(dumporder)/sizeof(dumporder[0]) - 1; i >= 0; i--) {
                m = NULL;
                p = NULL;
                switch (dumporder[i]) {
@@ -3230,14 +3224,14 @@
                case SADB_EXT_KEY_AUTH:
                        if (!sav->key_auth)
                                continue;
-                       l = sav->key_auth->sadb_key_len;
+                       l = PFKEY_UNUNIT64(sav->key_auth->sadb_key_len);
                        p = sav->key_auth;
                        break;
 
                case SADB_EXT_KEY_ENCRYPT:
                        if (!sav->key_enc)
                                continue;
-                       l = sav->key_enc->sadb_key_len;
+                       l = PFKEY_UNUNIT64(sav->key_enc->sadb_key_len);
                        p = sav->key_enc;
                        break;
 
diff -r 223cb9d37eda -r ec4551608afc sys/netkey/key_debug.c
--- a/sys/netkey/key_debug.c    Thu Jun 15 12:12:05 2000 +0000
+++ b/sys/netkey/key_debug.c    Thu Jun 15 12:37:07 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: key_debug.c,v 1.10 2000/06/12 10:40:47 itojun Exp $    */
-/*     $KAME: key_debug.c,v 1.20 2000/06/10 06:39:54 sakane Exp $      */
+/*     $NetBSD: key_debug.c,v 1.11 2000/06/15 12:37:09 itojun Exp $    */
+/*     $KAME: key_debug.c,v 1.21 2000/06/15 11:54:01 sakane Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -660,19 +660,20 @@
        struct mbuf *m = m0;
        int i, j;
 
-       kdebug_mbufhdr(m);
-       printf("  m_data=\n");
        for (j = 0; m; m = m->m_next) {
+               kdebug_mbufhdr(m);
+               printf("  m_data:\n");
                for (i = 0; i < m->m_len; i++) {
-                       if (i != 0 && i % 32 == 0) printf("\n");
-                       if (i % 4 == 0) printf(" ");
+                       if (i && i % 32 == 0)
+                               printf("\n");
+                       if (i % 4 == 0)
+                               printf(" ");
                        printf("%02x", mtod(m, u_char *)[i]);
                        j++;
                }
+               printf("\n");
        }
 
-       printf("\n");
-
        return;
 }
 #endif /* _KERNEL */
diff -r 223cb9d37eda -r ec4551608afc sys/netkey/keydb.h
--- a/sys/netkey/keydb.h        Thu Jun 15 12:12:05 2000 +0000
+++ b/sys/netkey/keydb.h        Thu Jun 15 12:37:07 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: keydb.h,v 1.5 2000/06/12 10:40:48 itojun Exp $ */
-/*     $KAME: keydb.h,v 1.10 2000/03/25 07:24:13 sumikawa Exp $        */
+/*     $NetBSD: keydb.h,v 1.6 2000/06/15 12:37:10 itojun Exp $ */
+/*     $KAME: keydb.h,v 1.11 2000/06/15 12:20:50 sakane Exp $  */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -79,9 +79,7 @@
        u_int32_t flags;                /* holder for SADB_KEY_FLAGS */
 
        struct sadb_key *key_auth;      /* Key for Authentication */
-                                       /* length has been shifted up to 3. */
        struct sadb_key *key_enc;       /* Key for Encryption */
-                                       /* length has been shifted up to 3. */
        caddr_t iv;                     /* Initilization Vector */
        u_int ivlen;                    /* length of IV */
 #if 0



Home | Main Index | Thread Index | Old Index