Signed-off-by: Masashi Honma <masashi.honma@xxxxxxxxx> --- tests/hwsim/test_wmediumd.py | 119 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/tests/hwsim/test_wmediumd.py b/tests/hwsim/test_wmediumd.py index a3e475b..a02fa9b 100644 --- a/tests/hwsim/test_wmediumd.py +++ b/tests/hwsim/test_wmediumd.py @@ -6,6 +6,7 @@ import tempfile, os, subprocess, errno, hwsim_utils from utils import HwsimSkip +from wpasupplicant import WpaSupplicant from test_ap_open import _test_ap_open from test_wpas_mesh import check_mesh_support, check_mesh_group_added from test_wpas_mesh import check_mesh_peer_connected, add_open_mesh_network @@ -37,6 +38,30 @@ ifaces : }; """ +CFG3 = """ +ifaces : +{ + ids = ["%s", "%s", "%s", "%s", "%s" ]; +}; + +model : +{ + type = "path_loss"; + positions = ( + ( 0.0, 0.0), + ( 50.0, 0.0), + (100.0, 0.0), + (150.0, 0.0), + (200.0, 0.0) + ); + tx_powers = (15.0, 15.0, 15.0, 15.0, 15.0); + + model_name = "log_distance"; + path_loss_exp = 3.5; + xg = 0.0; +}; +""" + def check_wmediumd_version(): if LocalVariables.is_old_wmediumd != None: if LocalVariables.is_old_wmediumd: @@ -194,3 +219,97 @@ def _test_wmediumd_path_simple(dev, apdev): dev[i].mesh_group_remove() check_mesh_group_removed(dev[i]) dev[i].dump_monitor() + +def test_wmediumd_path_ttl(dev, apdev, params): + """test a mesh path request TTL""" + # 0 --- 1 --- 2 --- 3 --- 4 + # Test the ttl of mesh path request. + # If the ttl is shorter than path, the mesh path request should be dropped. + check_wmediumd_version() + + local_dev = [] + local_dev.append(dev[0]) + local_dev.append(dev[1]) + local_dev.append(dev[2]) + + for i in range(5, 7): + wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') + wpas.interface_add("wlan" + str(i)) + check_mesh_support(wpas) + temp_dev = wpas.request("MESH_INTERFACE_ADD ifname=mesh" + str(i)) + if "FAIL" in temp_dev: + raise Exception("MESH_INTERFACE_ADD failed") + local_dev.append(WpaSupplicant(ifname=temp_dev)) + + fd, fn = tempfile.mkstemp() + try: + f = os.fdopen(fd, 'w') + f.write(CFG3 % (local_dev[0].own_addr(), local_dev[1].own_addr(), + local_dev[2].own_addr(), local_dev[3].own_addr(), + local_dev[4].own_addr())) + f.close() + p = start_wmediumd(fn, params) + try: + _test_wmediumd_path_ttl(local_dev, True) + _test_wmediumd_path_ttl(local_dev, False) + finally: + stop_wmediumd(p, params) + finally: + os.unlink(fn) + + for i in range(5, 7): + wpas.interface_remove("wlan" + str(i)) + wpas.interface_remove("wlan" + str(i)) + +def _test_wmediumd_path_ttl(dev, ok): + for i in range(0, 5): + check_mesh_support(dev[i]) + add_open_mesh_network(dev[i], freq="2462", basic_rates="60 120 240") + + # Check for mesh joined + for i in range(0, 5): + check_mesh_group_added(dev[i]) + + state = dev[i].get_status_field("wpa_state") + if state != "COMPLETED": + raise Exception("Unexpected wpa_state on dev" + str(i) + ": " + state) + + mode = dev[i].get_status_field("mode") + if mode != "mesh": + raise Exception("Unexpected mode: " + mode) + + # set mesh path request ttl + subprocess.check_call(["iw", "dev", dev[0].ifname, "set", "mesh_param", + "mesh_element_ttl=" + ("4" if ok else "3")]) + + # Check for peer connected + for i in range(0, 5): + check_mesh_peer_connected(dev[i]) + for i in range(1, 4): + check_mesh_peer_connected(dev[i]) + + # Test connectivity 0->4 and 0->4 + hwsim_utils.test_connectivity(dev[0], dev[4], success_expected=ok) + + # Check mpath table on 0 + res, data = dev[0].cmd_execute(['iw', dev[0].ifname, 'mpath', 'dump']) + if res != 0: + raise Exception("iw command failed on dev0") + if ok: + if data.find(dev[1].own_addr() + ' ' + dev[1].own_addr()) == -1 or \ + data.find(dev[4].own_addr() + ' ' + dev[1].own_addr()) == -1: + raise Exception("mpath not found on dev0:\n" + data) + else: + if data.find(dev[1].own_addr() + ' ' + dev[1].own_addr()) == -1 or \ + data.find(dev[4].own_addr() + ' 00:00:00:00:00:00') == -1: + raise Exception("mpath not found on dev0:\n" + data) + if data.find(dev[0].own_addr()) > -1 or \ + data.find(dev[2].own_addr()) > -1 or \ + data.find(dev[3].own_addr()) > -1: + raise Exception("invalid mpath found on dev0:\n" + data) + + # remove mesh groups + for i in range(0, 3): + dev[i].mesh_group_remove() + check_mesh_group_removed(dev[i]) + dev[i].dump_monitor() -- 2.7.4 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap