diff mbox series

[OpenWrt-Devel,1/2,netifd] interface: set interface in TEARDOWN state when checking link state

Message ID 20190401083427.6783-1-dedeckeh@gmail.com
State Accepted
Headers show
Series [OpenWrt-Devel,1/2,netifd] interface: set interface in TEARDOWN state when checking link state | expand

Commit Message

Hans Dedecker April 1, 2019, 8:34 a.m. UTC
From: Hans dedecker <dedeckeh@gmail.com>

When launching PROTO_CMD_TEARDOWN in interface_check_state() the interface
was set in IFS_DOWN state. In case an interface is now brought into IFS_SETUP
state in __interface_set_up() it will launch PROTO_CMD_SETUP trying to
bring the proto shell handler in S_SETUP state which will fail as the proto
shell handler is still in the S_TEARDOWN state.

Fix this by setting the interface in IFS_TEARDOWN state when the PROTO_CMD_TEARDOWN
event is launched which will prevent the interface being brought into IFS_SETUP state
as long as it's not in the IFS_DOWN state.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
---
 interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/interface.c b/interface.c
index b8c4ae2..fd7a826 100644
--- a/interface.c
+++ b/interface.c
@@ -342,11 +342,11 @@  interface_check_state(struct interface *iface)
 	case IFS_UP:
 	case IFS_SETUP:
 		if (!iface->enabled || !link_state) {
-			interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false);
+			iface->state = IFS_TEARDOWN;
 			if (iface->dynamic)
 				__set_config_state(iface, IFC_REMOVE);
 
-			mark_interface_down(iface);
+			interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false);
 		}
 		break;
 	case IFS_DOWN: