From patchwork Mon Aug 21 09:34:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via arch-projects X-Patchwork-Id: 230 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org with LMTP id WGFXNUWqmlnnfQAAtiB/HQ for ; Mon, 21 Aug 2017 11:39:17 +0200 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 9378440130; Mon, 21 Aug 2017 11:39:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.5 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Mon, 21 Aug 2017 11:39:16 +0200 (CEST) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 156432BF16; Mon, 21 Aug 2017 09:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=luna2; t=1503308356; bh=mkH7J3E7L50r1YdGvy6vgjAucJETcW6+COINmUFN/n8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc; b=YFjzd7DT8lkqe7ZLHVOKocM1sicMiLkBgRVDj1Ggorygi8+7fk2qeDKwNeaUhAO0Y mEP0y6AjZEaXaxEh3AtOF/ACgRhPmX9jvt/m0r58v6BK77D5g5gO+D0PU5//iaoY0i eUgK9V6b+vpeW33LDa8NO9QivtwIZ9uYLVoIVmxgxIRBr4rZ6Um0TJmUTHJmttd2Cd EKhOLe3G/A6bV+smv5ipJUzAKFJ4eL46ERRp0HekckZc+LyBWA2nKFgpzuiys0OJVP bno0jX5x23DQnwvSS6rvL+KhFmbm3qn2ds/JTkK+aswA0bVFahA3TzL/DzMOkDRIbr jpzFJYwYJAaUZxx3UZogYpnWvvh8MvMVCw6PZvVqHVG3oSwDGhx5CJq3FXLZRbdPD+ 4Sa1MPI4bm3eVNI1tSR1ErIKjUr2F6S15na95C7B/sKGqSFv3hKbJIKm+z4VKIPtHo tfuV1MfO0r87AJ6z676GS/1NjqOXouiJZq8DDgDVk09WP62FP5/6+ja+QjFqaWK25c P8p6Z7Z+SpXqBVjdWwOHyiy6/ufzFB/SoXeUZyAhHgmMyZT8uYTWrsO+gKYXsUgnYk +yhyHnWpB41aKrmrzCH3ZBCY1D50vRZ8Ce1k+WBYUKK+l000VySAn5EhXXRA6U6hwu rd0N112Nu+WED/LF2Uw3NGug= Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id BE64927F05 for ; Mon, 21 Aug 2017 09:39:14 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [IPv6:2a00:1828:2000:547::2]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 21 Aug 2017 09:39:14 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 73F7640130 for ; Mon, 21 Aug 2017 11:39:12 +0200 (CEST) Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS for ; Mon, 21 Aug 2017 11:39:12 +0200 (CEST) Received: by mail-wr0-x244.google.com with SMTP id f8so11565135wrf.3 for ; Mon, 21 Aug 2017 02:39:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GVVNNlX8uxkCVracD2pwg9bxDt2/HOB8qpo7icYjYZ4=; b=UGeYHK/5JS081EVtxyWPgXwbimnRDVZkhr3O+UXoK+cOvIebGZ8MnjUy+a/6Lzj7YC 0EfJ0DMK47x8baWRjtuv7n47QjqZziDQiv6K22oqMYneYMdYnzXji+0eIAKPzUa6yHB4 9010bxBmjLlvcPb+lyrjPg7HTwo2WCnOlh0t4iNvqp5/9fF2tbxBBPtZzFHZVwW5i4bx SIs18I8h60/y0bb9R5RG5NgYuv0bug2pvPlh6z937dDlpEKV6FESlJD6mF2ndf46YrdY /5wCiQ0+C1yNxYjlN2R9aWTDqgfhLKAyQxFL/nE/vwHgkooNXwiiJiREA2XblqB8kfDn +kZg== X-Gm-Message-State: AHYfb5hdILKWO5vJcx73Tghe0YuC0c19xtMNxTyC+ChBNvJaMG4x0A5D YRj6l0sZPok6FIWQ X-Received: by 10.28.4.148 with SMTP id 142mr4842437wme.145.1503308350795; Mon, 21 Aug 2017 02:39:10 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:fef1:58b9:efa6:c3aa]) by smtp.gmail.com with ESMTPSA id v22sm11373374wra.70.2017.08.21.02.39.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 02:39:09 -0700 (PDT) To: arch-projects@archlinux.org Date: Mon, 21 Aug 2017 10:34:20 +0100 Message-Id: <20170821093420.26303-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.14.0 Subject: [arch-projects] [projects][PATCH] wpa_actiond: Wait for three "failed" PONGs before disconnecting X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Emil Velikov via arch-projects Reply-To: Arch Linux projects development discussion Cc: Emil Velikov Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 554 Status: X-Keywords: Content-Length: 3084 When the system is very low on resources, select() may return 0 even when wpa_supplicant is alive and kicking. Don't disconnect as soon at that occurs - wait three times and clearly log it. Signed-off-by: Emil Velikov --- Hi all, Using [projects] since [wpa_actiond] gets kicked by the email filter. Can anyone update the message to include a list of supported tags, or link to an article/wiki with information? Back on topic: This is a small patch I had for 2 months and I thought about getting upstreamed. In particular - on certain workloads my system can get really low on memory (and available fds). With the patch in place, wpa_actiond no longer kills my connection although in practise I never seen two consecutive "wpa_supplicant failed to reply (PONG)" messages. My patch could be completely bonkers, so any suggestions how to address this correctly will be appreciated. --- wpa_actiond.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wpa_actiond.c b/wpa_actiond.c index d60d885..03a9d7f 100644 --- a/wpa_actiond.c +++ b/wpa_actiond.c @@ -292,6 +292,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t /* path to control socket */ char *ctrlsock = NULL; int ctrlsocklen; + int pong_failures = 0; ssid[0] = '\0'; old_ssid[0] = '\0'; @@ -359,6 +360,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t } logevent(WPA_ACTIOND_LOG_TERMINATE, iface, ""); state = WPA_ACTIOND_STATE_TERMINATED; + pong_failures = 0; break; case 0: if (state == WPA_ACTIOND_STATE_CONNECTION_LOST) { @@ -372,8 +374,15 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t reply_len = 0; reply[reply_len] = '\0'; if(!str_match(reply, "PONG")) { + if (pong_failures <= 3) { + logevent(WPA_ACTIOND_LOG_CUSTOM_ERROR, iface, "wpa_supplicant failed to reply (PONG)"); + pong_failures++; + break; + } + /* supplicant has been terminated */ if(state == WPA_ACTIOND_STATE_CONNECTED || state == WPA_ACTIOND_STATE_CONNECTION_LOST) { + logevent(WPA_ACTIOND_LOG_CUSTOM_ERROR, iface, "wpa_supplicant failed to reply three times in a row - disconnecting"); logevent(WPA_ACTIOND_LOG_DISCONNECTED, iface, ssid); action(WPA_ACTIOND_ACTION_DISCONNECT, iface, ssid, idstr, wpa_ctrl_get_fd(ctrl), script); } @@ -381,6 +390,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t state = WPA_ACTIOND_STATE_TERMINATED; } } + pong_failures = 0; break; default: /* event received */ @@ -446,6 +456,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t /* we are not interested in this event */ break; } + pong_failures = 0; } }