From patchwork Thu Aug 11 13:53:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 658226 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s98d86qHsz9sdn for ; Thu, 11 Aug 2016 23:54:04 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=M1Ei6uS0; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id D6616B91B74; Thu, 11 Aug 2016 15:53:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP; Thu, 11 Aug 2016 15:53:58 +0200 (CEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 09BFDB91B72 for ; Thu, 11 Aug 2016 15:53:57 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -7 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 11 Aug 2016 15:53:56 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id i138so1535951wmf.3 for ; Thu, 11 Aug 2016 06:53:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=OLHCbbCECyZbIYD58dxvs+ziu1OjKqnsX1gj6QR0MTk=; b=M1Ei6uS0M8Lk0zfwAKUhBwdVctTzxsa9TrMGSPRCTIM3qEczMWM3I08bUsDu9owLqq qA9ccw7Oejtssj8trh+QxAY6sQ9xwn9wFH/YZ1Y9JBt9pyW4YIS21RR/NT6ECKjFSnY7 V4yK9Ic5UdgaBUnk7YAohawLHvt0Ea5eLWH8QVOpHi2gC0hBCPBP0gprHxdltbnpzPDa oyKhuABEvwy6DWq92Qu4M2CnLb9YCx5EISMn1z02aVer1KscE2vGzmxCX5LO736tTmFq vYjvv7PdGKd2yg1fKoQSsswDZQkvSianYNeyIxQCtg414lX4+tyDWw+lr6zUg9X3guJO n4sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OLHCbbCECyZbIYD58dxvs+ziu1OjKqnsX1gj6QR0MTk=; b=L8SnFQidpJnwcVz/Syru7o7a3QZOC7JHNwEq1zJMYxPY9Jm/A7grPX5E5n1AjS+cnc tM0yLnFC5FgtFWjS8fh7w6MxH7NrkI6y7rQrNt2zFQ+w6zWXknGBI/z774qpAP8+MlhS JCqNXsqEtNUj8veG0WZQPXEANGMdFfRahhejHnp0OW0OdD7zE/Hu4GmWmeusJvKf3qP/ rGJPIngyPWMLv0TrnOO4X0UXz20vQaEdhN12uyewPGs67WP7T8iTh3+gpnMRqlq8vBd9 5T4rdBGsPNjw6bSjnr1WlXDVDAgugM8DqS0pcapQI88ZTiHvoqrzrInxbn4z0p/8ST8l dtUA== X-Gm-Message-State: AEkoouveTSU2R9kY78DUORrg5y98B2dzGbpGu4ALDP6b1d5j4TUVocit/4D9w7yeBH5BBA== X-Received: by 10.28.196.14 with SMTP id u14mr8777855wmf.17.1470923636141; Thu, 11 Aug 2016 06:53:56 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id 207sm238901wmb.7.2016.08.11.06.53.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 06:53:55 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org, lede-dev@lists.infradead.org Date: Thu, 11 Aug 2016 15:53:25 +0200 Message-Id: <1470923609-24767-1-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 Subject: [OpenWrt-Devel] [PATCH v2 1/5 netifd] proto-shell: Support teardown on layer 3 link loss X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker , steven@midlink.org MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Commit c6858766 added interface teardown support on layer 3 device link loss mainly for shell protocols who have no proto task like xl2tp. However for shell protocols having a proto task it is not always the correct action to teardown the interface; as an example the PPP daemon can be put into persist state trying to re-establish the link via a hold-off mechanism if layer 3 link loss is detected. Therefore shell handlers can enable via TEARDOWN_ON_L3_LINK_DOWN a proto flag which will teardown the interface when layer 3 link loss is detected Signed-off-by: Hans Dedecker --- Changes in v2: -Define seperate proto flag to enable teardown on layer3 link loss interface.c | 3 ++- proto-shell.c | 4 ++++ proto.h | 1 + scripts/netifd-proto.sh | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/interface.c b/interface.c index b9833d3..0b9893c 100644 --- a/interface.c +++ b/interface.c @@ -414,7 +414,8 @@ interface_l3_dev_cb(struct device_user *dep, enum device_event ev) switch (ev) { case DEV_EVENT_LINK_DOWN: - interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false); + if (iface->proto_handler->flags & PROTO_FLAG_TEARDOWN_ON_L3_LINK_DOWN) + interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false); break; default: break; diff --git a/proto-shell.c b/proto-shell.c index 25dec00..4391cdd 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -906,6 +906,10 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj) if (tmp && json_object_get_boolean(tmp)) handler->proto.flags |= PROTO_FLAG_LASTERROR; + tmp = json_get_field(obj, "teardown-on-l3-link-down", json_type_boolean); + if (tmp && json_object_get_boolean(tmp)) + handler->proto.flags |= PROTO_FLAG_TEARDOWN_ON_L3_LINK_DOWN; + config = json_get_field(obj, "config", json_type_array); if (config) handler->config_buf = netifd_handler_parse_config(&handler->config, config); diff --git a/proto.h b/proto.h index 87dec4e..8f50fdc 100644 --- a/proto.h +++ b/proto.h @@ -38,6 +38,7 @@ enum { PROTO_FLAG_RENEW_AVAILABLE = (1 << 3), PROTO_FLAG_FORCE_LINK_DEFAULT = (1 << 4), PROTO_FLAG_LASTERROR = (1 << 5), + PROTO_FLAG_TEARDOWN_ON_L3_LINK_DOWN = (1 << 6), }; struct interface_proto_state { diff --git a/scripts/netifd-proto.sh b/scripts/netifd-proto.sh index 447f0f6..64b3cab 100644 --- a/scripts/netifd-proto.sh +++ b/scripts/netifd-proto.sh @@ -365,6 +365,7 @@ init_proto() { no_proto_task=0 available=0 renew_handler=0 + teardown_on_l3_link_down=0 add_default_handler "proto_$1_init_config" @@ -378,6 +379,7 @@ init_proto() { json_add_boolean available "$available" json_add_boolean renew-handler "$renew_handler" json_add_boolean lasterror "$lasterror" + json_add_boolean teardown-on-l3-link-down "$teardown_on_l3_link_down" json_dump } ;;