config: limit ra_mtu to 65535
[project/odhcpd.git] / src / dhcpv6.c
index 7442b2d..ebb0c80 100644 (file)
@@ -18,6 +18,7 @@
 #include <stddef.h>
 #include <resolv.h>
 #include <sys/timerfd.h>
+#include <arpa/inet.h>
 
 #include "odhcpd.h"
 #include "dhcpv6.h"
@@ -51,7 +52,7 @@ int setup_dhcpv6_interface(struct interface *iface, bool enable)
        }
 
        // Configure multicast settings
-       if (enable && iface->dhcpv6 && !iface->master) {
+       if (enable && iface->dhcpv6) {
                int sock = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
                if (sock < 0) {
                        syslog(LOG_ERR, "Failed to create DHCPv6 server socket: %s",
@@ -89,6 +90,9 @@ int setup_dhcpv6_interface(struct interface *iface, bool enable)
                if (iface->dhcpv6 == RELAYD_SERVER)
                        setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &server, sizeof(server));
 
+               if (iface->dhcpv6 != RELAYD_RELAY || !iface->master)
+                       ndp_rqs_addr6_dump();
+
                iface->dhcpv6_event.uloop.fd = sock;
                iface->dhcpv6_event.handle_dgram = handle_dhcpv6;
                odhcpd_register(&iface->dhcpv6_event);
@@ -228,7 +232,7 @@ static void handle_client_request(void *addr, void *data, size_t len,
        size_t dns_cnt = iface->dns_cnt;
 
        if ((dns_cnt == 0) &&
-               odhcpd_get_preferred_interface_address(iface->ifindex, &dns_addr)) {
+               !odhcpd_get_interface_dns_addr(iface, &dns_addr)) {
                dns_addr_ptr = &dns_addr;
                dns_cnt = 1;
        }
@@ -460,7 +464,7 @@ static void relay_server_response(uint8_t *data, size_t len)
                size_t rewrite_cnt = iface->dns_cnt;
 
                if (rewrite_cnt == 0) {
-                       if (odhcpd_get_preferred_interface_address(iface->ifindex, &addr) < 1)
+                       if (odhcpd_get_interface_dns_addr(iface, &addr))
                                return; // Unable to get interface address
 
                        rewrite = &addr;