From patchwork Fri Mar 31 06:31:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Schiller X-Patchwork-Id: 745510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vvWrY4Fkzz9ryZ for ; Fri, 31 Mar 2017 17:32:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mOvJ/7Id"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=u43X5Vf3UzwP88eBRCEKtYYUlhSm8E1zc48QkBj+cTc=; b=mOvJ/7Id2qRDsV PJ7DMCksDnPRTANYW6s+tqWPuiVS0rIXYiheag5+Gk3+9aUOyhxQ2VgTw7GLfNLiiZ7Lj66Z7vyK2 i0BaYqgRTl2ObXBio9/X8Zi3kG6ann/5swcLjfrLwsF1ughFyjQdeWv1ds/EE46G1jTs7HuIizITi uRSrC55V4jVjcSdaDDOcWElCVcQTFVRUkWbtBKGWm8HZb2wVy6y29+xLAAsE2DC88r3iMJFSDDnPV PUrv2jL5OvC2H3NqOlYEhO8qc+lXqsPphOSseRAx623Xajj2eBgyxdSMNr47QhtKUs9NeRN1H2gnS QPsQJ6VwbgjNXXdiXEXg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ctq6b-0003xQ-Cz; Fri, 31 Mar 2017 06:32:17 +0000 Received: from ms.tdt.de ([195.243.126.94] helo=mail.dev.tdt.de) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ctq6X-0003vG-MS for lede-dev@lists.infradead.org; Fri, 31 Mar 2017 06:32:15 +0000 Received: from mschiller01.tdtnet.local (unknown [10.1.3.20]) by mail.dev.tdt.de (Postfix) with ESMTPSA id D63332035C; Fri, 31 Mar 2017 06:31:48 +0000 (UTC) From: Martin Schiller To: lede-dev@lists.infradead.org Date: Fri, 31 Mar 2017 08:31:39 +0200 Message-Id: <1490941899-2841-1-git-send-email-ms@dev.tdt.de> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.dev.tdt.de X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170330_233213_917123_2E83F6A6 X-CRM114-Status: GOOD ( 10.36 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH netifd] interface: add new "ifup-failed" hotplug event X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Schiller , nbd@nbd.name MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 --- interface-event.c | 2 ++ interface.c | 4 ++++ interface.h | 1 + 3 files changed, 7 insertions(+) diff --git a/interface-event.c b/interface-event.c index 4976c2c..86e8f54 100644 --- a/interface-event.c +++ b/interface-event.c @@ -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); diff --git a/interface.c b/interface.c index f150f7d..e04d477 100644 --- a/interface.c +++ b/interface.c @@ -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; diff --git a/interface.h b/interface.h index 1472324..c51705c 100644 --- a/interface.h +++ b/interface.h @@ -23,6 +23,7 @@ struct interface_proto_state; enum interface_event { IFEV_DOWN, IFEV_UP, + IFEV_UP_FAILED, IFEV_UPDATE, IFEV_FREE, IFEV_RELOAD,