From patchwork Thu Oct 20 04:43:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasun Maiti X-Patchwork-Id: 1692260 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nCzpdshv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Fb6zFIZQ; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MtFTM5sHcz1ygT for ; Thu, 20 Oct 2022 15:47:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From: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=pqI8Tl9F/M4wS8MktT1oGdhxrL9jBwrBc95yFRGYYRc=; b=nCzpdshvOVlH50 k8qR0FdtvSJ4+MRqaQwts8R+GA6VccN510dHVWAfeUY1uh/cEwn+e57MEPGOBuFCASnLd+m8kBKfd 5z40sL31XHBNYhzNtoXLCb0v31MwbjRdd2gBq//u7Uef9+4efTfg6fFZZuaoNtELpQcCKPbdiQqnp k3Pr9D/MghW9rMFN40RxvipSm6Y5Kq5ZJ1XZUQ+iSmFrJN7SE9R/b0F7FyR4IbRKNQzypD+9NdzdG iNHGrB1+GvStnfh17U5ERB7wnXBIshYpC69kCLFo7wm5DfH65FS7NLIsWaNUTEEEoL2Z2S0ilRixs Ws315+NLWRlsmXvgsGJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olNPB-00AHi2-Ez; Thu, 20 Oct 2022 04:43:41 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olNP6-00AHhL-DW for openwrt-devel@lists.openwrt.org; Thu, 20 Oct 2022 04:43:37 +0000 Received: by mail-pg1-x52c.google.com with SMTP id q1so18155132pgl.11 for ; Wed, 19 Oct 2022 21:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=7fDIvyEOAeRYlPNzaUhjfqbzMICQ/jn93D9ejm4GsiE=; b=Fb6zFIZQOAL7yz1BfpqMqyAT5bthgV9bKjKPXoaslNafyg9LzLMxSe7jlfMaW90zV9 Fw6MxRIOqhBVqDrDaYdRD5Gz81jDlzNk7usKQqXi2LwhiY/HqBPD8MIqKzQoskbdDmIf EH+UhHuUxvJnPCa3mb3ZWTEoU5T1LLALs75a1LmQT+SUSuzdQpe4R9k81mHy80qZf+ID EBptiaw5nChPXBdjKm6WmNNkXTOE/IitN7x345GJJ90dTVsExDIWDZWP0x2IPElpn/8g 6Pqrmqo2R4SA7PvxovQC6y+1LVne8XOpBSXdz3U2wLckn+Vkp1rWYK5cuO/zFCekmCvs BBlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7fDIvyEOAeRYlPNzaUhjfqbzMICQ/jn93D9ejm4GsiE=; b=M8c/5awzxSjBDd93KFBgoi+5UaMFP4hP02Jk7ejhWWHK5z2LVRzvafxq8p0Kf0UeU/ n8drq2zHQAP4UYgKo1ChR2kUdWv37ukHnz+HK+m1QLXIAtWzc6IaxzQtzZKsntmIbzAg N96YJi/VBNJeCGi/rkdSTyBz+85zhu1keI0o/786ZItA83TjglgCvSLinQTN7DDhI4oQ yk2JHy6nIo0McwynsK5BdkjJfptfBDVDmkfe3qcGttslj7JDovftNGDUON319+egARWm KMLOMaULHhQtJJqfGwBf+iNAdx2ZsQB+FB6uvEmbrab8jytELWPX+T8p9dzhMSoK3FuQ +V8A== X-Gm-Message-State: ACrzQf2r/gT00xmTs+YJ5DSuvpge+ZOm+NmdkIwJsFkrMCTU9WThY5br MLMucULSSZbwD8FoUzEQWu2xSjtL/uI= X-Google-Smtp-Source: AMsMyM4Xdfn/BNbr5EKZ09NUSLLtzyYa0LQfodVcEEsnhx8vrFgQho5zupTtabbsxdVCRyP054uukA== X-Received: by 2002:a05:6a00:c91:b0:562:aa06:2848 with SMTP id a17-20020a056a000c9100b00562aa062848mr12364500pfv.2.1666241014518; Wed, 19 Oct 2022 21:43:34 -0700 (PDT) Received: from BALT-PMAITI.maxlinear.com ([116.206.202.247]) by smtp.gmail.com with ESMTPSA id b4-20020a170902650400b0017f59ebafe7sm1485918plk.212.2022.10.19.21.43.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 21:43:34 -0700 (PDT) From: Prasun Maiti To: OpenWrt Development List Subject: [PATCH] netifd: add vif in ascending order instead of lexicographic Date: Thu, 20 Oct 2022 10:13:16 +0530 Message-Id: <20221020044317.1925-1-prasunmaiti87@gmail.com> X-Mailer: git-send-email 2.36.0.windows.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221019_214336_495341_3B60900C X-CRM114-Status: GOOD ( 11.18 ) X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: We are using vif_idx for listing vif. But wlan vif ordering is done in lexicographical manner by avl_strcmp() which is casuing in bringing up vap with higher index added first. Instead of using avl_strcmp(), we can use avl_vif_idx_cmp() for interfaces. Content analysis details: (0.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:52c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [prasunmaiti87[at]gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [prasunmaiti87[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org We are using vif_idx for listing vif. But wlan vif ordering is done in lexicographical manner by avl_strcmp() which is casuing in bringing up vap with higher index added first. Instead of using avl_strcmp(), we can use avl_vif_idx_cmp() for interfaces. Signed-off-by: Prasun Maiti --- wireless.c | 8 +++++++- wireless.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wireless.c b/wireless.c index bd847e7..b6b45bb 100644 --- a/wireless.c +++ b/wireless.c @@ -122,6 +122,12 @@ wireless_handler_stop(struct wireless_device *wdev) } } +int +avl_vif_idx_cmp(const void *k1, const void *k2, void *ptr) +{ + return (atoi(k1) - atoi(k2)); +} + static void put_container(struct blob_buf *buf, struct blob_attr *attr, const char *name) { @@ -1045,7 +1051,7 @@ wireless_device_create(struct wireless_driver *drv, const char *name, struct blo wdev->retry_setup_failed = false; wdev->autostart = true; INIT_LIST_HEAD(&wdev->script_proc); - vlist_init(&wdev->interfaces, avl_strcmp, vif_update); + vlist_init(&wdev->interfaces, avl_vif_idx_cmp, vif_update); wdev->interfaces.keep_old = true; vlist_init(&wdev->vlans, avl_strcmp, vlan_update); wdev->vlans.keep_old = true; diff --git a/wireless.h b/wireless.h index 7b87611..9a2c0ee 100644 --- a/wireless.h +++ b/wireless.h @@ -146,5 +146,6 @@ int wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data, void wireless_start_pending(void); void wireless_init(void); void wireless_device_hotplug_event(const char *name, bool add); +int avl_vif_idx_cmp(const void *k1, const void *k2, void *ptr); #endif