Begin rewrite of NDP-relay
[project/odhcpd.git] / src / ndp.c
index 9fc539b..fd0134e 100644 (file)
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -73,16 +73,6 @@ int init_ndp(void)
        setsockopt(rtnl_event.uloop.fd, SOL_NETLINK,
                        NETLINK_ADD_MEMBERSHIP, &group, sizeof(group));
 
-       // Synthesize initial address events
-       struct {
-               struct nlmsghdr nh;
-               struct ifaddrmsg ifa;
-       } req2 = {
-               {sizeof(req2), RTM_GETADDR, NLM_F_REQUEST | NLM_F_DUMP,
-                               ++rtnl_seqid, 0},
-               {.ifa_family = AF_INET6}
-       };
-       send(rtnl_event.uloop.fd, &req2, sizeof(req2), MSG_DONTWAIT);
        odhcpd_register(&rtnl_event);
 
        // Open ICMPv6 socket
@@ -144,6 +134,19 @@ int setup_ndp_interface(struct interface *iface, bool enable)
                dump_neigh = true;
        }
 
+       if (enable && (iface->ra == RELAYD_SERVER || iface->dhcpv6 == RELAYD_SERVER)) {
+               // Synthesize initial address events
+               struct {
+                       struct nlmsghdr nh;
+                       struct ifaddrmsg ifa;
+               } req2 = {
+                       {sizeof(req2), RTM_GETADDR, NLM_F_REQUEST | NLM_F_DUMP,
+                                       ++rtnl_seqid, 0},
+                       {.ifa_family = AF_INET6, .ifa_index = iface->ifindex}
+               };
+               send(rtnl_event.uloop.fd, &req2, sizeof(req2), MSG_DONTWAIT);
+       }
+
        if (enable && iface->ndp == RELAYD_RELAY) {
                write(procfd, "1\n", 2);