summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2011-01-21 17:01:34 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2011-01-21 17:01:34 +0000
commit81825332e44d97e53bb95b2c47b591a9cc30c793 (patch)
tree08d1fbc6508b6d4633db33d5a3ca88e674ce5c74
parent88b26796733b779680726bd87d83d0627aa5a263 (diff)
don't use memcmp on comparing two iked_addrs but IKED_ADDR_EQ.
ok mikeb@
-rw-r--r--sbin/iked/iked.h7
-rw-r--r--sbin/iked/ikev2.c10
2 files changed, 11 insertions, 6 deletions
diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h
index cc659f997b2..0078045943e 100644
--- a/sbin/iked/iked.h
+++ b/sbin/iked/iked.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: iked.h,v 1.32 2011/01/21 16:51:38 reyk Exp $ */
+/* $OpenBSD: iked.h,v 1.33 2011/01/21 17:01:33 reyk Exp $ */
/* $vantronix: iked.h,v 1.61 2010/06/03 07:57:33 reyk Exp $ */
/*
@@ -62,6 +62,11 @@ struct imsgev {
} while (0)
#define IMSG_DATA_SIZE(imsg) ((imsg)->hdr.len - IMSG_HEADER_SIZE)
+#define IKED_ADDR_EQ(_a, _b) \
+ ((_a)->addr_mask == (_b)->addr_mask && \
+ sockaddr_cmp((struct sockaddr *)&(_a)->addr, \
+ (struct sockaddr *)&(_b)->addr, (_a)->addr_mask) == 0)
+
#define IKED_ADDR_NEQ(_a, _b) \
((_a)->addr_mask != (_b)->addr_mask || \
sockaddr_cmp((struct sockaddr *)&(_a)->addr, \
diff --git a/sbin/iked/ikev2.c b/sbin/iked/ikev2.c
index 9abc9f87286..4d669c5704c 100644
--- a/sbin/iked/ikev2.c
+++ b/sbin/iked/ikev2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ikev2.c,v 1.39 2011/01/21 16:51:38 reyk Exp $ */
+/* $OpenBSD: ikev2.c,v 1.40 2011/01/21 17:01:33 reyk Exp $ */
/* $vantronix: ikev2.c,v 1.101 2010/06/03 07:57:33 reyk Exp $ */
/*
@@ -3383,10 +3383,10 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa, int initiator)
TAILQ_FOREACH(flow, &sa->sa_policy->pol_flows, flow_entry) {
skip = 0;
TAILQ_FOREACH(saflow, &sa->sa_flows, flow_entry) {
- if (memcmp(&saflow->flow_src, &flow->flow_src,
- sizeof(struct iked_addr)) == 0 &&
- memcmp(&saflow->flow_dst, &flow->flow_dst,
- sizeof(struct iked_addr)) == 0 &&
+ if (IKED_ADDR_EQ(&saflow->flow_src,
+ &flow->flow_src) &&
+ IKED_ADDR_EQ(&saflow->flow_dst,
+ &flow->flow_dst) &&
saflow->flow_saproto == prop->prop_protoid)
skip = 1;
}