summaryrefslogtreecommitdiff
path: root/interface.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2018-11-16 16:25:41 +0100
committerHans Dedecker <dedeckeh@gmail.com>2018-11-16 18:50:14 +0100
commitd9872db72eb63e9fa454446756e10fc7c52effc5 (patch)
tree2866bb13d0bddb245b8ce02bd00dc4ed0c6a30dd /interface.c
parent2f7ef7dc6cb542d5811f64fa7af97fb8619c9429 (diff)
downloadnetifd-d9872db72eb63e9fa454446756e10fc7c52effc5.tar.gz
interface: fix removal of dynamic interfaces
Set config state to remove for dynamic interfaces in the following cases : -interface is set as not available -interface is set as down -interface is set as having no link state This will trigger an interface delete upon the next call of interface_handle_config_change Before this change you could end up with lingering inactive dynamic interfaces in case the aliased interface went down as before a dynamic interface was only removed when set down via ubus Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/interface.c b/interface.c
index 36f5480..4a09a22 100644
--- a/interface.c
+++ b/interface.c
@@ -284,6 +284,12 @@ mark_interface_down(struct interface *iface)
system_flush_routes();
}
+static inline void
+__set_config_state(struct interface *iface, enum interface_config_state s)
+{
+ iface->config_state = s;
+}
+
static void
__interface_set_down(struct interface *iface, bool force)
{
@@ -292,6 +298,9 @@ __interface_set_down(struct interface *iface, bool force)
case IFS_UP:
case IFS_SETUP:
iface->state = IFS_TEARDOWN;
+ if (iface->dynamic)
+ __set_config_state(iface, IFC_REMOVE);
+
if (state == IFS_UP)
interface_event(iface, IFEV_DOWN);
@@ -334,6 +343,9 @@ interface_check_state(struct interface *iface)
case IFS_SETUP:
if (!iface->enabled || !link_state) {
interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false);
+ if (iface->dynamic)
+ __set_config_state(iface, IFC_REMOVE);
+
mark_interface_down(iface);
}
break;
@@ -697,8 +709,6 @@ interface_handle_config_change(struct interface *iface)
}
if (iface->autostart)
interface_set_up(iface);
- else if (iface->dynamic)
- set_config_state(iface, IFC_REMOVE);
}
static void
@@ -1120,7 +1130,7 @@ interface_start_pending(void)
static void
set_config_state(struct interface *iface, enum interface_config_state s)
{
- iface->config_state = s;
+ __set_config_state(iface, s);
if (iface->state == IFS_DOWN)
interface_handle_config_change(iface);
else