[PATCH] netifd: add vif in ascending order instead of lexicographic
Prasun Maiti
prasunmaiti87 at gmail.com
Wed Oct 19 21:43:16 PDT 2022
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 <prasunmaiti87 at gmail.com>
---
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
--
2.17.1
More information about the openwrt-devel
mailing list