From patchwork Tue Nov 7 14:11:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13448882 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC09A30F88 for ; Tue, 7 Nov 2023 14:11:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d6Bb/fdN" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-77774120c6eso361748985a.2 for ; Tue, 07 Nov 2023 06:11:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699366304; x=1699971104; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xlgQMJEMGYSVnfmuhVEVa9nQtXnHsubVQpyrEa3fWQU=; b=d6Bb/fdNkx+VWNdff9c8toaQg/u1aRkq67Nf6qOSXqGahetoAVQRUeUOOSNsaQBIwn GSc7/7Tl/c5LZ/6zRmAbIdOTeMQs1nHWHpZX4zPI9HtBD/LbBH+f1M0EACA6CJw9fwxt UBC2P/V4bF+tDC1p9AaRvN2h5KUYzszaxeJ6Jq9PMWpWmYP77TiyxVVUJrJTm3skRpSO VDqVojtEAwRhO5FKxfjAlKQ4DGlio7ZOMTyqc3uczK9wDBKStn6BceaLERNZxBgzEJt/ ULtmU63uUO+b0R0RxdzpE+iJdLWxKJ+5FeTnJXCmB46NkeyER1B7gx15dmch80DQ7CJO VmqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699366304; x=1699971104; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xlgQMJEMGYSVnfmuhVEVa9nQtXnHsubVQpyrEa3fWQU=; b=kxRFlARNrILYJ21AHCNHPR+/YBrFPy8lCEbR9hqJ9q+RdVBB8uRbmzcTqz3c0ZMJ7a tPcgZUdstrEN7XPTih1iyFTmwS2M7NJRAShMOXNpSkba6KsnyE0VdiDlDdXApfxNh9wO xV4bq5PNiPK238/MyR2TS396j8pTCspmdGmjodaGHxvCU6TwBLAHS1+7+tCIvkw/NbTV iEslxYZ7ehvk3FX42GkJUeJGF+v8RG4FTMjvwRE6587h73hs7fN3R3/jXHmF4V9vLWwV K7yEreMsvN7JAhPgNWXhnNdBS9DT/txrh/pErvDHiOlRqbDsKcxyxSZ+o4fEdrA2lPUd yz+w== X-Gm-Message-State: AOJu0YySokATq5AlqwnuGxKIiPLChTmIE7CHY9ZGeGEi0mIPEKeSNLvf +TNqqnogYdOZ6SnAqu0bkjpGrzvIzY4= X-Google-Smtp-Source: AGHT+IF1chdUAXpFFGsNk3EjFHCXPZ34CB1pJv7PzlMRQUrnTYOo0jM2cAnCVP7wjLQkY1Um4MjFdQ== X-Received: by 2002:a05:620a:28c5:b0:774:30b7:ed93 with SMTP id l5-20020a05620a28c500b0077430b7ed93mr39173188qkp.29.1699366304590; Tue, 07 Nov 2023 06:11:44 -0800 (PST) Received: from LOCLAP699.rst-02.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id b7-20020a05620a04e700b00765aa3ffa07sm4204890qkh.98.2023.11.07.06.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 06:11:44 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/2] station: start roam on beacon loss event Date: Tue, 7 Nov 2023 06:11:39 -0800 Message-Id: <20231107141140.1706441-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Beacon loss handling was removed in the past because it was determined that this even always resulted in a disconnect. This was short sighted and not always true. The default kernel behavior waits for 7 lost beacons before emitting this event, then sends either a few nullfuncs or probe requests to the BSS to determine if its really gone. If these come back successfully the connection will remain alive. This can give IWD some time to roam in some cases so we should be handling this event. Since beacon loss indicates a very poor connection the roam scan is delayed by a few seconds in order to give the kernel a chance to send the nullfuncs/probes or receive more beacons. This may result in a disconnect, but it would have happened anyways. Attempting a roam mainly handles the case when the connection can be maintained after beacon loss, but is still poor. --- src/netdev.h | 1 + src/station.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) v2: * Delay the roam to give the kernel a chance to salvage the connection FYI, I did attempt to add back the beacon loss test without much luck. Blocking beacons with hwsim did not result in a beacon loss event which may have been one of the reasons it was removed in the first place. Even blocking _all_ frames doesn't result in an event but instead just a local disconnect. After looking more into it I see that actually only a few drivers even use ieee80211_beacon_loss/ieee80211_connection_loss: iwlwifi,wl1251,intersil,mt76,wfx,ath10/11k,wcn36xx Every other driver likely disconnects rather than attempts to handle beacon loss. So probably for the majority of users this actually didn't matter, but for these drivers it does make sense to handle the event. diff --git a/src/netdev.h b/src/netdev.h index 73d38c32..f27130f1 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -51,6 +51,7 @@ enum netdev_event { NETDEV_EVENT_RSSI_LEVEL_NOTIFY, NETDEV_EVENT_PACKET_LOSS_NOTIFY, NETDEV_EVENT_FT_ROAMED, + NETDEV_EVENT_BEACON_LOSS_NOTIFY, }; enum netdev_watch_event { diff --git a/src/station.c b/src/station.c index 5a202ebd..c3f26b5a 100644 --- a/src/station.c +++ b/src/station.c @@ -3370,6 +3370,21 @@ static void station_packets_lost(struct station *station, uint32_t num_pkts) station_start_roam(station); } +static void station_beacon_lost(struct station *station) +{ + l_debug("Beacon lost event"); + + if (station_cannot_roam(station)) + return; + + station_debug_event(station, "beacon-loss-roam"); + + if (station->roam_trigger_timeout) + return; + + station_roam_timeout_rearm(station, LOSS_ROAM_RATE_LIMIT); +} + static void station_netdev_event(struct netdev *netdev, enum netdev_event event, void *event_data, void *user_data) { @@ -3414,6 +3429,9 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event, station_roamed(station); break; + case NETDEV_EVENT_BEACON_LOSS_NOTIFY: + station_beacon_lost(station); + break; } } From patchwork Tue Nov 7 14:11:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13448883 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 432CA30F8F for ; Tue, 7 Nov 2023 14:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FOtsqnxi" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7789cc5c8ccso465856085a.0 for ; Tue, 07 Nov 2023 06:11:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699366306; x=1699971106; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9u+hty29+P7c9zIKJAJcDefyW9mA99xF7TP5MMp1a9A=; b=FOtsqnxiIiAsTVRKEJb49By70Wi8wL1cTsP1/GJ7Qqk579s+L/YDekSQ2sWwR1wLlM nw6GgLOVureSTqtbkz9ssEICh3W7W4wmuSMPbYEWUcYaLQMOQA2ZaSjJyy92B4OVHUgA ClEqjiPBpjKVR075ptAPehAUGETe15TxBFKlvJ2Q0z0Oi0AtXLkY4N7XtyN/GB81qTDz i0Zo5GAR7OmkBztvpB+0FV7asbaBLS8aVZ1aQuBH4DKcr4Ro7OZwLyhxu5JixnCAHVip 9XW4e7GLpePgjvwEpgq2X83SyO+JaXc0ESr+sTuPWvn8c7geHegE+jced5cyzabTu6G8 9tdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699366306; x=1699971106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9u+hty29+P7c9zIKJAJcDefyW9mA99xF7TP5MMp1a9A=; b=PuGzragwP+r1i2nAuxSW4q0IVPtm7C04hACtgB1+LxlxcJTsM6enPjkZ8btWNqabD2 av4YOx3JBhkkW5QuF/NNsQ4a17DV1HHUq1udfT0qPo3X5KE4XOIyaIk5P0pY19rRc3Mb X4OQpBM0ft3aN9VpG0NZG56HtexBvowl8GVgfunSFkw/SxF6t50uZtFAtZfJ6woUP5Pi SeNFU1tPi1alDMj5yNWvzXnXFvjyGSuMmPuW/k1BABd9X2p2knnyScEafJLJj/BioRkT crQQMY34yC99dkNlaKVwop1pjJvksGh76jQttHcbPugD7g0m8tStscwEZOAXpgfxXvzk vdwA== X-Gm-Message-State: AOJu0YxQVNWLlty55aSB6jgqParmfFtyCkoeVJU09L577Fm3gW7hIvzz dqsadn8K10eEMLrY6RqumLhgoxSn1sg= X-Google-Smtp-Source: AGHT+IG8KkpIPnPmrjHmygdVBpiHELeQBWRB7LiHVFVUhrwRI+pTrwjZJc/BtAZiVC6Ssd4FLvsmvQ== X-Received: by 2002:a05:620a:46a2:b0:774:220c:1547 with SMTP id bq34-20020a05620a46a200b00774220c1547mr3787060qkb.34.1699366305753; Tue, 07 Nov 2023 06:11:45 -0800 (PST) Received: from LOCLAP699.rst-02.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id b7-20020a05620a04e700b00765aa3ffa07sm4204890qkh.98.2023.11.07.06.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 06:11:45 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/2] netdev: handle/send beacon loss event Date: Tue, 7 Nov 2023 06:11:40 -0800 Message-Id: <20231107141140.1706441-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231107141140.1706441-1-prestwoj@gmail.com> References: <20231107141140.1706441-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/netdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/netdev.c b/src/netdev.c index 56c6ebd2..86712658 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1054,6 +1054,7 @@ static void netdev_cqm_event(struct l_genl_msg *msg, struct netdev *netdev) uint32_t *rssi_event = NULL; int32_t *rssi_val = NULL; uint32_t *pkt_event = NULL; + bool beacon_loss = false; if (!l_genl_attr_init(&attr, msg)) return; @@ -1081,7 +1082,7 @@ static void netdev_cqm_event(struct l_genl_msg *msg, struct netdev *netdev) break; case NL80211_ATTR_CQM_BEACON_LOSS_EVENT: - l_debug("Beacon lost event"); + beacon_loss = true; break; case NL80211_ATTR_CQM_RSSI_LEVEL: @@ -1111,6 +1112,9 @@ static void netdev_cqm_event(struct l_genl_msg *msg, struct netdev *netdev) } else if (pkt_event && netdev->event_filter) netdev->event_filter(netdev, NETDEV_EVENT_PACKET_LOSS_NOTIFY, pkt_event, netdev->user_data); + else if (beacon_loss && netdev->event_filter) + netdev->event_filter(netdev, NETDEV_EVENT_BEACON_LOSS_NOTIFY, + NULL, netdev->user_data); } static void netdev_rekey_offload_event(struct l_genl_msg *msg,