diff mbox series

netifd: add vif in ascending order instead of lexicographic

Message ID 20221020044317.1925-1-prasunmaiti87@gmail.com
State Needs Review / ACK
Delegated to: Hauke Mehrtens
Headers show
Series netifd: add vif in ascending order instead of lexicographic | expand

Commit Message

Prasun Maiti Oct. 20, 2022, 4:43 a.m. UTC
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@gmail.com>
 wireless.c | 8 +++++++-
 wireless.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series


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)
+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;
-	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);