RFC 8981 allows the configuration of only temporary IPv6 addresses.
authorflorian <florian@openbsd.org>
Sat, 20 Mar 2021 17:07:49 +0000 (17:07 +0000)
committerflorian <florian@openbsd.org>
Sat, 20 Mar 2021 17:07:49 +0000 (17:07 +0000)
Track autoconf and temporary flag individually to be able to support
this.
OK kn

sbin/slaacd/engine.c
sbin/slaacd/frontend.c
sbin/slaacd/slaacd.h

index 34e16ef..7b49b33 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: engine.c,v 1.68 2021/03/20 16:46:03 kn Exp $  */
+/*     $OpenBSD: engine.c,v 1.69 2021/03/20 17:07:49 florian Exp $     */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -248,6 +248,7 @@ struct slaacd_iface {
        uint32_t                         if_index;
        uint32_t                         rdomain;
        int                              running;
+       int                              autoconf;
        int                              autoconfprivacy;
        int                              soii;
        struct ether_addr                hw_address;
@@ -786,6 +787,7 @@ send_interface_info(struct slaacd_iface *iface, pid_t pid)
        memset(&cei, 0, sizeof(cei));
        cei.if_index = iface->if_index;
        cei.running = iface->running;
+       cei.autoconf = iface->autoconf;
        cei.autoconfprivacy = iface->autoconfprivacy;
        cei.soii = iface->soii;
        memcpy(&cei.hw_address, &iface->hw_address, sizeof(struct ether_addr));
@@ -1089,6 +1091,7 @@ engine_update_iface(struct imsg_ifinfo *imsg_ifinfo)
                iface->rdomain = imsg_ifinfo->rdomain;
                iface->running = imsg_ifinfo->running;
                iface->link_state = imsg_ifinfo->link_state;
+               iface->autoconf = imsg_ifinfo->autoconf;
                iface->autoconfprivacy = imsg_ifinfo->autoconfprivacy;
                iface->soii = imsg_ifinfo->soii;
                memcpy(&iface->hw_address, &imsg_ifinfo->hw_address,
@@ -1107,6 +1110,11 @@ engine_update_iface(struct imsg_ifinfo *imsg_ifinfo)
                memcpy(&iface->ll_address, &imsg_ifinfo->ll_address,
                    sizeof(struct sockaddr_in6));
 
+               if (iface->autoconf != imsg_ifinfo->autoconf) {
+                       iface->autoconf = imsg_ifinfo->autoconf;
+                       need_refresh = 1;
+               }
+
                if (iface->autoconfprivacy != imsg_ifinfo->autoconfprivacy) {
                        iface->autoconfprivacy = imsg_ifinfo->autoconfprivacy;
                        need_refresh = 1;
@@ -1913,11 +1921,12 @@ update_iface_ra_prefix(struct slaacd_iface *iface, struct radv *ra,
                }
        }
 
-       if (!found && duplicate_found && iface->soii) {
+       if (!found && iface->autoconf && duplicate_found && iface->soii) {
                prefix->dad_counter++;
                log_debug("%s dad_counter: %d", __func__, prefix->dad_counter);
                gen_address_proposal(iface, ra, prefix, 0);
-       } else if (!found && (iface->soii || prefix->prefix_len <= 64))
+       } else if (!found  && iface->autoconf && (iface->soii ||
+           prefix->prefix_len <= 64))
                /* new proposal */
                gen_address_proposal(iface, ra, prefix, 0);
 
index 47dc80b..ebd8e9b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: frontend.c,v 1.53 2021/03/20 16:46:03 kn Exp $        */
+/*     $OpenBSD: frontend.c,v 1.54 2021/03/20 17:07:49 florian Exp $   */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -502,7 +502,7 @@ update_iface(uint32_t if_index, char* if_name)
            get_xflags(if_name)) == -1)
                return;
 
-       if (!(xflags & IFXF_AUTOCONF6))
+       if (!(xflags & (IFXF_AUTOCONF6 | IFXF_AUTOCONF6TEMP)))
                return;
 
        if((ifrdomain = get_ifrdomain(if_name)) == -1)
@@ -532,6 +532,7 @@ update_iface(uint32_t if_index, char* if_name)
        imsg_ifinfo.rdomain = ifrdomain;
        imsg_ifinfo.running = (flags & (IFF_UP | IFF_RUNNING)) == (IFF_UP |
            IFF_RUNNING);
+       imsg_ifinfo.autoconf = (xflags & IFXF_AUTOCONF6);
        imsg_ifinfo.autoconfprivacy = (xflags & IFXF_AUTOCONF6TEMP);
        imsg_ifinfo.soii = !(xflags & IFXF_INET6_NOSOII);
 
@@ -597,7 +598,7 @@ update_autoconf_addresses(uint32_t if_index, char* if_name)
        if ((xflags = get_xflags(if_name)) == -1)
                return;
 
-       if (!(xflags & IFXF_AUTOCONF6))
+       if (!(xflags & (IFXF_AUTOCONF6 | IFXF_AUTOCONF6TEMP)))
                return;
 
        memset(&imsg_addrinfo, 0, sizeof(imsg_addrinfo));
@@ -796,7 +797,8 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info)
                            &if_index, sizeof(if_index));
                } else {
                        xflags = get_xflags(if_name);
-                       if (xflags == -1 || !(xflags & IFXF_AUTOCONF6)) {
+                       if (xflags == -1 || !(xflags & (IFXF_AUTOCONF6 |
+                           IFXF_AUTOCONF6TEMP))) {
                                log_debug("RTM_IFINFO: %s(%d) no(longer) "
                                   "autoconf6", if_name, ifm->ifm_index);
                                if_index = ifm->ifm_index;
index 2f0830f..4b6ca98 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: slaacd.h,v 1.31 2021/03/07 10:31:20 florian Exp $     */
+/*     $OpenBSD: slaacd.h,v 1.32 2021/03/20 17:07:49 florian Exp $     */
 
 /*
  * Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -87,6 +87,7 @@ enum rpref {
 struct ctl_engine_info {
        uint32_t                if_index;
        int                     running;
+       int                     autoconf;
        int                     autoconfprivacy;
        int                     soii;
        struct ether_addr       hw_address;
@@ -189,6 +190,7 @@ struct imsg_ifinfo {
        int                     rdomain;
        int                     running;
        int                     link_state;
+       int                     autoconf;
        int                     autoconfprivacy;
        int                     soii;
        struct ether_addr       hw_address;