summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2000-09-21 02:38:34 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2000-09-21 02:38:34 +0000
commit0143671bbe11b6f4420babb02f6ac4c8e99a9e61 (patch)
tree09c13519219fa3479212a28bf9d0907ea2c424bf
parent9b6b0791cfde3bb69f264298aace667b98dba6d5 (diff)
Correctly handle srcid/dstid.
-rw-r--r--sys/net/pfkeyv2.c30
-rw-r--r--sys/net/pfkeyv2_parsemessage.c4
2 files changed, 15 insertions, 19 deletions
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c
index 7019724c4b6..d7972265736 100644
--- a/sys/net/pfkeyv2.c
+++ b/sys/net/pfkeyv2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2.c,v 1.43 2000/09/20 19:13:16 angelos Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.44 2000/09/21 02:38:32 angelos Exp $ */
/*
%%% copyright-nrl-97
This software is Copyright 1997-1998 by Randall Atkinson, Ronald Lee,
@@ -1750,6 +1750,10 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
if ((sid = headers[SADB_EXT_IDENTITY_SRC]) != NULL)
{
+ ipo->ipo_srcid_type = sid->sadb_ident_type;
+ ipo->ipo_srcid_len = (sid->sadb_ident_len * sizeof(u_int64_t)) -
+ sizeof(struct sadb_ident);
+
MALLOC(ipo->ipo_srcid, u_int8_t *, ipo->ipo_srcid_len,
M_TEMP, M_DONTWAIT);
if (ipo->ipo_srcid == NULL)
@@ -1766,17 +1770,15 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
goto ret;
}
- ipo->ipo_srcid_type = sid->sadb_ident_type;
- ipo->ipo_srcid_len = sid->sadb_ident_len -
- sizeof(struct sadb_ident);
-
- bcopy(headers[SADB_EXT_IDENTITY_SRC] +
- sizeof(struct sadb_ident), ipo->ipo_srcid,
- ipo->ipo_srcid_len);
+ bcopy(sid + 1, ipo->ipo_srcid, ipo->ipo_srcid_len);
}
if ((sid = headers[SADB_EXT_IDENTITY_DST]) != NULL)
{
+ ipo->ipo_dstid_type = sid->sadb_ident_type;
+ ipo->ipo_dstid_len = (sid->sadb_ident_len * sizeof(u_int64_t)) -
+ sizeof(struct sadb_ident);
+
MALLOC(ipo->ipo_dstid, u_int8_t *, ipo->ipo_dstid_len,
M_TEMP, M_DONTWAIT);
if (ipo->ipo_dstid == NULL)
@@ -1789,8 +1791,8 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
}
else
{
- if (ipo->ipo_srcid)
- FREE(ipo->ipo_srcid, M_TEMP);
+ if (ipo->ipo_dstid)
+ FREE(ipo->ipo_dstid, M_TEMP);
FREE(ipo, M_TDB);
}
@@ -1798,13 +1800,7 @@ pfkeyv2_send(struct socket *socket, void *message, int len)
goto ret;
}
- ipo->ipo_dstid_type = sid->sadb_ident_type;
- ipo->ipo_dstid_len = sid->sadb_ident_len -
- sizeof(struct sadb_ident);
-
- bcopy(headers[SADB_EXT_IDENTITY_SRC] +
- sizeof(struct sadb_ident), ipo->ipo_dstid,
- ipo->ipo_dstid_len);
+ bcopy(sid + 1, ipo->ipo_dstid, ipo->ipo_dstid_len);
}
/* Flow type */
diff --git a/sys/net/pfkeyv2_parsemessage.c b/sys/net/pfkeyv2_parsemessage.c
index ec8367cae8d..1c1e7ab3b2c 100644
--- a/sys/net/pfkeyv2_parsemessage.c
+++ b/sys/net/pfkeyv2_parsemessage.c
@@ -86,7 +86,7 @@ uint32_t sadb_exts_allowed_in[SADB_MAX+1] =
/* X_PROMISC */
0,
/* X_ADDFLOW */
- BITMAP_ADDRESS_SRC | BITMAP_ADDRESS_DST | BITMAP_SA | BITMAP_X_SRC_MASK | BITMAP_X_DST_MASK | BITMAP_X_PROTOCOL | BITMAP_X_SRC_FLOW | BITMAP_X_DST_FLOW | BITMAP_X_FLOW_TYPE | BITMAP_IDENTITY_SRC | BITMAP_IDENTITY_DST ,
+ BITMAP_ADDRESS_SRC | BITMAP_ADDRESS_DST | BITMAP_SA | BITMAP_X_SRC_MASK | BITMAP_X_DST_MASK | BITMAP_X_PROTOCOL | BITMAP_X_SRC_FLOW | BITMAP_X_DST_FLOW | BITMAP_X_FLOW_TYPE | BITMAP_IDENTITY_SRC | BITMAP_IDENTITY_DST,
/* X_DELFLOW */
BITMAP_X_SRC_MASK | BITMAP_X_DST_MASK | BITMAP_X_PROTOCOL | BITMAP_X_SRC_FLOW | BITMAP_X_DST_FLOW | BITMAP_SA | BITMAP_ADDRESS_DST | BITMAP_X_FLOW_TYPE,
/* X_GRPSPIS */
@@ -154,7 +154,7 @@ uint32_t sadb_exts_allowed_out[SADB_MAX+1] =
/* X_PROMISC */
0,
/* X_ADDFLOW */
- BITMAP_ADDRESS_SRC | BITMAP_ADDRESS_DST | BITMAP_SA | BITMAP_X_SRC_MASK | BITMAP_X_DST_MASK | BITMAP_X_PROTOCOL | BITMAP_X_SRC_FLOW | BITMAP_X_DST_FLOW | BITMAP_X_FLOW_TYPE | BITMAP_IDENTITY_SRC | BITMAP_IDENTITY_DST ,
+ BITMAP_ADDRESS_SRC | BITMAP_ADDRESS_DST | BITMAP_SA | BITMAP_X_SRC_MASK | BITMAP_X_DST_MASK | BITMAP_X_PROTOCOL | BITMAP_X_SRC_FLOW | BITMAP_X_DST_FLOW | BITMAP_X_FLOW_TYPE | BITMAP_IDENTITY_SRC | BITMAP_IDENTITY_DST,
/* X_DELFLOW */
BITMAP_X_SRC_MASK | BITMAP_X_DST_MASK | BITMAP_X_PROTOCOL | BITMAP_X_SRC_FLOW | BITMAP_X_DST_FLOW | BITMAP_SA | BITMAP_ADDRESS_DST | BITMAP_X_FLOW_TYPE,
/* X_GRPSPIS */