From patchwork Wed Apr 8 14:20:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 459289 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.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6E4E914011D for ; Thu, 9 Apr 2015 00:21:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=DleiKdNg; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id EE27428C68B; Wed, 8 Apr 2015 16:19:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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 version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 407B528BDD5 for ; Wed, 8 Apr 2015 16:19:51 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 8 Apr 2015 16:19:48 +0200 (CEST) Received: by wizk4 with SMTP id k4so56970865wiz.1 for ; Wed, 08 Apr 2015 07:20:35 -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=VtnZxINaT4l7Y807ZruYq5ZfDYdhU3/Mmf+AIP0lrwk=; b=DleiKdNg7ouiRpcXxT7I/OXiOuPUvcvN9jy0DE46tsj2TyuIfaJ9AyZd9tnkfFB27C 6uLDe51wS9Cygv49UxkcN3F6cCcoMcglwGt5ZzJmjYDq2fA8JqgRmkQpQ950o8pUv+f2 mRffDk0TjpCLDJmsr0hyeXE4hQzjkDsN0w0Xx9KzCne68liBMm6kqu8T7LTafBv8WhsT ekLvToWtc1LIuX47Sk0WzhJ+WcpazZpfXaqJpMJ2GZ+PwaQCg7IZY3ZQzbgz+4dAcKy/ SO7EZ59bgxL/vh9E94d6r64iLvtBgXoVYpJHsSkR7u7d6QlVMQ1AXabmVQv828LXsv06 g8uQ== X-Received: by 10.194.19.197 with SMTP id h5mr49726889wje.109.1428502835089; Wed, 08 Apr 2015 07:20:35 -0700 (PDT) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by mx.google.com with ESMTPSA id ff4sm15903097wib.9.2015.04.08.07.20.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Apr 2015 07:20:34 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Wed, 8 Apr 2015 16:20:21 +0200 Message-Id: <1428502822-23703-1-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: Johan Peeters , Hans Dedecker , cyrus@openwrt.org Subject: [OpenWrt-Devel] [PATCH] ppp: Detailed last error support X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Enables last error support for the PPP protocol handlers. In generic teardown the PPP daemon exit code is translated into a self explaining error string which is set as interface error by proto_notify_error in case of failure. Signed-off-by: Johan Peeters Signed-off-by: Hans Dedecker --- package/network/services/ppp/files/ppp.sh | 51 ++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/package/network/services/ppp/files/ppp.sh b/package/network/services/ppp/files/ppp.sh index b4a7467..99fdc87 100755 --- a/package/network/services/ppp/files/ppp.sh +++ b/package/network/services/ppp/files/ppp.sh @@ -8,6 +8,38 @@ init_proto "$@" } +ppp_exitcode_tostring() +{ + local errorcode=$1 + [ -n "$errorcode" ] || errorcode=5 + + case "$errorcode" in + 0) echo "OK" ;; + 1) echo "FATAL_ERROR" ;; + 2) echo "OPTION_ERROR" ;; + 3) echo "NOT_ROOT" ;; + 4) echo "NO_KERNEL_SUPPORT" ;; + 5) echo "USER_REQUEST" ;; + 6) echo "LOCK_FAILED" ;; + 7) echo "OPEN_FAILED" ;; + 8) echo "CONNECT_FAILED" ;; + 9) echo "PTYCMD_FAILED" ;; + 10) echo "NEGOTIATION_FAILED" ;; + 11) echo "PEER_AUTH_FAILED" ;; + 12) echo "IDLE_TIMEOUT" ;; + 13) echo "CONNECT_TIME" ;; + 14) echo "CALLBACK" ;; + 15) echo "PEER_DEAD" ;; + 16) echo "HANGUP" ;; + 17) echo "LOOPBACK" ;; + 18) echo "INIT_FAILED" ;; + 19) echo "AUTH_TOPEER_FAILED" ;; + 20) echo "TRAFFIC_LIMIT" ;; + 21) echo "CNID_AUTH_FAILED";; + *) echo "UNKNOWN_ERROR" ;; + esac +} + ppp_generic_init_config() { proto_config_add_string username proto_config_add_string password @@ -72,20 +104,27 @@ ppp_generic_setup() { ppp_generic_teardown() { local interface="$1" + local errorstring=$(ppp_exitcode_tostring $ERROR) case "$ERROR" in + 0) + ;; + 2) + proto_notify_error "$interface" "$errorstring" + proto_block_restart "$interface" + ;; 11|19) - proto_notify_error "$interface" AUTH_FAILED json_get_var authfail authfail + proto_notify_error "$interface" "$errorstring" if [ "${authfail:-0}" -gt 0 ]; then proto_block_restart "$interface" fi ;; - 2) - proto_notify_error "$interface" INVALID_OPTIONS - proto_block_restart "$interface" + *) + proto_notify_error "$interface" "$errorstring" ;; esac + proto_kill_command "$interface" } @@ -96,6 +135,7 @@ proto_ppp_init_config() { ppp_generic_init_config no_device=1 available=1 + lasterror=1 } proto_ppp_setup() { @@ -114,6 +154,7 @@ proto_pppoe_init_config() { proto_config_add_string "ac" proto_config_add_string "service" proto_config_add_string "host_uniq" + lasterror=1 } proto_pppoe_setup() { @@ -151,6 +192,7 @@ proto_pppoa_init_config() { proto_config_add_string "encaps" no_device=1 available=1 + lasterror=1 } proto_pppoa_setup() { @@ -184,6 +226,7 @@ proto_pptp_init_config() { proto_config_add_string "interface" available=1 no_device=1 + lasterror=1 } proto_pptp_setup() {