diff mbox

[2/6] tests: pass apdev to add_bss() remove_bss()

Message ID 1459328161-4298-3-git-send-email-janusz.dziedzic@tieto.com
State Changes Requested
Headers show

Commit Message

Janusz.Dziedzic@tieto.com March 30, 2016, 8:55 a.m. UTC
Pass apdev dictionary to add_bss()/remove_bss()
funtions instead of ifname. This allow us to handle
remote hosts correctly while we can get hostname
form apdev['hostname'].

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 tests/hwsim/hostapd.py                |  25 ++++--
 tests/hwsim/test_ap_dynamic.py        | 165 ++++++++++++++++++----------------
 tests/hwsim/test_ap_ht.py             |  14 +--
 tests/hwsim/test_ap_wps.py            |   2 +-
 tests/hwsim/test_monitor_interface.py |   2 +-
 5 files changed, 119 insertions(+), 89 deletions(-)

Comments

Jouni Malinen April 3, 2016, 9:21 p.m. UTC | #1
On Wed, Mar 30, 2016 at 10:55:57AM +0200, Janusz Dziedzic wrote:
> Pass apdev dictionary to add_bss()/remove_bss()
> funtions instead of ifname. This allow us to handle
> remote hosts correctly while we can get hostname
> form apdev['hostname'].

Passing apdev as an additional argument would likely be acceptable, but
doing this instead of ifname sounds strange. apdev is supposed to
describe the main interface and the BSSes are independent of that and
use different ifname.

> diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py
> @@ -92,111 +92,117 @@ def _test_ap_bss_add_remove(dev, apdev):
> -    ifname1 = apdev[0]['ifname']
> -    ifname2 = apdev[0]['ifname'] + '-2'
> -    ifname3 = apdev[0]['ifname'] + '-3'
> +    apdev1 = apdev[0].copy()
> +    apdev2 = apdev[0].copy()
> +    apdev2['ifname'] = apdev[0]['ifname'] + '-2'

This does not really make any sense to me. Why would there be multiple
apdev dicts for the same apdev with the ifname changed to point to a BSS
ifname?

> -    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
> +    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')

If we need apdev in add_bss(), I'd just add apdev[0] here as an argument
and leave ifname1 as-is.

I'm dropping this version and since the following patches in this series
were dependent on the changes from this patch, I'm also dropping them.
Please resubmit if you end up modifying this patch to leave in the
ifname argument.
Janusz.Dziedzic@tieto.com April 4, 2016, 3:29 p.m. UTC | #2
On 3 April 2016 at 23:21, Jouni Malinen <j@w1.fi> wrote:
> On Wed, Mar 30, 2016 at 10:55:57AM +0200, Janusz Dziedzic wrote:
>> Pass apdev dictionary to add_bss()/remove_bss()
>> funtions instead of ifname. This allow us to handle
>> remote hosts correctly while we can get hostname
>> form apdev['hostname'].
>
> Passing apdev as an additional argument would likely be acceptable, but
> doing this instead of ifname sounds strange. apdev is supposed to
> describe the main interface and the BSSes are independent of that and
> use different ifname.
>
OK, then I will add apdev and leave ifname.
BTW should I remove phy parameter and get this from add_bss()
using:
iw dev apdev['ifname'] info
instead of using hardcoded "phy3"?

BR
Janusz
>> diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py
>> @@ -92,111 +92,117 @@ def _test_ap_bss_add_remove(dev, apdev):
>> -    ifname1 = apdev[0]['ifname']
>> -    ifname2 = apdev[0]['ifname'] + '-2'
>> -    ifname3 = apdev[0]['ifname'] + '-3'
>> +    apdev1 = apdev[0].copy()
>> +    apdev2 = apdev[0].copy()
>> +    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
>
> This does not really make any sense to me. Why would there be multiple
> apdev dicts for the same apdev with the ifname changed to point to a BSS
> ifname?
>
>> -    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
>> +    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
>
> If we need apdev in add_bss(), I'd just add apdev[0] here as an argument
> and leave ifname1 as-is.
>
> I'm dropping this version and since the following patches in this series
> were dependent on the changes from this patch, I'm also dropping them.
> Please resubmit if you end up modifying this patch to leave in the
> ifname argument.
>
> --
> Jouni Malinen                                            PGP id EFC895FA
diff mbox

Patch

diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index 5abd3ca..5ee22bb 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -383,9 +383,16 @@  def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30):
                 raise Exception("AP startup failed")
         return hapd
 
-def add_bss(phy, ifname, confname, ignore_error=False, hostname=None,
-            port=8878):
-    logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
+def add_bss(phy, apdev, confname, ignore_error=False):
+    ifname = apdev['ifname']
+    try:
+        hostname = apdev['hostname']
+        port = apdev['port']
+        logger.info("Starting BSS " + hostname + "/" + port + " phy=" + phy + " ifname=" + ifname)
+    except:
+        logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
+        hostname = None
+        port = 8878
     hapd_global = HostapdGlobal(hostname=hostname, port=port)
     hapd_global.add_bss(phy, confname, ignore_error)
     port = hapd_global.get_ctrl_iface_port(ifname)
@@ -402,8 +409,16 @@  def add_iface(ifname, confname, hostname=None, port=8878):
     if not hapd.ping():
         raise Exception("Could not ping hostapd")
 
-def remove_bss(ifname, hostname=None, port=8878):
-    logger.info("Removing BSS " + ifname)
+def remove_bss(apdev):
+    ifname = apdev['ifname']
+    try:
+        hostname = apdev['hostname']
+        port = apdev['port']
+        logger.info("Removing BSS " + hostname + "/" + port + " " + ifname)
+    except:
+        logger.info("Removing BSS " + ifname)
+        hostname = None
+        port = 8878
     hapd_global = HostapdGlobal(hostname=hostname, port=port)
     hapd_global.remove(ifname)
 
diff --git a/tests/hwsim/test_ap_dynamic.py b/tests/hwsim/test_ap_dynamic.py
index de1c4d9..dac2d20 100644
--- a/tests/hwsim/test_ap_dynamic.py
+++ b/tests/hwsim/test_ap_dynamic.py
@@ -92,111 +92,117 @@  def _test_ap_bss_add_remove(dev, apdev):
     for i in range(3):
         dev[i].flush_scan_cache()
         dev[i].request("SCAN_INTERVAL 1")
-    ifname1 = apdev[0]['ifname']
-    ifname2 = apdev[0]['ifname'] + '-2'
-    ifname3 = apdev[0]['ifname'] + '-3'
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[0].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
+    apdev3 = apdev[0].copy()
+    apdev3['ifname'] = apdev[0]['ifname'] + '-3'
+
     logger.info("Set up three BSSes one by one")
-    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
     multi_check(dev, [ True, False, False ])
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
     multi_check(dev, [ True, True, False ])
-    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+    hostapd.add_bss('phy3', apdev3, 'bss-3.conf')
     multi_check(dev, [ True, True, True ])
 
     logger.info("Remove the last BSS and re-add it")
-    hostapd.remove_bss(ifname3)
+    hostapd.remove_bss(apdev3)
     multi_check(dev, [ True, True, False ])
-    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+    hostapd.add_bss('phy3', apdev3, 'bss-3.conf')
     multi_check(dev, [ True, True, True ])
 
     logger.info("Remove the middle BSS and re-add it")
-    hostapd.remove_bss(ifname2)
+    hostapd.remove_bss(apdev2)
     multi_check(dev, [ True, False, True ])
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
     multi_check(dev, [ True, True, True ])
 
     logger.info("Remove the first BSS and re-add it and other BSSs")
-    hostapd.remove_bss(ifname1)
+    hostapd.remove_bss(apdev1)
     multi_check(dev, [ False, False, False ])
-    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
-    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
+    hostapd.add_bss('phy3', apdev3, 'bss-3.conf')
     multi_check(dev, [ True, True, True ])
 
     logger.info("Remove two BSSes and re-add them")
-    hostapd.remove_bss(ifname2)
+    hostapd.remove_bss(apdev2)
     multi_check(dev, [ True, False, True ])
-    hostapd.remove_bss(ifname3)
+    hostapd.remove_bss(apdev3)
     multi_check(dev, [ True, False, False ])
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
     multi_check(dev, [ True, True, False ])
-    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+    hostapd.add_bss('phy3', apdev3, 'bss-3.conf')
     multi_check(dev, [ True, True, True ])
 
     logger.info("Remove three BSSes in and re-add them")
-    hostapd.remove_bss(ifname3)
+    hostapd.remove_bss(apdev3)
     multi_check(dev, [ True, True, False ])
-    hostapd.remove_bss(ifname2)
+    hostapd.remove_bss(apdev2)
     multi_check(dev, [ True, False, False ])
-    hostapd.remove_bss(ifname1)
+    hostapd.remove_bss(apdev1)
     multi_check(dev, [ False, False, False ])
-    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
     multi_check(dev, [ True, False, False ])
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
     multi_check(dev, [ True, True, False ])
-    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+    hostapd.add_bss('phy3', apdev3, 'bss-3.conf')
     multi_check(dev, [ True, True, True ])
 
     logger.info("Test error handling if a duplicate ifname is tried")
-    hostapd.add_bss('phy3', ifname3, 'bss-3.conf', ignore_error=True)
+    hostapd.add_bss('phy3', apdev3, 'bss-3.conf', ignore_error=True)
     multi_check(dev, [ True, True, True ])
 
 def test_ap_bss_add_remove_during_ht_scan(dev, apdev):
     """Dynamic BSS add during HT40 co-ex scan"""
     for i in range(3):
         dev[i].flush_scan_cache()
-    ifname1 = apdev[0]['ifname']
-    ifname2 = apdev[0]['ifname'] + '-2'
-    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
-    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[0].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
+    hostapd.add_bss('phy3', apdev1, 'bss-ht40-1.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-ht40-2.conf')
     multi_check(dev, [ True, True ], scan_opt=False)
-    hostapd.remove_bss(ifname2)
-    hostapd.remove_bss(ifname1)
+    hostapd.remove_bss(apdev2)
+    hostapd.remove_bss(apdev1)
 
-    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
-    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
-    hostapd.remove_bss(ifname2)
+    hostapd.add_bss('phy3', apdev1, 'bss-ht40-1.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-ht40-2.conf')
+    hostapd.remove_bss(apdev2)
     multi_check(dev, [ True, False ], scan_opt=False)
-    hostapd.remove_bss(ifname1)
+    hostapd.remove_bss(apdev1)
 
-    hostapd.add_bss('phy3', ifname1, 'bss-ht40-1.conf')
-    hostapd.add_bss('phy3', ifname2, 'bss-ht40-2.conf')
-    hostapd.remove_bss(ifname1)
+    hostapd.add_bss('phy3', apdev1, 'bss-ht40-1.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-ht40-2.conf')
+    hostapd.remove_bss(apdev1)
     multi_check(dev, [ False, False ])
 
 def test_ap_multi_bss_config(dev, apdev):
     """hostapd start with a multi-BSS configuration file"""
     for i in range(3):
         dev[i].flush_scan_cache()
-    ifname1 = apdev[0]['ifname']
-    ifname2 = apdev[0]['ifname'] + '-2'
-    ifname3 = apdev[0]['ifname'] + '-3'
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[0].copy()
+    apdev3 = apdev[0].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
+    apdev3['ifname'] = apdev[0]['ifname'] + '-3'
     logger.info("Set up three BSSes with one configuration file")
-    hostapd.add_iface(ifname1, 'multi-bss.conf')
-    hapd = hostapd.Hostapd(ifname1)
+    hostapd.add_iface(apdev1['ifname'], 'multi-bss.conf')
+    hapd = hostapd.Hostapd(apdev1['ifname'])
     hapd.enable()
     multi_check(dev, [ True, True, True ])
-    hostapd.remove_bss(ifname2)
+    hostapd.remove_bss(apdev2)
     multi_check(dev, [ True, False, True ])
-    hostapd.remove_bss(ifname3)
+    hostapd.remove_bss(apdev3)
     multi_check(dev, [ True, False, False ])
-    hostapd.remove_bss(ifname1)
+    hostapd.remove_bss(apdev1)
     multi_check(dev, [ False, False, False ])
 
-    hostapd.add_iface(ifname1, 'multi-bss.conf')
-    hapd = hostapd.Hostapd(ifname1)
+    hostapd.add_iface(apdev1['ifname'], 'multi-bss.conf')
+    hapd = hostapd.Hostapd(apdev1['ifname'])
     hapd.enable()
-    hostapd.remove_bss(ifname1)
+    hostapd.remove_bss(apdev1)
     multi_check(dev, [ False, False, False ])
 
 def invalid_ap(hapd_global, ifname):
@@ -348,8 +354,11 @@  def test_ap_enable_disable_reenable(dev, apdev):
 
 def test_ap_double_disable(dev, apdev):
     """Double DISABLE regression test"""
-    hostapd.add_bss('phy3', apdev[0]['ifname'], 'bss-1.conf')
-    hostapd.add_bss('phy3', apdev[0]['ifname'] + '-2', 'bss-2.conf')
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[0].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
     hapd = hostapd.Hostapd(apdev[0]['ifname'])
     hapd.disable()
     if "FAIL" not in hapd.request("DISABLE"):
@@ -377,23 +386,24 @@  def test_ap_bss_add_many(dev, apdev):
             pass
 
 def _test_ap_bss_add_many(dev, apdev):
-    ifname = apdev[0]['ifname']
+    apdev1 = apdev[0].copy()
     phy = 'phy3'
-    hostapd.add_bss(phy, ifname, 'bss-1.conf')
+    hostapd.add_bss(phy, apdev1, 'bss-1.conf')
     hapd = hostapd.HostapdGlobal()
     fname = '/tmp/hwsim-bss.conf'
     for i in range(16):
-        ifname2 = ifname + '-' + str(i)
+        apdev2 = apdev[0].copy()
+        apdev2['ifname'] = apdev[0]['ifname'] + '-' + str(i)
         with open(fname, 'w') as f:
             f.write("driver=nl80211\n")
             f.write("hw_mode=g\n")
             f.write("channel=1\n")
             f.write("ieee80211n=1\n")
-            f.write("interface=%s\n" % ifname2)
+            f.write("interface=%s\n" % apdev2['ifname'])
             f.write("bssid=02:00:00:00:03:%02x\n" % (i + 1))
             f.write("ctrl_interface=/var/run/hostapd\n")
             f.write("ssid=test-%d\n" % i)
-        hostapd.add_bss(phy, ifname2, fname)
+        hostapd.add_bss(phy, apdev2, fname)
         os.remove(fname)
 
     dev[0].request("SCAN_INTERVAL 1")
@@ -404,19 +414,20 @@  def _test_ap_bss_add_many(dev, apdev):
         dev[0].connect("test-%d" % i, key_mgmt="NONE", scan_freq="2412")
         dev[0].request("DISCONNECT")
         dev[0].wait_disconnected(timeout=5)
-        ifname2 = ifname + '-' + str(i)
+        ifname2 = apdev[0]['ifname'] + '-' + str(i)
         hapd.remove(ifname2)
 
 def test_ap_bss_add_reuse_existing(dev, apdev):
     """Dynamic BSS add operation reusing existing interface"""
-    ifname1 = apdev[0]['ifname']
-    ifname2 = apdev[0]['ifname'] + '-2'
-    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
-    subprocess.check_call(["iw", "dev", ifname1, "interface", "add", ifname2,
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[1].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
+    subprocess.check_call(["iw", "dev", apdev1['ifname'], "interface", "add", apdev2['ifname'],
                            "type", "__ap"])
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
-    hostapd.remove_bss(ifname2)
-    subprocess.check_call(["iw", "dev", ifname2, "del"])
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
+    hostapd.remove_bss(apdev2)
+    subprocess.check_call(["iw", "dev", apdev2['ifname'], "del"])
 
 def hapd_bss_out_of_mem(hapd, phy, confname, count, func):
     with alloc_fail(hapd, count, func):
@@ -429,8 +440,9 @@  def test_ap_bss_add_out_of_memory(dev, apdev):
     """Running out of memory while adding a BSS"""
     hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open" })
 
-    ifname1 = apdev[0]['ifname']
-    ifname2 = apdev[0]['ifname'] + '-2'
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[0].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
 
     hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf', 1, 'hostapd_add_iface')
     for i in range(1, 3):
@@ -439,28 +451,29 @@  def test_ap_bss_add_out_of_memory(dev, apdev):
     hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-1.conf',
                         1, 'ieee802_11_build_ap_params')
 
-    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
 
     hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf',
                         1, 'hostapd_interface_init_bss')
     hapd_bss_out_of_mem(hapd2, 'phy3', 'bss-2.conf',
                         1, 'ieee802_11_build_ap_params')
 
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
-    hostapd.remove_bss(ifname2)
-    hostapd.remove_bss(ifname1)
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
+    hostapd.remove_bss(apdev2)
+    hostapd.remove_bss(apdev1)
 
 def test_ap_multi_bss(dev, apdev):
     """Multiple BSSes with hostapd"""
-    ifname1 = apdev[0]['ifname']
-    ifname2 = apdev[0]['ifname'] + '-2'
-    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[0].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
     dev[0].connect("bss-1", key_mgmt="NONE", scan_freq="2412")
     dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")
 
-    hapd1 = hostapd.Hostapd(ifname1)
-    hapd2 = hostapd.Hostapd(ifname2)
+    hapd1 = hostapd.Hostapd(apdev1['ifname'])
+    hapd2 = hostapd.Hostapd(apdev2['ifname'])
 
     hwsim_utils.test_connectivity(dev[0], hapd1)
     hwsim_utils.test_connectivity(dev[1], hapd2)
diff --git a/tests/hwsim/test_ap_ht.py b/tests/hwsim/test_ap_ht.py
index e66f7a9..63aae42 100644
--- a/tests/hwsim/test_ap_ht.py
+++ b/tests/hwsim/test_ap_ht.py
@@ -699,12 +699,14 @@  def test_olbc(dev, apdev):
 
 def test_olbc_table_limit(dev, apdev):
     """OLBC AP table size limit"""
-    ifname1 = apdev[0]['ifname']
-    ifname2 = apdev[0]['ifname'] + '-2'
-    ifname3 = apdev[0]['ifname'] + '-3'
-    hostapd.add_bss('phy3', ifname1, 'bss-1.conf')
-    hostapd.add_bss('phy3', ifname2, 'bss-2.conf')
-    hostapd.add_bss('phy3', ifname3, 'bss-3.conf')
+    apdev1 = apdev[0].copy()
+    apdev2 = apdev[0].copy()
+    apdev3 = apdev[0].copy()
+    apdev2['ifname'] = apdev[0]['ifname'] + '-2'
+    apdev3['ifname'] = apdev[0]['ifname'] + '-3'
+    hostapd.add_bss('phy3', apdev1, 'bss-1.conf')
+    hostapd.add_bss('phy3', apdev2, 'bss-2.conf')
+    hostapd.add_bss('phy3', apdev3, 'bss-3.conf')
 
     params = { "ssid": "test-olbc",
                "channel": "1",
diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py
index ed1de58..712c7de 100644
--- a/tests/hwsim/test_ap_wps.py
+++ b/tests/hwsim/test_ap_wps.py
@@ -2287,7 +2287,7 @@  def test_ap_wps_auto_setup_with_config_file(dev, apdev):
             f.write("ssid=wps\n")
             f.write("eap_server=1\n")
             f.write("wps_state=1\n")
-        hostapd.add_bss('phy3', ifname, conffile)
+        hostapd.add_bss('phy3', apdev[0], conffile)
         hapd = hostapd.Hostapd(ifname)
         hapd.request("WPS_PBC")
         dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
diff --git a/tests/hwsim/test_monitor_interface.py b/tests/hwsim/test_monitor_interface.py
index 435afa7..a07668b 100644
--- a/tests/hwsim/test_monitor_interface.py
+++ b/tests/hwsim/test_monitor_interface.py
@@ -46,7 +46,7 @@  def test_monitor_iface_multi_bss(dev, apdev):
     """AP mode mmonitor interface with hostapd multi-BSS setup"""
     params = { "ssid": "monitor-iface", "driver_params": "use_monitor=1" }
     hapd = hostapd.add_ap(apdev[0], params)
-    hostapd.add_bss('phy3', apdev[0]['ifname'] + '-2', 'bss-2.conf')
+    hostapd.add_bss('phy3', apdev[0] + '-2', 'bss-2.conf')
     dev[0].connect("monitor-iface", key_mgmt="NONE", scan_freq="2412")
     dev[1].connect("bss-2", key_mgmt="NONE", scan_freq="2412")