summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2017-05-05 11:04:18 +0000
committerbluhm <bluhm@openbsd.org>2017-05-05 11:04:18 +0000
commitc4b6a3a9989f0e9a13953930e6af53f5bbde7256 (patch)
treeeab05d57084817196a96c84c3508d0030f5cbd78
parentmore simplification and removal of SSHv1-related code; ok djm@ (diff)
downloadwireguard-openbsd-c4b6a3a9989f0e9a13953930e6af53f5bbde7256.tar.xz
wireguard-openbsd-c4b6a3a9989f0e9a13953930e6af53f5bbde7256.zip
Expand SA_LEN(), there is no benefit for using the macro in the
kernel. It was only used in IPsec sources. No binary change OK deraadt@
-rw-r--r--sys/net/pfkeyv2.c28
-rw-r--r--sys/net/pfkeyv2_convert.c8
-rw-r--r--sys/netinet/ip_ipsp.c20
-rw-r--r--sys/netinet/ipsec_input.c6
4 files changed, 31 insertions, 31 deletions
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c
index 5ff3eba4c40..b56010365dd 100644
--- a/sys/net/pfkeyv2.c
+++ b/sys/net/pfkeyv2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2.c,v 1.153 2017/02/28 16:46:27 bluhm Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.154 2017/05/05 11:04:18 bluhm Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
@@ -521,8 +521,8 @@ pfkeyv2_get(struct tdb *sa, void **headers, void **buffer, int *lenp)
if (sa->tdb_last_used)
i += sizeof(struct sadb_lifetime);
- i += sizeof(struct sadb_address) + PADUP(SA_LEN(&sa->tdb_src.sa));
- i += sizeof(struct sadb_address) + PADUP(SA_LEN(&sa->tdb_dst.sa));
+ i += sizeof(struct sadb_address) + PADUP(sa->tdb_src.sa.sa_len);
+ i += sizeof(struct sadb_address) + PADUP(sa->tdb_dst.sa.sa_len);
if (sa->tdb_ids) {
i += sizeof(struct sadb_ident) + PADUP(sa->tdb_ids->id_local->len);
@@ -559,7 +559,7 @@ pfkeyv2_get(struct tdb *sa, void **headers, void **buffer, int *lenp)
if (sa->tdb_onext) {
i += sizeof(struct sadb_sa);
i += sizeof(struct sadb_address) +
- PADUP(SA_LEN(&sa->tdb_onext->tdb_dst.sa));
+ PADUP(sa->tdb_onext->tdb_dst.sa.sa_len);
i += sizeof(struct sadb_protocol);
}
@@ -1730,8 +1730,8 @@ pfkeyv2_acquire(struct ipsec_policy *ipo, union sockaddr_union *gw,
/* How large a buffer do we need... XXX we only do one proposal for now */
i = sizeof(struct sadb_msg) +
(laddr == NULL ? 0 : sizeof(struct sadb_address) +
- PADUP(SA_LEN(&ipo->ipo_src.sa))) +
- sizeof(struct sadb_address) + PADUP(SA_LEN(&gw->sa)) +
+ PADUP(ipo->ipo_src.sa.sa_len)) +
+ sizeof(struct sadb_address) + PADUP(gw->sa.sa_len) +
sizeof(struct sadb_prop) + 1 * sizeof(struct sadb_comb);
if (ipo->ipo_ids) {
@@ -1767,22 +1767,22 @@ pfkeyv2_acquire(struct ipsec_policy *ipo, union sockaddr_union *gw,
if (laddr) {
headers[SADB_EXT_ADDRESS_SRC] = p;
- p += sizeof(struct sadb_address) + PADUP(SA_LEN(&laddr->sa));
+ p += sizeof(struct sadb_address) + PADUP(laddr->sa.sa_len);
sadd = (struct sadb_address *) headers[SADB_EXT_ADDRESS_SRC];
sadd->sadb_address_len = (sizeof(struct sadb_address) +
- SA_LEN(&laddr->sa) + sizeof(uint64_t) - 1) /
+ laddr->sa.sa_len + sizeof(uint64_t) - 1) /
sizeof(uint64_t);
bcopy(laddr, headers[SADB_EXT_ADDRESS_SRC] +
- sizeof(struct sadb_address), SA_LEN(&laddr->sa));
+ sizeof(struct sadb_address), laddr->sa.sa_len);
}
headers[SADB_EXT_ADDRESS_DST] = p;
- p += sizeof(struct sadb_address) + PADUP(SA_LEN(&gw->sa));
+ p += sizeof(struct sadb_address) + PADUP(gw->sa.sa_len);
sadd = (struct sadb_address *) headers[SADB_EXT_ADDRESS_DST];
sadd->sadb_address_len = (sizeof(struct sadb_address) +
- SA_LEN(&gw->sa) + sizeof(uint64_t) - 1) / sizeof(uint64_t);
+ gw->sa.sa_len + sizeof(uint64_t) - 1) / sizeof(uint64_t);
bcopy(gw, headers[SADB_EXT_ADDRESS_DST] + sizeof(struct sadb_address),
- SA_LEN(&gw->sa));
+ gw->sa.sa_len);
if (ipo->ipo_ids)
export_identities(&p, ipo->ipo_ids, 0, headers);
@@ -1939,8 +1939,8 @@ pfkeyv2_expire(struct tdb *sa, u_int16_t type)
i = sizeof(struct sadb_msg) + sizeof(struct sadb_sa) +
2 * sizeof(struct sadb_lifetime) +
- sizeof(struct sadb_address) + PADUP(SA_LEN(&sa->tdb_src.sa)) +
- sizeof(struct sadb_address) + PADUP(SA_LEN(&sa->tdb_dst.sa));
+ sizeof(struct sadb_address) + PADUP(sa->tdb_src.sa.sa_len) +
+ sizeof(struct sadb_address) + PADUP(sa->tdb_dst.sa.sa_len);
if (!(p = malloc(i, M_PFKEY, M_NOWAIT | M_ZERO))) {
rval = ENOMEM;
diff --git a/sys/net/pfkeyv2_convert.c b/sys/net/pfkeyv2_convert.c
index 9109f07f65c..2008489046d 100644
--- a/sys/net/pfkeyv2_convert.c
+++ b/sys/net/pfkeyv2_convert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2_convert.c,v 1.59 2017/02/28 16:46:27 bluhm Exp $ */
+/* $OpenBSD: pfkeyv2_convert.c,v 1.60 2017/05/05 11:04:18 bluhm Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@keromytis.org)
*
@@ -685,12 +685,12 @@ export_address(void **p, struct sockaddr *sa)
struct sadb_address *sadb_address = (struct sadb_address *) *p;
sadb_address->sadb_address_len = (sizeof(struct sadb_address) +
- PADUP(SA_LEN(sa))) / sizeof(uint64_t);
+ PADUP(sa->sa_len)) / sizeof(uint64_t);
*p += sizeof(struct sadb_address);
- bcopy(sa, *p, SA_LEN(sa));
+ bcopy(sa, *p, sa->sa_len);
((struct sockaddr *) *p)->sa_family = sa->sa_family;
- *p += PADUP(SA_LEN(sa));
+ *p += PADUP(sa->sa_len);
}
/*
diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c
index cbe4b1f307c..49ef81aa4ec 100644
--- a/sys/netinet/ip_ipsp.c
+++ b/sys/netinet/ip_ipsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ipsp.c,v 1.220 2017/02/14 09:51:46 mpi Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.221 2017/05/05 11:04:18 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
@@ -160,7 +160,7 @@ tdb_hash(u_int rdomain, u_int32_t spi, union sockaddr_union *dst,
SipHash24_Update(&ctx, &rdomain, sizeof(rdomain));
SipHash24_Update(&ctx, &spi, sizeof(spi));
SipHash24_Update(&ctx, &proto, sizeof(proto));
- SipHash24_Update(&ctx, dst, SA_LEN(&dst->sa));
+ SipHash24_Update(&ctx, dst, dst->sa.sa_len);
return (SipHash24_End(&ctx) & tdb_hashmask);
}
@@ -237,8 +237,8 @@ reserve_spi(u_int rdomain, u_int32_t sspi, u_int32_t tspi,
tdbp->tdb_spi = spi;
- memcpy(&tdbp->tdb_dst.sa, &dst->sa, SA_LEN(&dst->sa));
- memcpy(&tdbp->tdb_src.sa, &src->sa, SA_LEN(&src->sa));
+ memcpy(&tdbp->tdb_dst.sa, &dst->sa, dst->sa.sa_len);
+ memcpy(&tdbp->tdb_src.sa, &src->sa, src->sa.sa_len);
tdbp->tdb_sproto = sproto;
tdbp->tdb_flags |= TDBF_INVALID; /* Mark SA invalid for now. */
tdbp->tdb_satype = SADB_SATYPE_UNSPEC;
@@ -283,7 +283,7 @@ gettdb(u_int rdomain, u_int32_t spi, union sockaddr_union *dst, u_int8_t proto)
for (tdbp = tdbh[hashval]; tdbp != NULL; tdbp = tdbp->tdb_hnext)
if ((tdbp->tdb_spi == spi) && (tdbp->tdb_sproto == proto) &&
(tdbp->tdb_rdomain == rdomain) &&
- !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))
+ !memcmp(&tdbp->tdb_dst, dst, dst->sa.sa_len))
break;
return tdbp;
@@ -313,8 +313,8 @@ gettdbbysrcdst(u_int rdomain, u_int32_t spi, union sockaddr_union *src,
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
(tdbp->tdb_dst.sa.sa_family == AF_UNSPEC ||
- !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) &&
- !memcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))
+ !memcmp(&tdbp->tdb_dst, dst, dst->sa.sa_len)) &&
+ !memcmp(&tdbp->tdb_src, src, src->sa.sa_len))
break;
if (tdbp != NULL)
@@ -330,7 +330,7 @@ gettdbbysrcdst(u_int rdomain, u_int32_t spi, union sockaddr_union *src,
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
(tdbp->tdb_dst.sa.sa_family == AF_UNSPEC ||
- !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) &&
+ !memcmp(&tdbp->tdb_dst, dst, dst->sa.sa_len)) &&
tdbp->tdb_src.sa.sa_family == AF_UNSPEC)
break;
@@ -395,7 +395,7 @@ gettdbbydst(u_int rdomain, union sockaddr_union *dst, u_int8_t sproto,
if ((tdbp->tdb_sproto == sproto) &&
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
- (!memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))) {
+ (!memcmp(&tdbp->tdb_dst, dst, dst->sa.sa_len))) {
/* Do IDs match ? */
if (!ipsp_aux_match(tdbp, ids, filter, filtermask))
continue;
@@ -426,7 +426,7 @@ gettdbbysrc(u_int rdomain, union sockaddr_union *src, u_int8_t sproto,
if ((tdbp->tdb_sproto == sproto) &&
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
- (!memcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))) {
+ (!memcmp(&tdbp->tdb_src, src, src->sa.sa_len))) {
/* Check whether IDs match */
if (!ipsp_aux_match(tdbp, ids, filter,
filtermask))
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c
index de3dd99b4c1..8ded384c8d9 100644
--- a/sys/netinet/ipsec_input.c
+++ b/sys/netinet/ipsec_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsec_input.c,v 1.147 2017/04/14 20:46:31 bluhm Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.148 2017/05/05 11:04:18 bluhm Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -806,8 +806,8 @@ udpencap_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v)
if (tdbp->tdb_sproto == IPPROTO_ESP &&
((tdbp->tdb_flags & (TDBF_INVALID|TDBF_UDPENCAP)) ==
TDBF_UDPENCAP) &&
- !memcmp(&tdbp->tdb_dst, &dst, SA_LEN(&su_dst->sa)) &&
- !memcmp(&tdbp->tdb_src, &src, SA_LEN(&su_src->sa))) {
+ !memcmp(&tdbp->tdb_dst, &dst, su_dst->sa.sa_len) &&
+ !memcmp(&tdbp->tdb_src, &src, su_src->sa.sa_len)) {
if ((adjust = ipsec_hdrsz(tdbp)) != -1) {
/* Store adjusted MTU in tdb */
tdbp->tdb_mtu = mtu - adjust;