diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index ebb2e328af50..4fa19294a99e 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -147,14 +147,20 @@ class HostapdGlobal:
 
 class Hostapd:
     def __init__(self, ifname, bssidx=0, hostname=None, ctrl=hapd_ctrl,
-                 port=8877):
+                 port=8877, link=None):
         self.hostname = hostname
         self.host = remotehost.Host(hostname, ifname)
         self.ifname = ifname
         if hostname is None:
-            self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname))
-            self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname))
-            self.dbg = ifname
+            if link is None:
+                self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.dbg = ifname
+            else:
+                ifname = ifname + "_link" + link
+                self.ctrl = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.mon = wpaspy.Ctrl(os.path.join(ctrl, ifname))
+                self.dbg = ifname
         else:
             self.ctrl = wpaspy.Ctrl(hostname, port)
             self.mon = wpaspy.Ctrl(hostname, port)
@@ -740,6 +746,13 @@ def add_mld_link(apdev, params):
         hostname = None
         port = 8878
 
+    if "link_id" not in params:
+        raise Exception("Link ID not passed in param")
+
+    link_id = params["link_id"]
+    # Delete the 'link_id' key from params or else it will be added in config
+    del params["link_id"]
+
     hapd_global = HostapdGlobal(apdev)
     confname, ctrl_iface = cfg_mld_link_file(ifname, params)
     hapd_global.send_file(confname, confname)
@@ -749,7 +762,8 @@ def add_mld_link(apdev, params):
         if str(e) == "Could not add hostapd link":
             raise utils.HwsimSkip("No MLO support in hostapd")
     port = hapd_global.get_ctrl_iface_port(ifname)
-    hapd = Hostapd(ifname, hostname=hostname, ctrl=ctrl_iface, port=port)
+    hapd = Hostapd(ifname, hostname=hostname, ctrl=ctrl_iface, port=port,
+                   link=link_id)
     if not hapd.ping():
         raise Exception("Could not ping hostapd")
     return hapd
@@ -1023,9 +1037,6 @@ def cfg_mld_link_file(ifname, params):
     fd, fname = tempfile.mkstemp(dir='/tmp', prefix=conf + '-')
     f = os.fdopen(fd, 'w')
 
-    if idx != 0:
-        ctrl_iface="/var/run/hostapd_%d" % idx
-
     f.write("ctrl_interface=%s\n" % ctrl_iface)
     f.write("driver=nl80211\n")
     f.write("ieee80211n=1\n")
diff --git a/tests/hwsim/test_eht.py b/tests/hwsim/test_eht.py
index 00d6adff7190..e9543936477c 100644
--- a/tests/hwsim/test_eht.py
+++ b/tests/hwsim/test_eht.py
@@ -302,10 +302,12 @@ def test_eht_mld_discovery(dev, apdev):
         ssid = "mld_ap"
         link0_params = {"ssid": ssid,
                         "hw_mode": "g",
-                        "channel": "1"}
+                        "channel": "1",
+                        "link_id": "0"}
         link1_params = {"ssid": ssid,
                         "hw_mode": "g",
-                        "channel": "2"}
+                        "channel": "2",
+                        "link_id": "1"}
 
         hapd0 = eht_mld_enable_ap(hapd_iface, link0_params)
         hapd1 = eht_mld_enable_ap(hapd_iface, link1_params)
@@ -387,12 +389,14 @@ def _eht_mld_owe_two_links(dev, apdev, second_link_disabled=False,
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
         if second_link_disabled:
             params['mld_indicate_disabled'] = '1'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
         # Check legacy client connection
@@ -445,6 +449,7 @@ def test_eht_mld_sae_single_link(dev, apdev):
         ssid = "mld_ap_sae_single_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase, key_mgmt="SAE",
                                         mfp="2", pwe='2')
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -470,10 +475,12 @@ def run_eht_mld_sae_two_links(dev, apdev, beacon_prot="1",
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE", mfp="2", pwe='1',
                                         beacon_prot=beacon_prot)
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -560,6 +567,7 @@ def test_eht_mld_sae_ext_one_link(dev, apdev):
         passphrase = 'qwertyuiop'
         ssid = "mld_ap_sae_ext_single_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase, key_mgmt="SAE-EXT-KEY")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -583,10 +591,12 @@ def test_eht_mld_sae_ext_two_links(dev, apdev):
         ssid = "mld_ap_sae_two_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE-EXT-KEY")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -606,10 +616,12 @@ def test_eht_mld_sae_legacy_client(dev, apdev):
         ssid = "mld_ap_sae_two_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE", mfp="2", pwe='1')
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -646,10 +658,12 @@ def test_eht_mld_sae_transition(dev, apdev):
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE-EXT-KEY SAE WPA-PSK WPA-PSK-SHA256",
                                         mfp="1")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -682,10 +696,12 @@ def test_eht_mld_ptk_rekey(dev, apdev):
                                         key_mgmt="SAE-EXT-KEY SAE WPA-PSK WPA-PSK-SHA256",
                                         mfp="1")
         params['wpa_ptk_rekey'] = '5'
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -722,10 +738,12 @@ def test_eht_mld_gtk_rekey(dev, apdev):
                                         key_mgmt="SAE-EXT-KEY SAE WPA-PSK WPA-PSK-SHA256",
                                         mfp="1")
         params['wpa_group_rekey'] = '5'
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -762,10 +780,12 @@ def test_eht_ml_probe_req(dev, apdev):
         ssid = "mld_ap_sae_two_link"
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE-EXT-KEY")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
@@ -804,10 +824,14 @@ def test_eht_mld_connect_probes(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
 
         wpas.set("sae_pwe", "1")
@@ -849,10 +873,14 @@ def test_eht_tx_link_rejected_connect_other(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
 
         wpas.set("sae_pwe", "1")
@@ -879,10 +907,14 @@ def test_eht_all_links_rejected(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
         wpas.set("mld_connect_bssid_pref", "00:11:22:33:44:01")
         wpas.set("sae_pwe", "1")
@@ -922,10 +954,13 @@ def test_eht_connect_invalid_link(dev, apdev, params):
                                              key_mgmt="SAE", pwe='2')
         link_params['channel'] = '1'
         link_params['bssid'] = '00:11:22:33:44:01'
+        link_params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, link_params)
 
         link_params['channel'] = '6'
         link_params['bssid'] = '00:11:22:33:44:02'
+        link_params['link_id'] = '1'
         hapd1 = eht_mld_enable_ap(hapd_iface, link_params)
 
         # We scan for both APs, then try to connect to link 0, but only the
@@ -957,9 +992,12 @@ def test_eht_mld_link_removal(dev, apdev):
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
         wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
@@ -1009,10 +1047,12 @@ def test_eht_mld_bss_trans_mgmt_link_removal_imminent(dev, apdev):
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
         params["bss_transition"] = "1"
         params["mbo"] = "1"
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1061,10 +1101,12 @@ def test_eht_ap_mld_proto(dev, apdev):
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1449,10 +1491,14 @@ def test_eht_mld_gas(dev, apdev):
         params['venue_group'] = "7"
         params['venue_type'] = "1"
         params['venue_name'] = "eng:Example venue"
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
         bssid0 = hapd0.own_addr()
 
         params['channel'] = '6'
+        params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
         bssid1 = hapd1.own_addr()
 
@@ -1485,9 +1531,13 @@ def test_eht_mld_dpp_responder_while_assoc(dev, apdev):
 
         ssid = "owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
         wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
@@ -1513,9 +1563,13 @@ def _eht_mld_disconnect(dev, apdev, disassoc=True):
 
         ssid = "mld_ap_owe_two_link"
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
         params['channel'] = '6'
+        params['link_id'] = '1'
+
         hapd1 = eht_mld_enable_ap(hapd0_iface, params)
 
         wpas.connect(ssid, scan_freq="2412 2437", key_mgmt="OWE",
@@ -1570,6 +1624,7 @@ def test_eht_mld_non_pref_chan(dev, apdev):
         params = eht_mld_ap_wpa2_params(ssid, key_mgmt="OWE", mfp="2")
         params["bss_transition"] = "1"
         params["mbo"] = "1"
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1658,6 +1713,7 @@ def test_eht_mld_rrm_beacon_req(dev, apdev):
         params["bss_transition"] = "1"
         params["mbo"] = "1"
         params["rrm_beacon_report"] = "1"
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd0_iface, params)
 
@@ -1673,6 +1729,8 @@ def test_eht_mld_rrm_beacon_req(dev, apdev):
         other_ssid = "other"
         params = eht_mld_ap_wpa2_params(other_ssid, key_mgmt="OWE", mfp="2")
         params["channel"] = '6'
+        params['link_id'] = '0'
+
         hapd1 = eht_mld_enable_ap(hapd1_iface, params)
 
         # Issue a beacon request for the second AP
@@ -1712,6 +1770,8 @@ def test_eht_mld_legacy_stas(dev, apdev):
                                         mfp="2", pwe='2')
         params['rsn_pairwise'] = "CCMP GCMP-256"
         params['sae_groups'] = "19 20"
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         for i in range(3):
@@ -1751,6 +1811,8 @@ def test_eht_mld_and_mlds(dev, apdev):
                                         mfp="2", pwe='2')
         params['rsn_pairwise'] = "CCMP GCMP-256"
         params['sae_groups'] = "19 20"
+        params['link_id'] = '0'
+
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         wpas.set("sae_pwe", "1")
@@ -1816,9 +1878,13 @@ def test_eht_mlo_csa(dev, apdev):
 
             params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                             key_mgmt="SAE", mfp="2", pwe='1')
+            params['link_id'] = '0'
+
             hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
             params['channel'] = '6'
+            params['link_id'] = '1'
+
             hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
             wpas.set("sae_pwe", "1")
@@ -1903,7 +1969,7 @@ def get_config(iface, count, ssid, passphrase, channel, bssid_regex,
         params['sae_pwe'] = "2"
         params['group_mgmt_cipher'] = "AES-128-CMAC"
         params['beacon_prot'] = "1"
-        params["ctrl_interface"] = "/var/run/hostapd/chan_" + str(channel)
+        params["ctrl_interface"] = "/var/run/hostapd/"
         params["bssid"] = bssid_regex % (i + 1)
 
         if rnr:
@@ -1911,7 +1977,7 @@ def get_config(iface, count, ssid, passphrase, channel, bssid_regex,
 
         append_bss_conf_to_file(f, ifname, params, first=(i == 0))
 
-        hapds.append([ifname, params["ctrl_interface"], i])
+        hapds.append([ifname, i])
 
     f.close()
 
@@ -1956,15 +2022,15 @@ def get_mld_devs(hapd_iface, count, prefix, rnr=False):
 
     start_ap(prefix, fname1 + " " + fname2)
 
-    hapd_mld1_link0 = hostapd.Hostapd(ifname=hapds1[0][0], ctrl=hapds1[0][1],
-                                      bssidx=hapds1[0][2])
-    hapd_mld1_link1 = hostapd.Hostapd(ifname=hapds2[0][0], ctrl=hapds2[0][1],
-                                      bssidx=hapds2[0][2])
+    hapd_mld1_link0 = hostapd.Hostapd(ifname=hapds1[0][0], bssidx=hapds1[0][1],
+                                      link="0")
+    hapd_mld1_link1 = hostapd.Hostapd(ifname=hapds2[0][0], bssidx=hapds2[0][1],
+                                      link="1")
 
-    hapd_mld2_link0 = hostapd.Hostapd(ifname=hapds1[1][0], ctrl=hapds1[1][1],
-                                      bssidx=hapds1[1][2])
-    hapd_mld2_link1 = hostapd.Hostapd(ifname=hapds2[1][0], ctrl=hapds2[1][1],
-                                      bssidx=hapds2[1][2])
+    hapd_mld2_link0 = hostapd.Hostapd(ifname=hapds1[1][0], bssidx=hapds1[1][1],
+                                      link="0")
+    hapd_mld2_link1 = hostapd.Hostapd(ifname=hapds2[1][0], bssidx=hapds2[1][1],
+                                      link="1")
 
     if not hapd_mld1_link0.ping():
         raise Exception("Could not ping hostapd")
@@ -2143,11 +2209,13 @@ def test_eht_mlo_color_change(dev, apdev):
         params = eht_mld_ap_wpa2_params(ssid, passphrase,
                                         key_mgmt="SAE", mfp="2", pwe='1')
         params['he_bss_color'] = '42'
+        params['link_id'] = '0'
 
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params['channel'] = '6'
         params['he_bss_color'] = '24'
+        params['link_id'] = '1'
 
         hapd1 = eht_mld_enable_ap(hapd_iface, params)
 
diff --git a/tests/hwsim/test_rsn_override.py b/tests/hwsim/test_rsn_override.py
index 6733102e7ba4..9ffcad1032d4 100644
--- a/tests/hwsim/test_rsn_override.py
+++ b/tests/hwsim/test_rsn_override.py
@@ -141,6 +141,7 @@ def run_rsn_override_mld(dev, apdev, mixed):
         params['sae_groups'] = '19 20'
         params['sae_require_mfp'] = '1'
         params['sae_pwe'] = '2'
+        params['link_id'] = '0'
         if not mixed:
             params['rsn_override_key_mgmt'] = 'SAE'
             params['rsn_override_key_mgmt_2'] = 'SAE-EXT-KEY'
@@ -166,6 +167,7 @@ def run_rsn_override_mld(dev, apdev, mixed):
         hapd0 = eht_mld_enable_ap(hapd_iface, params)
 
         params1['channel'] = '6'
+        params1['link_id'] = '1'
         hapd1 = eht_mld_enable_ap(hapd_iface, params1)
 
         wpas.set("sae_pwe", "1")
