diff options
-rw-r--r-- | src/config.c | 4 | ||||
-rw-r--r-- | src/dhcpv6.c | 3 | ||||
-rw-r--r-- | src/ndp.c | 25 | ||||
-rw-r--r-- | src/odhcpd.h | 3 | ||||
-rw-r--r-- | src/router.c | 1 |
5 files changed, 28 insertions, 8 deletions
diff --git a/src/config.c b/src/config.c index 689d4ce..943f243 100644 --- a/src/config.c +++ b/src/config.c @@ -760,11 +760,11 @@ void odhcpd_reload(void) setup_dhcpv6_interface(i, !i->ignore || i->dhcpv6 != RELAYD_DISABLED); setup_ndp_interface(i, !i->ignore || i->ndp != RELAYD_DISABLED); setup_dhcpv4_interface(i, !i->ignore || i->dhcpv4 != RELAYD_DISABLED); - } else { + } else close_interface(i); - } } + ndp_handle_addr6_dump(); uci_unload(uci, dhcp); uci_free_context(uci); } diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 81eae06..4cd9e02 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -90,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); @@ -49,6 +49,7 @@ static void handle_rtnl_event(struct odhcpd_event *ev); static int cb_rtnl_valid(struct nl_msg *msg, void *arg); static void catch_rtnl_err(struct odhcpd_event *e, int error); +static int addr6_dump_rqs = 0; static int ping_socket = -1; static struct event_socket rtnl_event = { .ev = { @@ -150,7 +151,7 @@ static void dump_neigh_table(const bool proxy) nlmsg_free(msg); } -static void dump_addr_table(void) +static void dump_addr6_table(void) { struct nl_msg *msg; struct ifaddrmsg ifa = { @@ -168,6 +169,20 @@ static void dump_addr_table(void) nlmsg_free(msg); } +void ndp_handle_addr6_dump(void) +{ + if (!addr6_dump_rqs) + return; + + dump_addr6_table(); + addr6_dump_rqs = 0; +} + +inline void ndp_rqs_addr6_dump(void) +{ + addr6_dump_rqs++; +} + int setup_ndp_interface(struct interface *iface, bool enable) { int ret = 0, procfd; @@ -193,10 +208,6 @@ int setup_ndp_interface(struct interface *iface, bool enable) dump_neigh = true; } - if (enable && (iface->ra == RELAYD_SERVER || - iface->dhcpv6 == RELAYD_SERVER || iface->ndp == RELAYD_RELAY)) - dump_addr_table(); - if (enable && iface->ndp == RELAYD_RELAY) { if (write(procfd, "1\n", 2) < 0) {} @@ -243,6 +254,8 @@ int setup_ndp_interface(struct interface *iface, bool enable) dump_neigh_table(false); else dump_neigh = false; + + ndp_rqs_addr6_dump(); } if (dump_neigh) @@ -570,7 +583,7 @@ static void catch_rtnl_err(struct odhcpd_event *e, int error) if (nl_socket_set_buffer_size(ev_sock->sock, ev_sock->sock_bufsize, 0)) goto err; - dump_addr_table(); + dump_addr6_table(); return; err: diff --git a/src/odhcpd.h b/src/odhcpd.h index 538a7e5..9733090 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -226,6 +226,9 @@ void odhcpd_bmemcpy(void *av, const void *bv, size_t bits); int config_parse_interface(void *data, size_t len, const char *iname, bool overwrite); +void ndp_handle_addr6_dump(void); +void ndp_rqs_addr6_dump(void); + #ifdef WITH_UBUS int init_ubus(void); const char* ubus_get_ifname(const char *name); diff --git a/src/router.c b/src/router.c index e8a9aa9..6e5111a 100644 --- a/src/router.c +++ b/src/router.c @@ -120,6 +120,7 @@ int setup_router_interface(struct interface *iface, bool enable) } else if (iface->ra == RELAYD_SERVER && !iface->master) { iface->timer_rs.cb = trigger_router_advert; uloop_timeout_set(&iface->timer_rs, 1000); + ndp_rqs_addr6_dump(); } if (iface->ra == RELAYD_RELAY || (iface->ra == RELAYD_SERVER && !iface->master)) |