summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-09-11 21:38:11 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-09-11 21:38:11 +0200
commit13cb667dc2c4131663e728bfc4bf3de465d52b20 (patch)
treeb81475679207a5da2475d6dc146b387931627c38
parent924d9c4e48ed2044efe712eac9cd170f4da4b447 (diff)
downloadnetifd-13cb667dc2c4131663e728bfc4bf3de465d52b20.tar.gz
add a protocol event for link loss
-rw-r--r--interface.c7
-rw-r--r--proto-shell.c13
-rw-r--r--proto.h1
3 files changed, 10 insertions, 11 deletions
diff --git a/interface.c b/interface.c
index 72ecf4d..a5675f7 100644
--- a/interface.c
+++ b/interface.c
@@ -185,6 +185,13 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
mark_interface_down(iface);
break;
+ case IFPEV_LINK_LOST:
+ if (iface->state != IFS_UP)
+ return;
+
+ iface->state = IFS_SETUP;
+ interface_event(iface, IFEV_DOWN);
+ break;
}
}
diff --git a/proto-shell.c b/proto-shell.c
index 1481b66..bb42c98 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -60,15 +60,6 @@ run_script(const char **argv, struct uloop_process *proc)
return 0;
}
-static void
-proto_shell_set_down(struct proto_shell_state *state)
-{
- if (!state->l3_dev.dev)
- return;
-
- device_remove_user(&state->l3_dev);
-}
-
static int
proto_shell_handler(struct interface_proto_state *proto,
enum interface_proto_cmd cmd, bool force)
@@ -145,8 +136,8 @@ proto_shell_teardown_cb(struct uloop_process *p, int ret)
struct proto_shell_state *state;
state = container_of(p, struct proto_shell_state, teardown_task);
- proto_shell_set_down(state);
state->proto.proto_event(&state->proto, IFPEV_DOWN);
+ device_remove_user(&state->l3_dev);
}
static void
@@ -194,7 +185,7 @@ proto_shell_notify(struct interface_proto_state *proto, struct blob_attr *attr)
state->proto.iface->l3_dev = &state->l3_dev;
state->proto.proto_event(&state->proto, IFPEV_UP);
} else {
- proto_shell_set_down(state);
+ state->proto.proto_event(&state->proto, IFPEV_LINK_LOST);
}
return 0;
diff --git a/proto.h b/proto.h
index c1b97b2..b4a1d04 100644
--- a/proto.h
+++ b/proto.h
@@ -8,6 +8,7 @@ struct proto_handler;
enum interface_proto_event {
IFPEV_UP,
IFPEV_DOWN,
+ IFPEV_LINK_LOST,
};
enum interface_proto_cmd {