interface: add new "ifup-failed" hotplug event
authorMartin Schiller <ms@dev.tdt.de>
Fri, 31 Mar 2017 06:31:39 +0000 (08:31 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 May 2017 10:53:50 +0000 (12:53 +0200)
This hook makes it possible to do some helper work in hotplug scripts
when a connection is not established successfully.

example: try several username/passwords from a pool to establish a
pppoe or wwan connection by replacing the configured values of the
connection in a hotplug script.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
interface-event.c
interface.c
interface.h

index 4976c2cf032d6b3bc25069f03398aefd454f3d50..86e8f5488da8626d54a61a9efee24e0366b10433 100644 (file)
@@ -33,6 +33,7 @@ static struct uloop_process task = {
 static const char * const eventnames[] = {
        [IFEV_DOWN] = "ifdown",
        [IFEV_UP] = "ifup",
+       [IFEV_UP_FAILED] = "ifup-failed",
        [IFEV_UPDATE] = "ifupdate",
        [IFEV_FREE] = "free",
        [IFEV_RELOAD] = "reload",
@@ -191,6 +192,7 @@ static void interface_event_cb(struct interface_user *dep, struct interface *ifa
        switch (ev) {
                case IFEV_LINK_UP:
                case IFEV_UP:
+               case IFEV_UP_FAILED:
                case IFEV_UPDATE:
                case IFEV_DOWN:
                        interface_queue_event(iface, ev);
index 593b0490c85d8cc30dd338979aaea6b560e50866..900a523dc4252280277ca1cf559b9111929e219b 100644 (file)
@@ -241,6 +241,7 @@ interface_event(struct interface *iface, enum interface_event ev)
                adev = iface->l3_dev.dev;
                /* fall through */
        case IFEV_DOWN:
+       case IFEV_UP_FAILED:
                alias_notify_device(iface->name, adev);
                break;
        default:
@@ -268,6 +269,8 @@ mark_interface_down(struct interface *iface)
        iface->state = IFS_DOWN;
        if (state == IFS_UP)
                interface_event(iface, IFEV_DOWN);
+       else
+               interface_event(iface, IFEV_UP_FAILED);
        interface_ip_set_enabled(&iface->config_ip, false);
        interface_ip_set_enabled(&iface->proto_ip, false);
        interface_ip_flush(&iface->proto_ip);
@@ -557,6 +560,7 @@ interface_alias_cb(struct interface_user *dep, struct interface *iface, enum int
                interface_set_available(alias, true);
                break;
        case IFEV_DOWN:
+       case IFEV_UP_FAILED:
                interface_set_available(alias, false);
                interface_set_main_dev(alias, NULL);
                break;
index d35fd98a971630d94f231f0364e90d6f617c502b..0e58f69c26e0c31c62cf1b0262d664d771873db8 100644 (file)
@@ -23,6 +23,7 @@ struct interface_proto_state;
 enum interface_event {
        IFEV_DOWN,
        IFEV_UP,
+       IFEV_UP_FAILED,
        IFEV_UPDATE,
        IFEV_FREE,
        IFEV_RELOAD,