summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-event.c10
-rw-r--r--interface.c9
-rw-r--r--interface.h2
3 files changed, 18 insertions, 3 deletions
diff --git a/interface-event.c b/interface-event.c
index 3cdfbdb..d370cae 100644
--- a/interface-event.c
+++ b/interface-event.c
@@ -30,7 +30,14 @@ static void task_complete(struct uloop_process *proc, int ret);
static struct uloop_process task = {
.cb = task_complete,
};
-static const char * const eventnames[] = {"ifdown", "ifup", "ifupdate", "free", "reload"};
+static const char * const eventnames[] = {
+ [IFEV_DOWN] = "ifdown",
+ [IFEV_UP] = "ifup",
+ [IFEV_UPDATE] = "ifupdate",
+ [IFEV_FREE] = "free",
+ [IFEV_RELOAD] = "reload",
+ [IFEV_LINK_UP] = "iflink",
+};
static void
run_cmd(const char *ifname, const char *device, enum interface_event event,
@@ -178,6 +185,7 @@ static void interface_event_cb(struct interface_user *dep, struct interface *ifa
enum interface_event ev)
{
switch (ev) {
+ case IFEV_LINK_UP:
case IFEV_UP:
case IFEV_UPDATE:
case IFEV_DOWN:
diff --git a/interface.c b/interface.c
index 7b18cef..b9833d3 100644
--- a/interface.c
+++ b/interface.c
@@ -260,6 +260,7 @@ mark_interface_down(struct interface *iface)
if (state == IFS_DOWN)
return;
+ iface->link_up_event = false;
iface->state = IFS_DOWN;
if (state == IFS_UP)
interface_event(iface, IFEV_DOWN);
@@ -355,6 +356,11 @@ interface_set_link_state(struct interface *iface, bool new_state)
netifd_log_message(L_NOTICE, "Interface '%s' has link connectivity %s\n", iface->name, new_state ? "" : "loss");
iface->link_state = new_state;
interface_check_state(iface);
+
+ if (new_state && iface->force_link && iface->state == IFS_UP && !iface->link_up_event) {
+ interface_event(iface, IFEV_LINK_UP);
+ iface->link_up_event = true;
+ }
}
static void
@@ -550,8 +556,7 @@ interface_alias_cb(struct interface_user *dep, struct interface *iface, enum int
case IFEV_FREE:
interface_remove_user(dep);
break;
- case IFEV_RELOAD:
- case IFEV_UPDATE:
+ default:
break;
}
}
diff --git a/interface.h b/interface.h
index 73a3b55..5b89b17 100644
--- a/interface.h
+++ b/interface.h
@@ -26,6 +26,7 @@ enum interface_event {
IFEV_UPDATE,
IFEV_FREE,
IFEV_RELOAD,
+ IFEV_LINK_UP,
};
enum interface_state {
@@ -113,6 +114,7 @@ struct interface {
bool force_link;
bool dynamic;
bool policy_rules_set;
+ bool link_up_event;
time_t start_time;
enum interface_state state;