Compare the l2 address from which the slaac address was formed with
authorflorian <florian@openbsd.org>
Mon, 29 May 2017 08:15:38 +0000 (08:15 +0000)
committerflorian <florian@openbsd.org>
Mon, 29 May 2017 08:15:38 +0000 (08:15 +0000)
the current interface l2 address. Only update the address lifetime if
they are the same. This way we get a new address on ifconfig lladdr
random.

usr.sbin/slaacd/engine.c

index 7a873f1..7bbf65f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: engine.c,v 1.25 2017/05/29 07:54:46 florian Exp $     */
+/*     $OpenBSD: engine.c,v 1.26 2017/05/29 08:15:38 florian Exp $     */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -172,6 +172,7 @@ struct address_proposal {
        struct timespec                  when;
        struct timespec                  uptime;
        uint32_t                         if_index;
+       struct ether_addr                hw_address;
        struct sockaddr_in6              addr;
        struct in6_addr                  mask;
        struct in6_addr                  prefix;
@@ -1555,6 +1556,12 @@ void update_iface_ra(struct slaacd_iface *iface, struct radv *ra)
                                    &addr_proposal->prefix,
                                    sizeof(struct in6_addr)) != 0)
                                        continue;
+
+                               if (memcmp(&addr_proposal->hw_address,
+                                   &iface->hw_address,
+                                   sizeof(addr_proposal->hw_address)) != 0)
+                                       continue;
+
                                if (addr_proposal->privacy) {
                                        /*
                                         * create new privacy address if old
@@ -1675,6 +1682,8 @@ gen_address_proposal(struct slaacd_iface *iface, struct radv *ra, struct
        addr_proposal->when = ra->when;
        addr_proposal->uptime = ra->uptime;
        addr_proposal->if_index = iface->if_index;
+       memcpy(&addr_proposal->hw_address, &iface->hw_address,
+           sizeof(addr_proposal->hw_address));
        addr_proposal->privacy = privacy;
        memcpy(&addr_proposal->prefix, &prefix->prefix,
            sizeof(addr_proposal->prefix));