Do not request a prefix with length zero.
authorflorian <florian@openbsd.org>
Wed, 5 Jun 2024 10:25:07 +0000 (10:25 +0000)
committerflorian <florian@openbsd.org>
Wed, 5 Jun 2024 10:25:07 +0000 (10:25 +0000)
If we got a prefix delegation for some IA but not others use the
prefix lenght from the configuration for the ones we did not get a
prefix delegation.

sbin/dhcp6leased/frontend.c

index 6dc1abe..c5cb446 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: frontend.c,v 1.9 2024/06/04 15:48:47 florian Exp $    */
+/*     $OpenBSD: frontend.c,v 1.10 2024/06/05 10:25:07 florian Exp $   */
 
 /*
  * Copyright (c) 2017, 2021, 2024 Florian Obser <florian@openbsd.org>
@@ -874,9 +874,12 @@ build_packet(uint8_t message_type, struct iface *iface, char *if_name)
                case DHCPRENEW:
                case DHCPREBIND:
                        pd = &iface->pds[ia_conf->id];
-                       iaprefix.prefix_len = pd->prefix_len;
-                       memcpy(&iaprefix.prefix, &pd->prefix,
-                           sizeof(struct in6_addr));
+                       if (pd->prefix_len > 0) {
+                               iaprefix.prefix_len = pd->prefix_len;
+                               memcpy(&iaprefix.prefix, &pd->prefix,
+                                   sizeof(struct in6_addr));
+                       } else
+                               iaprefix.prefix_len = ia_conf->prefix_len;
                        break;
                default:
                        fatalx("%s: %s not implemented", __func__,