summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/config.c28
-rw-r--r--src/netlink.c9
-rw-r--r--src/odhcpd.h1
3 files changed, 31 insertions, 7 deletions
diff --git a/src/config.c b/src/config.c
index 27e7f03..85d77b0 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1209,6 +1209,27 @@ struct lease *config_find_lease_by_ipaddr(const uint32_t ipaddr)
return NULL;
}
+void reload_services(struct interface *iface)
+{
+ if (iface->ifflags & IFF_RUNNING) {
+ syslog(LOG_DEBUG, "Enabling services with %s running", iface->ifname);
+ router_setup_interface(iface, iface->ra != MODE_DISABLED);
+ dhcpv6_setup_interface(iface, iface->dhcpv6 != MODE_DISABLED);
+ ndp_setup_interface(iface, iface->ndp != MODE_DISABLED);
+#ifdef DHCPV4_SUPPORT
+ dhcpv4_setup_interface(iface, iface->dhcpv4 != MODE_DISABLED);
+#endif
+ } else {
+ syslog(LOG_DEBUG, "Disabling services with %s not running", iface->ifname);
+ router_setup_interface(iface, false);
+ dhcpv6_setup_interface(iface, false);
+ ndp_setup_interface(iface, false);
+#ifdef DHCPV4_SUPPORT
+ dhcpv4_setup_interface(iface, false);
+#endif
+ }
+}
+
void odhcpd_reload(void)
{
struct uci_context *uci = uci_alloc_context();
@@ -1326,12 +1347,7 @@ void odhcpd_reload(void)
i->ndp = (master && master->ndp == MODE_RELAY) ?
MODE_RELAY : MODE_DISABLED;
- router_setup_interface(i, i->ra != MODE_DISABLED);
- dhcpv6_setup_interface(i, i->dhcpv6 != MODE_DISABLED);
- ndp_setup_interface(i, i->ndp != MODE_DISABLED);
-#ifdef DHCPV4_SUPPORT
- dhcpv4_setup_interface(i, i->dhcpv4 != MODE_DISABLED);
-#endif
+ reload_services(i);
} else
close_interface(i);
}
diff --git a/src/netlink.c b/src/netlink.c
index 0a2da03..9b9fdb8 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -313,8 +313,15 @@ static int handle_rtm_link(struct nlmsghdr *hdr)
iface->ifflags = ifi->ifi_flags;
- if (iface->ifindex == ifi->ifi_index)
+ /*
+ * Assume for link event of the same index, that link changed
+ * and reload services to enable or disable them based on the
+ * RUNNING state of the interface.
+ */
+ if (iface->ifindex == ifi->ifi_index) {
+ reload_services(iface);
continue;
+ }
iface->ifindex = ifi->ifi_index;
event_info.iface = iface;
diff --git a/src/odhcpd.h b/src/odhcpd.h
index 0550bc2..bd61b01 100644
--- a/src/odhcpd.h
+++ b/src/odhcpd.h
@@ -475,5 +475,6 @@ void dhcpv4_handle_msg(void *addr, void *data, size_t len,
int router_setup_interface(struct interface *iface, bool enable);
int dhcpv6_setup_interface(struct interface *iface, bool enable);
int ndp_setup_interface(struct interface *iface, bool enable);
+void reload_services(struct interface *iface);
void odhcpd_reload(void);