From patchwork Mon Oct 30 13:48:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13440614 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 2B970171B9 for ; Mon, 30 Oct 2023 13:48: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="loIi11Uq" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6c7b3adbeb6so2980620a34.0 for ; Mon, 30 Oct 2023 06:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698673725; x=1699278525; 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=1PtMk8Gt+1gFjjXdMBkctyeZWlT2Y9aLB9DRk7MjRaQ=; b=loIi11UqhdFGD6KdoWmLkh6Y7aODWbrEzNsc74ETyWXRRnay7Yj/bg95BDhtl6jQwB ty8RQE6nkcG+HFj547FivNCdpL+7Pru69s28iFWAklruVaYQtoiTST3ez1PxZ2qDVIWt lF1Ip3TZXdIZN4P3PHhJ3A2pteyu1mCYjdui25qLMKpGO0d+PO6wTXiDz5d4ZWMsrhOQ Iy7JDKyY3DwV8U2vXTCbujWRfYDGpRjHIfNd+u0dUpOaIf68y0dQE2qGmyCFWuvcgdXi FmBGOm6DrQzntgR4JLu3lPgOwgeqRP7IbHcjl/NQKq4/t4p2eZgwGOkYpE8fVihurVIT hwlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698673725; x=1699278525; 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=1PtMk8Gt+1gFjjXdMBkctyeZWlT2Y9aLB9DRk7MjRaQ=; b=OtKlc1I3yrYm97qSzWD8Ce5LvE/M9Nv69ZJUZv3JX+dhgHO4c4deayyBTLSGXlBaRl 2WO3V0tcjrezVCsK9o6qwbzbRPlXkl9uaC0aUQ6QXu4/rLx7DHpiGBmA56gn0JbUa7RB e4ZwxBbEnZPpK0KXkNXS/M6EFGJcZhf62ExcaNvEWysouotPfGJ4CB0b6bl232XIszFO P8GkM/Atv5rStQRE+NNPQwsSXKnr0VMfWSo4Hxg/Zx2c5DVKMzvNSM4dd1XSk0+rX1sN db6i+Lejzv/N3duhX5kFlxhORZID2D4C3g1ZyUz5uSuF/IDqvh+CTVELsp0WVgqlRq50 0uDg== X-Gm-Message-State: AOJu0Yw2ZgbNsfEXuD7R5LAPDJMEVLRp0AAs/Ry4he6Ac1lcnM9wJJKC TYbam6nVeeome9FhxCYlI/ZRI/X3aHI= X-Google-Smtp-Source: AGHT+IH425DyKC7MxT6N6Klvf1nt8bx8F20ycTGWiE/I+L2FUsIhIkTRXds6QKYwrGzG9dzhZpSM9w== X-Received: by 2002:a05:6830:90a:b0:6c4:ae52:9599 with SMTP id v10-20020a056830090a00b006c4ae529599mr11258044ott.7.1698673725072; Mon, 30 Oct 2023 06:48:45 -0700 (PDT) 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 c18-20020ac86612000000b004181aa90b46sm3419929qtp.89.2023.10.30.06.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:48:44 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/4] station: rename ap_directed_roam to force_roam Date: Mon, 30 Oct 2023 06:48:34 -0700 Message-Id: <20231030134837.452957-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231030134837.452957-1-prestwoj@gmail.com> References: <20231030134837.452957-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This will be used for other situations where a roam is forced rather than based on ranking. --- src/station.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/station.c b/src/station.c index 1a886b19..a2358d95 100644 --- a/src/station.c +++ b/src/station.c @@ -126,7 +126,7 @@ struct station { bool preparing_roam : 1; bool roam_scan_full : 1; bool signal_low : 1; - bool ap_directed_roaming : 1; + bool force_roam : 1; bool scanning : 1; bool autoconnect : 1; bool autoconnect_can_start : 1; @@ -2114,7 +2114,7 @@ static void station_roam_retry(struct station *station) */ station->preparing_roam = false; station->roam_scan_full = false; - station->ap_directed_roaming = false; + station->force_roam = false; if (station->signal_low) station_roam_timeout_rearm(station, roam_retry_interval); @@ -2145,7 +2145,7 @@ static void station_roam_failed(struct station *station) * We were told by the AP to roam, but failed. Try ourselves or * wait for the AP to tell us to roam again */ - if (station->ap_directed_roaming) + if (station->force_roam) goto delayed_retry; /* @@ -2425,7 +2425,7 @@ static bool station_try_next_transition(struct station *station, util_address_to_string(bss->addr)); /* Reset AP roam flag, at this point the roaming behaves the same */ - station->ap_directed_roaming = false; + station->force_roam = false; /* Can we use Fast Transition? */ if (station_can_fast_transition(hs, bss) && !no_ft) @@ -2583,7 +2583,7 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list, * to occur. */ bss = l_queue_find(bss_list, bss_match_bssid, current_bss->addr); - if (bss && !station->ap_directed_roaming) { + if (bss && !station->force_roam) { cur_bss_rank = bss->rank; if (hs->mde && bss->mde_present && l_get_le16(bss->mde) == mdid) @@ -2961,18 +2961,18 @@ static void station_ap_directed_roam(struct station *station, MAC_STR(hdr->address_3)); /* - * The ap_directed_roaming flag forces IWD to roam if there are any + * The force_roam flag forces IWD to roam if there are any * candidates, even if they are worse than the current BSS. This isn't * always a good idea since we may be associated to the best BSS. Where * this does matter is if the AP indicates its going down or will be * disassociating us. If either of these bits are set, set the - * ap_directed_roaming flag. Otherwise still try roaming but don't + * force_roam flag. Otherwise still try roaming but don't * treat it any different than a normal roam. */ if (req_mode & (WNM_REQUEST_MODE_DISASSOCIATION_IMMINENT | WNM_REQUEST_MODE_TERMINATION_IMMINENT | WNM_REQUEST_MODE_ESS_DISASSOCIATION_IMMINENT)) - station->ap_directed_roaming = true; + station->force_roam = true; if (req_mode & WNM_REQUEST_MODE_TERMINATION_IMMINENT) { if (pos + 12 > body_len) From patchwork Mon Oct 30 13:48:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13440615 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 B5C06F9E6 for ; Mon, 30 Oct 2023 13:48: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="ejbHbgAf" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-41cd8bd5727so30328701cf.3 for ; Mon, 30 Oct 2023 06:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698673726; x=1699278526; 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=zvBixF0OuY0BLthWm479TL27u1v2r+Vng/YDZCMRjtw=; b=ejbHbgAffsZDzodM9TcYMP8ufsQaY3W2ohYirbJbldrIluAlVosSBL+0wdnJG8GnfA H5tu7jKd/hvG9pjVdYMqMkWkewN0s3w/sgI+d/lKnkkqJ7Y93L8rFheZqAJl08i1Z2nT ce+V96rfUXjG6lXSwFaX1lqa5Et2vy8mbwbS8KeTxnlvhY8Cw1cgJYO6JbmpUp1bVYM0 m5PsFl6tb4gQEVCl/rZclGD/WjaeYVbsxNN+0E9jQohGR26wyjF7fXUWoJoAG56tUPOo 8tDVGEfloZNHiND8lCKveCz5t8mib37sowwdBPm3OdiUyso0L/ybb50ED0h3AhVg5gPy OIMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698673726; x=1699278526; 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=zvBixF0OuY0BLthWm479TL27u1v2r+Vng/YDZCMRjtw=; b=kKpQyI1Q9e1L/UQUV38ZxKKaE2AOBUXNl8XKFeXfI6W8/CXRmurKYOI0hLDiN8NXIV WnBG3jN+EG6dsFHVsu3atcqXtB6atsPxXJybrAlRq0hx0IOANHjCPd8i+cJO1/IKgkQU mz9IZorX79+CQ+4JDqv9jyFU9w8r3nN46FpXPshO4yFgrCnt/dtzWUtxPODQzfda9lZ9 0HmD4WkiKA9ccpo/1Ol11O/kcDaj1kC7mlxYD/B6CSqg87PEmwGsCXIx4pJiKpQa0kFH LFBZ4GSMaKroHJE4mAbZ4n9J0WlWqy300Olrs8FwMTQ1iY+Bnb1hdTvEkqI2EC4EzIKx QDOw== X-Gm-Message-State: AOJu0YwgirPPKGanmiCFaGO4vvQQS7JfwxDfTgGZdv6sooQKS32i2ujw la6HOIe7X2wPEb1CrxLu9X7CrhiT5rg= X-Google-Smtp-Source: AGHT+IHqc1+8C+Vif8VsFBtpmk2bTyiKeMX3eOc5BuurGztDPM7MluDNplKQqpz8C9E1Ji9UH3+3Uw== X-Received: by 2002:ac8:594a:0:b0:41e:172f:6e78 with SMTP id 10-20020ac8594a000000b0041e172f6e78mr12667960qtz.29.1698673726299; Mon, 30 Oct 2023 06:48:46 -0700 (PDT) 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 c18-20020ac86612000000b004181aa90b46sm3419929qtp.89.2023.10.30.06.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:48:46 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/4] station: start roam on beacon loss event Date: Mon, 30 Oct 2023 06:48:35 -0700 Message-Id: <20231030134837.452957-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231030134837.452957-1-prestwoj@gmail.com> References: <20231030134837.452957-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In past testing the beacon loss event seemed to always be followed immediately by a disconnect. It was determined at the time that there wasn't much point in even attempting a roam because a disconnect would happen before the roam could finish. This was a bit short sighted because its hardware dependent when the beacon loss event is sent. Recently it was seen that some hardware (ath10k in this case) actually gives some time before the kernel finally disconnects. In this example a beacon loss event came and IWD remained connected for 4 seconds (until a packet loss which issued a roam scan). 11:30:25 iwd[1407046]: src/netdev.c:netdev_cqm_event() Beacon lost event 11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64) 11:30:29 iwd[1407046]: src/station.c:station_packets_lost() Packets lost event: 10 11:30:29 iwd[1407046]: src/station.c:station_roam_scan() ifindex: 6 11:30:29 iwd[1407046]: src/wiphy.c:wiphy_radio_work_insert() Inserting work item 144 11:30:29 iwd[1407046]: src/wiphy.c:wiphy_radio_work_next() Starting work item 144 11:30:29 iwd[1407046]: src/station.c:station_start_roam() Using cached neighbor report for roam 11:30:29 iwd[1407046]: src/scan.c:scan_notify() Scan notification Trigger Scan(33) 11:30:29 iwd[1407046]: src/scan.c:scan_request_triggered() Active scan triggered for wdev 4 11:30:29 iwd[1407046]: src/netdev.c:netdev_link_notify() event 16 on ifindex 6 11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20) 11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39) 11:30:29 iwd[1407046]: src/netdev.c:netdev_deauthenticate_event() 11:30:29 iwd[1407046]: src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48) 11:30:29 iwd[1407046]: src/netdev.c:netdev_disconnect_event() 11:30:29 iwd[1407046]: Received Deauthentication event, reason: 4, from_ap: false It makes sense to also handle beacon loss events and attempt a roam, potentially saving the connection. One difference here is the beacon loss event will force a roam (similar to ap directed roaming when the imminent bit is set). --- src/netdev.h | 1 + src/station.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) 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 a2358d95..8c87b3e0 100644 --- a/src/station.c +++ b/src/station.c @@ -3347,6 +3347,20 @@ 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->force_roam = true; + + station_debug_event(station, "beacon-loss-roam"); + + station_start_roam(station); +} + static void station_netdev_event(struct netdev *netdev, enum netdev_event event, void *event_data, void *user_data) { @@ -3391,6 +3405,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 Mon Oct 30 13:48:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13440616 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.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 AA79E171CC for ; Mon, 30 Oct 2023 13:48:49 +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="blip7KMi" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-41cc44736f2so33839121cf.3 for ; Mon, 30 Oct 2023 06:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698673728; x=1699278528; 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=blip7KMiwN/8AKyA1y3svSmZkRJ6PvccuEg/7dJ4x2oGHiLjkE5pBzWr9Ryuocj4KT Voy0GcJ4vlDOVzMV+Kvu6QKXDfxCFK111bgy//FX+j80cAHm9KyuGKJTS/EC4kUEA8d+ cVEw3FTHn5BMhko/5Q80DBLk0+7U/ASo2l5iPinFgUTW4SbZISUSTPYpwLAeNbnzCasU 0KdemLgyO1xFJnxSnH1lcIvdcd/TiCRiNFC+0OSmMgqn5p9yVllPQh/5xmUnveH+wgcg 3ajA62ijhK6C1hKJN2wpviorlA5I0nL2KzS2iRAuHPLGBmIvS2CIDcoOILFBDjygBHk0 kPvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698673728; x=1699278528; 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=vlImL6bS0rahkAYputnDcQ8/IUfhEJZq6Ii6hlkbkRUwPF2Uw2Ck0g1FhzvdH3YfnB +dpbZjiQx/T6DsTwOkjQ3BswVXgiJylAyH/JndTKirezVxvkF/rGw05Bzelck1Cf4cPP 9zXX/T92l57Ydpix8gUSQXO4Ko6pV/dVuw3WcmMA5krG8CzSfahEmcTffMrr9EQHKu4n Izz+cE+WlwalUZh8IN+NICdt8/ntWKxUuAiTKF3eWt+8b0aWs3CRYDgTLqKWY2Ncp0hT zHOmCpqgtf+dryiChoYsiG3RxyROTPyqRCruJlFVZ1fEmKx8gw6+tv6hfuWp9jWHW9w8 dlMQ== X-Gm-Message-State: AOJu0Ywwwedet/p50fmkkrsohXOCc6FWB9CUN21oqXuIXkLl+kCGIp2r kE4juVqJDvBzBY/2iiB+sCrYcN+61/g= X-Google-Smtp-Source: AGHT+IHlrhaKE2eN0HnqoOTOu9D0WZdjLmU98mmOFx8GDGl5rv2HI4EF3dNa0cALwijAhpK6Iy3Z/Q== X-Received: by 2002:a05:622a:18a:b0:41c:c5bd:712 with SMTP id s10-20020a05622a018a00b0041cc5bd0712mr13135660qtw.62.1698673728505; Mon, 30 Oct 2023 06:48:48 -0700 (PDT) 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 c18-20020ac86612000000b004181aa90b46sm3419929qtp.89.2023.10.30.06.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:48:48 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/4] netdev: handle/send beacon loss event Date: Mon, 30 Oct 2023 06:48:36 -0700 Message-Id: <20231030134837.452957-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231030134837.452957-1-prestwoj@gmail.com> References: <20231030134837.452957-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, From patchwork Mon Oct 30 13:48:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13440617 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) (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 09543F9E6 for ; Mon, 30 Oct 2023 13:48:50 +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="LOUxaveB" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-1dc9c2b2b79so1886835fac.0 for ; Mon, 30 Oct 2023 06:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698673730; x=1699278530; 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=g3Gjbrqb/Rmqp4j8t39MW+WhEVN0ovDkDLbWrFkUeD0=; b=LOUxaveBb5ngehXpm31F3An5F5JoUIDC6s0xbHmmviHkt21pEx4Z/bYz1P6m+dlUyZ fEOseIM/pKxvJ8L3aENI9PxFhzr4tZV1QqVbUK98VKd2etHmAe4z2G1F23jJyrLdZCyv LttIiiv1aUjOvhUQZenFrOA6A8C6gdDPjdYhn23YupI5NV/cb0Vm2wsOXMwwATYx7i2v YzNjC9yIVT83y1RMxDAj9Mg0XmwiX8Y2XNYcHjnx/o9KIYuHAejPnky9TfPuZPVZVm+v CK/jSEL1SRZjMIEFDjXZ3yOmm1yZC+jixy6EsrMx7zSySFY6+NjlETSRR+8yz/RHHapx XK9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698673730; x=1699278530; 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=g3Gjbrqb/Rmqp4j8t39MW+WhEVN0ovDkDLbWrFkUeD0=; b=PsHHffaiI+8N2wi6Ja7QatIdBrJHGk85etvaJWN6ry/NZ0BJHURft/zkS9StWOo6GR lgooMuWE5LgmlPkM8C80zYoU+frvKybBimOTFnua1qrZBQt0kEEaM9ABKutTaOIv6SW8 Jx96+vFMA2nLpdQfs4OOAGhrb5Y+zCK0PHXnvHYQStdER5sk8pWj3OeL+4VYwm5SlbBt K2O49YyqiuoOtrUPZV1rlg0BLiXLJENbisnavsmCgK3+y1Z6SyrzpEphoR55gguFQs0F qsoZhOSm4VcrQlBNTfZT8O5mQS+8s3DUkDGCBb/cSbRimXLmyXMd2dW3VXuQ3nXmya6H Caew== X-Gm-Message-State: AOJu0Yyh3wZ4lNmaDd5rEzN9c8/t/rcZGuYOkcmc/ON1uYDfXsOR9LfW DhB0j8eV9GkjTj3uZ1qsVOLWckCbSXU= X-Google-Smtp-Source: AGHT+IF5YUaUY61wLZ9K0Pn6ja5QiuwJ8wG8tKPaEKxz4q7Vzg2IT44bZnEYkDpY6PtdkdUNfetOeQ== X-Received: by 2002:a05:6871:70b:b0:1e9:8885:b537 with SMTP id f11-20020a056871070b00b001e98885b537mr9487943oap.41.1698673729778; Mon, 30 Oct 2023 06:48:49 -0700 (PDT) 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 c18-20020ac86612000000b004181aa90b46sm3419929qtp.89.2023.10.30.06.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:48:49 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/4] station: rate limit packet loss roam scans Date: Mon, 30 Oct 2023 06:48:37 -0700 Message-Id: <20231030134837.452957-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231030134837.452957-1-prestwoj@gmail.com> References: <20231030134837.452957-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The packet loss handler puts a higher priority on roaming compared to the low signal roam path. This is generally beneficial since this event usually indicates some problem with the BSS and generally is an indicator that a disconnect will follow sometime soon. But by immediately issuing a scan we run the risk of causing many successive scans if more packet loss events arrive following the roam scans (and if no candidates are found). Logs provided further. To help with this handle the first event with priority and immediately issue a roam scan. If another event comes in within a certain timeframe (2 seconds) don't immediately scan, but instead rearm the roam timer instead of issuing a scan. This also handles the case of a low signal roam scan followed by a packet loss event. Delaying the roam will at least provide some time for packets to get out in between roam scans. Logs were snipped to be less verbose, but this cycled happened 5 times prior. In total 7 scans were issued in 5 seconds which may very well have been the reason for the local disconnect: Oct 27 16:23:46 src/station.c:station_roam_failed() 9 Oct 27 16:23:46 src/wiphy.c:wiphy_radio_work_done() Work item 29 done Oct 27 16:23:47 src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64) Oct 27 16:23:47 src/station.c:station_packets_lost() Packets lost event: 10 Oct 27 16:23:47 src/station.c:station_roam_scan() ifindex: 9 Oct 27 16:23:47 src/wiphy.c:wiphy_radio_work_insert() Inserting work item 30 Oct 27 16:23:47 src/wiphy.c:wiphy_radio_work_next() Starting work item 30 Oct 27 16:23:47 src/station.c:station_start_roam() Using cached neighbor report for roam Oct 27 16:23:47 src/scan.c:scan_notify() Scan notification Trigger Scan(33) Oct 27 16:23:47 src/scan.c:scan_request_triggered() Active scan triggered for wdev a Oct 27 16:23:47 src/scan.c:scan_notify() Scan notification New Scan Results(34) Oct 27 16:23:47 src/netdev.c:netdev_link_notify() event 16 on ifindex 9 ... scan results ... Oct 27 16:23:47 src/station.c:station_roam_failed() 9 Oct 27 16:23:47 src/wiphy.c:wiphy_radio_work_done() Work item 30 done Oct 27 16:23:47 src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64) Oct 27 16:23:47 src/station.c:station_packets_lost() Packets lost event: 10 Oct 27 16:23:47 src/station.c:station_roam_scan() ifindex: 9 Oct 27 16:23:47 src/wiphy.c:wiphy_radio_work_insert() Inserting work item 31 Oct 27 16:23:47 src/wiphy.c:wiphy_radio_work_next() Starting work item 31 Oct 27 16:23:47 src/station.c:station_start_roam() Using cached neighbor report for roam Oct 27 16:23:47 src/scan.c:scan_notify() Scan notification Trigger Scan(33) Oct 27 16:23:47 src/scan.c:scan_request_triggered() Active scan triggered for wdev a Oct 27 16:23:48 src/scan.c:scan_notify() Scan notification New Scan Results(34) Oct 27 16:23:48 src/netdev.c:netdev_link_notify() event 16 on ifindex 9 ... scan results ... Oct 27 16:23:48 src/station.c:station_roam_failed() 9 Oct 27 16:23:48 src/wiphy.c:wiphy_radio_work_done() Work item 31 done Oct 27 16:23:48 src/netdev.c:netdev_mlme_notify() MLME notification Notify CQM(64) Oct 27 16:23:48 src/station.c:station_packets_lost() Packets lost event: 10 Oct 27 16:23:48 src/station.c:station_roam_scan() ifindex: 9 Oct 27 16:23:48 src/wiphy.c:wiphy_radio_work_insert() Inserting work item 32 Oct 27 16:23:48 src/wiphy.c:wiphy_radio_work_next() Starting work item 32 Oct 27 16:23:48 src/station.c:station_start_roam() Using cached neighbor report for roam Oct 27 16:23:48 src/scan.c:scan_notify() Scan notification Trigger Scan(33) Oct 27 16:23:48 src/scan.c:scan_request_triggered() Active scan triggered for wdev a Oct 27 16:23:49 src/netdev.c:netdev_link_notify() event 16 on ifindex 9 Oct 27 16:23:49 src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20) Oct 27 16:23:49 src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39) Oct 27 16:23:49 src/netdev.c:netdev_deauthenticate_event() Oct 27 16:23:49 src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48) Oct 27 16:23:49 src/netdev.c:netdev_disconnect_event() Oct 27 16:23:49 Received Deauthentication event, reason: 4, from_ap: false --- src/station.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/station.c b/src/station.c index 8c87b3e0..bab690b9 100644 --- a/src/station.c +++ b/src/station.c @@ -123,6 +123,8 @@ struct station { struct wiphy_radio_work_item ft_work; + uint64_t last_roam_scan; + bool preparing_roam : 1; bool roam_scan_full : 1; bool signal_low : 1; @@ -1708,6 +1710,7 @@ static void station_roam_state_clear(struct station *station) station->signal_low = false; station->roam_min_time.tv_sec = 0; station->netconfig_after_roam = false; + station->last_roam_scan = 0; if (station->roam_scan_id) scan_cancel(netdev_get_wdev_id(station->netdev), @@ -2711,6 +2714,8 @@ static int station_roam_scan(struct station *station, if (L_WARN_ON(scan_freq_set_isempty(params.freqs))) return -ENOTSUP; + station->last_roam_scan = l_time_now(); + station->roam_scan_id = scan_active_full(netdev_get_wdev_id(station->netdev), ¶ms, station_roam_scan_triggered, @@ -3330,10 +3335,13 @@ static void station_disconnect_event(struct station *station, void *event_data) l_warn("Unexpected disconnect event"); } -#define STATION_PKT_LOSS_THRESHOLD 10 +#define STATION_PKT_LOSS_THRESHOLD 10 +#define LOSS_ROAM_RATE_LIMIT 2 static void station_packets_lost(struct station *station, uint32_t num_pkts) { + uint64_t elapsed; + l_debug("Packets lost event: %u", num_pkts); if (num_pkts < STATION_PKT_LOSS_THRESHOLD) @@ -3344,6 +3352,24 @@ static void station_packets_lost(struct station *station, uint32_t num_pkts) station_debug_event(station, "packet-loss-roam"); + elapsed = l_time_diff(station->last_roam_scan, l_time_now()); + + /* + * If we just issued a roam scan, delay the roam to avoid constant + * scanning. + */ + if (LOSS_ROAM_RATE_LIMIT > l_time_to_secs(elapsed)) { + l_debug("Too many roam attempts in %u second timeframe, " + "delaying roam", LOSS_ROAM_RATE_LIMIT); + + if (station->roam_trigger_timeout) + return; + + station_roam_timeout_rearm(station, LOSS_ROAM_RATE_LIMIT); + + return; + } + station_start_roam(station); }