X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FIPsecUtil.py;h=123043828dd055c3212b7c279fa603f4f241bba8;hp=3346da2526a7bffcb5522f631bb679f6e66ec820;hb=d5a0c7319ac12bbf56cfae8d9c6778bb2834f7dd;hpb=533fcfe3d177447aee7a3dca5f0d7a5f06d70377 diff --git a/resources/libraries/python/IPsecUtil.py b/resources/libraries/python/IPsecUtil.py index 3346da2526..123043828d 100644 --- a/resources/libraries/python/IPsecUtil.py +++ b/resources/libraries/python/IPsecUtil.py @@ -661,6 +661,18 @@ class IPsecUtil(object): vat = VatExecutor() with open(tmp_fn1, 'w') as tmp_f1, open(tmp_fn2, 'w') as tmp_f2: + tmp_f1.write( + 'exec create loopback interface\n' + 'exec set interface state loop0 up\n' + 'exec set interface ip address {uifc} {iaddr}/24\n' + .format( + iaddr=ip_address(unicode(if2_ip_addr)) - 1, + uifc=Topology.get_interface_name(nodes['DUT1'], if1_key))) + tmp_f2.write( + 'exec set interface ip address {uifc} {iaddr}/24\n' + .format( + iaddr=ip_address(unicode(if2_ip_addr)), + uifc=Topology.get_interface_name(nodes['DUT2'], if2_key))) for i in range(0, n_tunnels): ckey = gen_key(IPsecUtil.get_crypto_alg_key_len(crypto_alg)) ikey = gen_key(IPsecUtil.get_integ_alg_key_len(integ_alg)) @@ -675,7 +687,7 @@ class IPsecUtil(object): local_integ_key=ikey, remote_integ_key=ikey)) tmp_f1.write( - 'exec set interface ip address {uifc} {laddr}/24\n' + 'exec set interface ip address loop0 {laddr}/32\n' 'ipsec_tunnel_if_add_del ' 'local_spi {local_spi} ' 'remote_spi {remote_spi} ' @@ -693,11 +705,10 @@ class IPsecUtil(object): remote_crypto_key=ckey, integ=integ, laddr=ip_address(unicode(if1_ip_addr)) + i * addr_incr, - raddr=ip_address(unicode(if2_ip_addr)) + i * addr_incr, + raddr=ip_address(unicode(if2_ip_addr)), uifc=Topology.get_interface_name(nodes['DUT1'], if1_key))) tmp_f2.write( - 'exec set interface ip address {uifc} {laddr}/24\n' 'ipsec_tunnel_if_add_del ' 'local_spi {local_spi} ' 'remote_spi {remote_spi} ' @@ -714,42 +725,44 @@ class IPsecUtil(object): local_crypto_key=ckey, remote_crypto_key=ckey, integ=integ, - laddr=ip_address(unicode(if2_ip_addr)) + i * addr_incr, - raddr=ip_address(unicode(if1_ip_addr)) + i * addr_incr, - uifc=Topology.get_interface_name(nodes['DUT2'], - if2_key))) - vat.execute_script(tmp_fn1, nodes['DUT1'], timeout=300, json_out=False, + laddr=ip_address(unicode(if2_ip_addr)), + raddr=ip_address(unicode(if1_ip_addr)) + i * addr_incr)) + vat.execute_script(tmp_fn1, nodes['DUT1'], timeout=1800, json_out=False, copy_on_execute=True) - vat.execute_script(tmp_fn2, nodes['DUT2'], timeout=300, json_out=False, + vat.execute_script(tmp_fn2, nodes['DUT2'], timeout=1800, json_out=False, copy_on_execute=True) os.remove(tmp_fn1) os.remove(tmp_fn2) with open(tmp_fn1, 'w') as tmp_f1, open(tmp_fn2, 'w') as tmp_f2: + tmp_f2.write( + 'exec ip route add {raddr} via {uifc} {iaddr}\n' + .format( + raddr=ip_network(unicode(if1_ip_addr+'/8'), False), + iaddr=ip_address(unicode(if2_ip_addr)) - 1, + uifc=Topology.get_interface_name(nodes['DUT2'], if2_key))) for i in range(0, n_tunnels): tmp_f1.write( 'exec set interface unnumbered ipsec{i} use {uifc}\n' 'exec set interface state ipsec{i} up\n' - 'exec ip route add {taddr}/32 via {raddr} ipsec{i}\n' + 'exec ip route add {taddr}/32 via ipsec{i}\n' .format( taddr=ip_address(unicode(raddr_ip2)) + i, - raddr=ip_address(unicode(if2_ip_addr)) + i * addr_incr, i=i, uifc=Topology.get_interface_name(nodes['DUT1'], if1_key))) tmp_f2.write( 'exec set interface unnumbered ipsec{i} use {uifc}\n' 'exec set interface state ipsec{i} up\n' - 'exec ip route add {taddr}/32 via {raddr} ipsec{i}\n' + 'exec ip route add {taddr}/32 via ipsec{i}\n' .format( taddr=ip_address(unicode(raddr_ip1)) + i, - raddr=ip_address(unicode(if1_ip_addr)) + i * addr_incr, i=i, uifc=Topology.get_interface_name(nodes['DUT2'], if2_key))) - vat.execute_script(tmp_fn1, nodes['DUT1'], timeout=300, json_out=False, + vat.execute_script(tmp_fn1, nodes['DUT1'], timeout=1800, json_out=False, copy_on_execute=True) - vat.execute_script(tmp_fn2, nodes['DUT2'], timeout=300, json_out=False, + vat.execute_script(tmp_fn2, nodes['DUT2'], timeout=1800, json_out=False, copy_on_execute=True) os.remove(tmp_fn1) os.remove(tmp_fn2)