From patchwork Fri Aug 3 23:27:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyad Qumei X-Patchwork-Id: 953528 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=verizon.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Wvh34Wcl"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=verizon.com header.i=@verizon.com header.b="ZxpDF8sE"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=verizon-com.20150623.gappssmtp.com header.i=@verizon-com.20150623.gappssmtp.com header.b="f0EhndcN"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41k2x443QHz9s0n for ; Mon, 6 Aug 2018 00:20:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=vYSsr5ndy8Yj+fhkxg75HZwkOItAFDgav1XLagdP2lY=; b=Wvh 34Wclzo05+BTKmo3fEvqiRdE6+ML2fVyVTo9RU67DyL5+8KqS/UZgZoACmII8pciAfduwHjr+GpmS XOr5Erf/+Kp9dj2Z27YHSINMxSl3wBANML301/9y0Yi7OfRRNJyH1ar7GnOKv+onugj+xU4Ymp42l ax+BrQ3UsdHf17mdwF+4NTZkM3kUwxGCstmj4ESCFT9RJILZq4R/7FzmSVcg78oTyNKdbrAWt2GdB ObLdK/33TnuoJ0rXv+S4GKpeUgWFM2MrNzCVlfpbQUDWypxN/3oU+yJWaIgTkoKELnXhHmU7CtOWu 2YHrhuncJOisg9T6XAn6zvVkej2Hrow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmJss-0002mM-Le; Sun, 05 Aug 2018 14:19:50 +0000 Received: from mx0a-0024a201.pphosted.com ([148.163.149.93]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fljU6-0000H3-8H for hostap@lists.infradead.org; Fri, 03 Aug 2018 23:27:52 +0000 Received: from pps.filterd (m0098484.ppops.net [127.0.0.1]) by mx0a-0024a201.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w73NPGKU186695 for ; Fri, 3 Aug 2018 19:27:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.com; h=mime-version : from : date : message-id : subject : to : content-type; s=corp; bh=4Q1psdQH2nLIMkzB4Ka3qhAm+vtKFole82cqQlJOCj4=; b=ZxpDF8sEnxMReBoEyjxIYWWVFY8aMWIAHoCXATfeqFjwmTWDQYSVnhqzpanDK3FaFdzb ST4K44PW0CuE5n+wBR13tkxGwZgiu5DJIigcLkran+f+YXs565jdpWioyK7chnK6IczP lUYjxUvYM2KDqHy0eIR1xHq6SrG5kaS0zBA= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by mx0a-0024a201.pphosted.com with ESMTP id 2kmy52rh12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 03 Aug 2018 19:27:36 -0400 Received: by mail-lf1-f71.google.com with SMTP id z12-v6so864453lfe.2 for ; Fri, 03 Aug 2018 16:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=4Q1psdQH2nLIMkzB4Ka3qhAm+vtKFole82cqQlJOCj4=; b=f0EhndcNIqn4IAr6zeWvuDqXRFkxtrBBIeVQ6oPp5vfMBMut5eK+mppk1sHsXPnfB5 97jpiGf6D5ZBj0QDObdUkqaimkFh2w8VA/KeC+qrcf9cbbvTzSnWlnnnkvROfQlw8T/1 X7tPTo1wyEQN4AmoPWOBlNQVSNyq/49vsJaQKOY/Yl6AHt+YvhiTdcbL6eeOFZsDWhAW QZuBbICmeKKybSakduukXsA0WOJg4ZlELyGYJaNYxBm/as2gEvpNNiBs6VK/aver+5FQ uSRRuBuQkyTj1MyhSuspPXo7OmA4hVHAcjyvwZHXIkbvUyXPtLeuuyC5j6YV9IulmVRq 7c2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=4Q1psdQH2nLIMkzB4Ka3qhAm+vtKFole82cqQlJOCj4=; b=cac3KQH+vHoFSrSNquP4bk6TIaIQTO1yLx9Oaq38bWlIFgWTEmduq3AAFnCTFvUhcO 7M6pxO8NcDHXrwBibeYb8oR3FovFEqzDGd/eavEs6PvHgPbA/FSN/q+tjGn0qpjBrb38 1ZEeyN41QP3NNWpW9O31wi8MTStatt8NKqDekCyhooBKECp7rLfJmLZtVcxy+xMuMnVq YYfIDPAtke2VaF9rbqdlvFS7AJw0ByRRP57wP+pcuMUlVi6lReVMxzr94dwcvaax7Wz/ baor0VbOJd0vglGKkuH1NxMok0+HpOEENZAG8/rMbNcmlzXDeYdIk7HOF8r34WEHpJ7N Ysrw== X-Gm-Message-State: AOUpUlFrLRWsRMl/mvOIiH2RkIhBp1KXqVsx0cCOkU1qA0RO/YYvxQ7A 8P0BOmw6Pla4OWrGDN6QXYQsTuRaute1qvVxEz19ULvqIBJaj+WHXat1Gt1Pno6/FWWmNxjeQNF KyocXhtSfKwhtP8x1QzbH3g3Ts7ephVUSCgFPPw== X-Received: by 2002:a19:de4e:: with SMTP id v75-v6mr5580796lfg.14.1533338854133; Fri, 03 Aug 2018 16:27:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeQ/BVS2OU+4wIFUxJr9ysVQlnCNEw1KnzmQFpq/QUgySxsixRnARcF5Sia2ivz22vG0Qu6bGISOPl3Unq2CJE= X-Received: by 2002:a19:de4e:: with SMTP id v75-v6mr5580790lfg.14.1533338853898; Fri, 03 Aug 2018 16:27:33 -0700 (PDT) MIME-Version: 1.0 From: Iyad Qumei Date: Fri, 3 Aug 2018 16:27:22 -0700 Message-ID: Subject: [PATCH] Fix wpa_supplicant AP roaming algorithm To: hostap@lists.infradead.org X-mailroute: internal X-Proofpoint-Spam-Details: rule=out_spam_notspam policy=out_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808030253 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180803_162750_562498_9F80F2B3 X-CRM114-Status: GOOD ( 19.57 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [148.163.149.93 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.0 T_DKIMWL_WL_MED DKIMwl.org - Whitelisted Medium sender X-Mailman-Approved-At: Sun, 05 Aug 2018 07:19:48 -0700 X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The current roaming algorithm is incorrect. The main issue is the presence of roaming gaps in specific regions of the defined signal levels in wpa_supplicant_need_to_roam(). The following table illustrates these gaps. These gaps are introduced due to the comparison of absolute integer values instead of a signed comparison. For example, in the preferred 5 GHz signal level range (-80,-75) roaming will occur at delta (selected - current) levels of -2, -1 and > 1 dBm. In this case, no roaming is permitted with the delta value equal to 0. Similar circumstances occur in the range (-75,-70). The second issue is related to the handling of positive signal levels. Although, this is not a physically common use case due to the limit on the WiFi signal power level. Nevertheless, it is being handled incorrectly by the algorithm. First, for the preferred 5GHz signal levels, roaming will happen at any value, as the calculated absolute |current - select| is never < 0. Second, when operating frequency is similar, i.e. both are 5 or both 2.4 GHz, roaming with positive signal level will occur at a signal level delta of <-2 and >2. Hence, a gap is present where no roaming is possible at -1, 0 and 1 dBm. Current Broken State else if (current_bss->level < -80) @@ -1734,9 +1734,9 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, if (min_diff > reduce) min_diff -= reduce; else - min_diff = 0; + min_diff = -2; } - diff = abs(current_bss->level - selected->level); + diff = (selected->level - current_bss->level); if (diff < min_diff) { wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference in signal level (%d < %d)", ==================== Standard Roam Criteria (both select and current frequences are either 2.4 or 5 GHz) ----------------------------------------------------------------------------------------------------------------- Current Level < -85 selected - current >= 1 min_diff = 1 -85 < Current Level < -80 selected - current >= 2 min_diff = 2 -80 < Current Level < -75 selected - current >= 3 min_diff = 3 -75 < Current Level < -70 selected - current >= 4 min_diff = 4 -70 < Current Level < 0 selected - current >= 5 min_diff = 5 Current Level > 0 selected - current >= 2 min_diff = 2 ( Roams at delta < -2, > 2 , gap at delta -1 0 1 ) Preferred 5GHz ( current channel frequency 2.4 and select frequency is 5.0 GHz) ------------------------------------------------------------------------------------------------------------- Current Level < -85 selected - current >= -2 min_diff = 0 -85 < Current Level < -80 selected - current >= -2 min_diff = 0 -80 < Current Level < -75 selected - current >= 1 min_diff = 1 ( roams at delta -2, -1 and > 1, does not roam at delta 0 ) -75 < Current Level < -70 selected - current >= 2 min_diff = 2 ( roams at delta -2 and > 2, does not roam at delta -1 0 1 ) -70 < Current Level < 0 selected - current >= 3 min_diff = 3 Current Level > 0 selected - current >= any min_diff = 0 The proposed fix in the attached patch eliminates incorrect roams. The following data was collected from the revised algorithm implementation. Proposed Fix ============ Standard Roam Criteria (both select and current frequences are either 2.4 or 5 GHz) ------------------------------------------------------------------------------------ Current Level < -85 selected - current >= 1 min_diff = 1 -85 < Current Level < -80 selected - current >= 2 min_diff = 2 -80 < Current Level < -75 selected - current >= 3 min_diff = 3 -75 < Current Level < -70 selected - current >= 4 min_diff = 4 Current Level > -70 selected - current >= 5 min_diff = 5 Preferred 5GHz ( current channel frequency 2.4 and select frequency is 5.0 GHz) ------------------------------------------------------------------------------------ Current Level < -85 selected - current >= -2 min_diff = -2 -85 < Current Level < -80 selected - current >= -2 min_diff = -2 -80 < Current Level < -75 selected - current >= 1 min_diff = 1 -75 < Current Level < -70 selected - current >= 2 min_diff = 2 Current Level > -70 selected - current >= 3 min_diff = 3 Signed-off-by: Iyad Qumei --- wpa_supplicant/events.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index fb77f1d..64a2a54 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1700,7 +1700,7 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, cur_est = current_bss->est_throughput; sel_est = selected->est_throughput; min_diff = 2; - if (current_bss->level < 0) { + { if (current_bss->level < -85) min_diff = 1;