summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2018-06-20 14:55:30 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2018-06-20 14:55:30 +0000
commit2880447b2b076ce6dae12af5fd7f074435a5f117 (patch)
tree2e96cef41b22bffe6ac5bd18cabd5584938a1cb0 /sbin
parent0e21f1f0ae826f453ed1448101da4b289313923c (diff)
This might have been a good idea 20 years ago but in this day and age
the compiler is probably better at unrolling loops. style nit fcambus OK phessler
Diffstat (limited to 'sbin')
-rw-r--r--sbin/slaacd/engine.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/sbin/slaacd/engine.c b/sbin/slaacd/engine.c
index 9f94bf177ff..961e1b115b6 100644
--- a/sbin/slaacd/engine.c
+++ b/sbin/slaacd/engine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: engine.c,v 1.26 2018/05/18 11:06:59 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.27 2018/06/20 14:55:29 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -1262,6 +1262,7 @@ gen_addr(struct slaacd_iface *iface, struct radv_prefix *prefix, struct
SHA2_CTX ctx;
struct in6_addr iid;
int dad_counter = 0; /* XXX not used */
+ int i;
u_int8_t digest[SHA512_DIGEST_LENGTH];
memset(&iid, 0, sizeof(iid));
@@ -1280,14 +1281,9 @@ gen_addr(struct slaacd_iface *iface, struct radv_prefix *prefix, struct
memcpy(&addr_proposal->addr.sin6_addr, &prefix->prefix,
sizeof(addr_proposal->addr.sin6_addr));
- addr_proposal->addr.sin6_addr.s6_addr32[0] &=
- addr_proposal->mask.s6_addr32[0];
- addr_proposal->addr.sin6_addr.s6_addr32[1] &=
- addr_proposal->mask.s6_addr32[1];
- addr_proposal->addr.sin6_addr.s6_addr32[2] &=
- addr_proposal->mask.s6_addr32[2];
- addr_proposal->addr.sin6_addr.s6_addr32[3] &=
- addr_proposal->mask.s6_addr32[3];
+ for (i = 0; i < 4; i++)
+ addr_proposal->addr.sin6_addr.s6_addr32[i] &=
+ addr_proposal->mask.s6_addr32[i];
if (privacy) {
arc4random_buf(&iid.s6_addr, sizeof(iid.s6_addr));
@@ -1310,14 +1306,9 @@ gen_addr(struct slaacd_iface *iface, struct radv_prefix *prefix, struct
sizeof(iid.s6_addr));
}
- addr_proposal->addr.sin6_addr.s6_addr32[0] |=
- (iid.s6_addr32[0] & ~addr_proposal->mask.s6_addr32[0]);
- addr_proposal->addr.sin6_addr.s6_addr32[1] |=
- (iid.s6_addr32[1] & ~addr_proposal->mask.s6_addr32[1]);
- addr_proposal->addr.sin6_addr.s6_addr32[2] |=
- (iid.s6_addr32[2] & ~addr_proposal->mask.s6_addr32[2]);
- addr_proposal->addr.sin6_addr.s6_addr32[3] |=
- (iid.s6_addr32[3] & ~addr_proposal->mask.s6_addr32[3]);
+ for (i = 0; i < 4; i++)
+ addr_proposal->addr.sin6_addr.s6_addr32[i] |=
+ (iid.s6_addr32[i] & ~addr_proposal->mask.s6_addr32[i]);
#undef s6_addr32
}