Source-Changes-HG archive

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

[src/trunk]: src/sys/netkey sync with kame:



details:   https://anonhg.NetBSD.org/src/rev/ca9e7b76d93d
branches:  trunk
changeset: 516236:ca9e7b76d93d
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri Oct 19 01:57:20 2001 +0000

description:
sync with kame:
fixed the value of the prefixlen in the sadb_address structure.
when pfkey message relative to SA is sent, the prefixlen was incorrect.

diffstat:

 sys/netkey/key.c |  30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diffs (93 lines):

diff -r 50ee03b6df9b -r ca9e7b76d93d sys/netkey/key.c
--- a/sys/netkey/key.c  Fri Oct 19 01:16:37 2001 +0000
+++ b/sys/netkey/key.c  Fri Oct 19 01:57:20 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: key.c,v 1.51 2001/09/24 13:22:34 wiz Exp $     */
+/*     $NetBSD: key.c,v 1.52 2001/10/19 01:57:20 itojun Exp $  */
 /*     $KAME: key.c,v 1.203 2001/07/28 03:12:18 itojun Exp $   */
 
 /*
@@ -107,6 +107,8 @@
 #define satosin(s) ((struct sockaddr_in *)s)
 #endif
 
+#define FULLMASK       0xff
+
 /*
  * Note on SA reference counting:
  * - SAs that are not in DEAD state will have (total external reference + 1)
@@ -3164,7 +3166,7 @@
                case SADB_EXT_ADDRESS_SRC:
                        m = key_setsadbaddr(SADB_EXT_ADDRESS_SRC,
                            (struct sockaddr *)&sav->sah->saidx.src,
-                           sav->sah->saidx.src.ss_len << 3, IPSEC_ULPROTO_ANY);
+                           FULLMASK, IPSEC_ULPROTO_ANY);
                        if (!m)
                                goto fail;
                        break;
@@ -3172,7 +3174,7 @@
                case SADB_EXT_ADDRESS_DST:
                        m = key_setsadbaddr(SADB_EXT_ADDRESS_DST,
                            (struct sockaddr *)&sav->sah->saidx.dst,
-                           sav->sah->saidx.dst.ss_len << 3, IPSEC_ULPROTO_ANY);
+                           FULLMASK, IPSEC_ULPROTO_ANY);
                        if (!m)
                                goto fail;
                        break;
@@ -3374,6 +3376,18 @@
        p->sadb_address_len = PFKEY_UNIT64(len);
        p->sadb_address_exttype = exttype;
        p->sadb_address_proto = ul_proto;
+       if (prefixlen == FULLMASK) {
+               switch (saddr->sa_family) {
+               case AF_INET:
+                       prefixlen = sizeof(struct in_addr) << 3;
+                       break;
+               case AF_INET6:
+                       prefixlen = sizeof(struct in6_addr) << 3;
+                       break;
+               default:
+                       ; /*XXX*/
+               }
+       }
        p->sadb_address_prefixlen = prefixlen;
        p->sadb_address_reserved = 0;
 
@@ -5694,8 +5708,7 @@
 
        /* set sadb_address for saidx's. */
        m = key_setsadbaddr(SADB_EXT_ADDRESS_SRC,
-           (struct sockaddr *)&saidx->src, saidx->src.ss_len << 3,
-           IPSEC_ULPROTO_ANY);
+           (struct sockaddr *)&saidx->src, FULLMASK, IPSEC_ULPROTO_ANY);
        if (!m) {
                error = ENOBUFS;
                goto fail;
@@ -5703,8 +5716,7 @@
        m_cat(result, m);
 
        m = key_setsadbaddr(SADB_EXT_ADDRESS_DST,
-           (struct sockaddr *)&saidx->dst, saidx->dst.ss_len << 3,
-           IPSEC_ULPROTO_ANY);
+           (struct sockaddr *)&saidx->dst, FULLMASK, IPSEC_ULPROTO_ANY);
        if (!m) {
                error = ENOBUFS;
                goto fail;
@@ -6336,7 +6348,7 @@
        /* set sadb_address for source */
        m = key_setsadbaddr(SADB_EXT_ADDRESS_SRC,
            (struct sockaddr *)&sav->sah->saidx.src,
-           sav->sah->saidx.src.ss_len << 3, IPSEC_ULPROTO_ANY);
+           FULLMASK, IPSEC_ULPROTO_ANY);
        if (!m) {
                error = ENOBUFS;
                goto fail;
@@ -6346,7 +6358,7 @@
        /* set sadb_address for destination */
        m = key_setsadbaddr(SADB_EXT_ADDRESS_DST,
            (struct sockaddr *)&sav->sah->saidx.dst,
-           sav->sah->saidx.dst.ss_len << 3, IPSEC_ULPROTO_ANY);
+           FULLMASK, IPSEC_ULPROTO_ANY);
        if (!m) {
                error = ENOBUFS;
                goto fail;



Home | Main Index | Thread Index | Old Index