1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """IPsec utilities library."""
17 from ipaddress import ip_network, ip_address
21 from resources.libraries.python.VatExecutor import VatExecutor
22 from resources.libraries.python.topology import Topology
23 from resources.libraries.python.VatJsonUtil import VatJsonUtil
26 class PolicyAction(Enum):
32 def __init__(self, string):
36 class CryptoAlg(Enum):
37 """Encryption algorithms."""
38 AES_CBC_128 = ('aes-cbc-128', 'AES-CBC', 16)
39 AES_CBC_192 = ('aes-cbc-192', 'AES-CBC', 24)
40 AES_CBC_256 = ('aes-cbc-256', 'AES-CBC', 32)
41 AES_GCM_128 = ('aes-gcm-128', 'AES-GCM', 20)
43 def __init__(self, alg_name, scapy_name, key_len):
44 self.alg_name = alg_name
45 self.scapy_name = scapy_name
46 self.key_len = key_len
50 """Integrity algorithm."""
51 SHA1_96 = ('sha1-96', 'HMAC-SHA1-96', 20)
52 SHA_256_128 = ('sha-256-128', 'SHA2-256-128', 32)
53 SHA_384_192 = ('sha-384-192', 'SHA2-384-192', 48)
54 SHA_512_256 = ('sha-512-256', 'SHA2-512-256', 64)
55 AES_GCM_128 = ('aes-gcm-128', 'AES-GCM', 20)
57 def __init__(self, alg_name, scapy_name, key_len):
58 self.alg_name = alg_name
59 self.scapy_name = scapy_name
60 self.key_len = key_len
63 class IPsecUtil(object):
64 """IPsec utilities."""
67 def policy_action_bypass():
68 """Return policy action bypass.
70 :returns: PolicyAction enum BYPASS object.
73 return PolicyAction.BYPASS
76 def policy_action_discard():
77 """Return policy action discard.
79 :returns: PolicyAction enum DISCARD object.
82 return PolicyAction.DISCARD
85 def policy_action_protect():
86 """Return policy action protect.
88 :returns: PolicyAction enum PROTECT object.
91 return PolicyAction.PROTECT
94 def crypto_alg_aes_cbc_128():
95 """Return encryption algorithm aes-cbc-128.
97 :returns: CryptoAlg enum AES_CBC_128 object.
100 return CryptoAlg.AES_CBC_128
103 def crypto_alg_aes_cbc_192():
104 """Return encryption algorithm aes-cbc-192.
106 :returns: CryptoAlg enum AES_CBC_192 objec.
109 return CryptoAlg.AES_CBC_192
112 def crypto_alg_aes_cbc_256():
113 """Return encryption algorithm aes-cbc-256.
115 :returns: CryptoAlg enum AES_CBC_256 object.
118 return CryptoAlg.AES_CBC_256
121 def crypto_alg_aes_gcm_128():
122 """Return encryption algorithm aes-gcm-128.
124 :returns: CryptoAlg enum AES_GCM_128 object.
127 return CryptoAlg.AES_GCM_128
130 def get_crypto_alg_key_len(crypto_alg):
131 """Return encryption algorithm key length.
133 :param crypto_alg: Encryption algorithm.
134 :type crypto_alg: CryptoAlg
135 :returns: Key length.
138 return crypto_alg.key_len
141 def get_crypto_alg_scapy_name(crypto_alg):
142 """Return encryption algorithm scapy name.
144 :param crypto_alg: Encryption algorithm.
145 :type crypto_alg: CryptoAlg
146 :returns: Algorithm scapy name.
149 return crypto_alg.scapy_name
152 def integ_alg_sha1_96():
153 """Return integrity algorithm SHA1-96.
155 :returns: IntegAlg enum SHA1_96 object.
158 return IntegAlg.SHA1_96
161 def integ_alg_sha_256_128():
162 """Return integrity algorithm SHA-256-128.
164 :returns: IntegAlg enum SHA_256_128 object.
167 return IntegAlg.SHA_256_128
170 def integ_alg_sha_384_192():
171 """Return integrity algorithm SHA-384-192.
173 :returns: IntegAlg enum SHA_384_192 object.
176 return IntegAlg.SHA_384_192
179 def integ_alg_sha_512_256():
180 """Return integrity algorithm SHA-512-256.
182 :returns: IntegAlg enum SHA_512_256 object.
185 return IntegAlg.SHA_512_256
188 def integ_alg_aes_gcm_128():
189 """Return integrity algorithm AES-GCM-128.
191 :returns: IntegAlg enum AES_GCM_128 object.
194 return IntegAlg.AES_GCM_128
197 def get_integ_alg_key_len(integ_alg):
198 """Return integrity algorithm key length.
200 :param integ_alg: Integrity algorithm.
201 :type integ_alg: IntegAlg
202 :returns: Key length.
205 return integ_alg.key_len
208 def get_integ_alg_scapy_name(integ_alg):
209 """Return integrity algorithm scapy name.
211 :param integ_alg: Integrity algorithm.
212 :type integ_alg: IntegAlg
213 :returns: Algorithm scapy name.
216 return integ_alg.scapy_name
219 def vpp_ipsec_add_sad_entry(node, sad_id, spi, crypto_alg, crypto_key,
220 integ_alg, integ_key, tunnel_src=None,
222 """Create Security Association Database entry on the VPP node.
224 :param node: VPP node to add SAD entry on.
225 :param sad_id: SAD entry ID.
226 :param spi: Security Parameter Index of this SAD entry.
227 :param crypto_alg: The encryption algorithm name.
228 :param crypto_key: The encryption key string.
229 :param integ_alg: The integrity algorithm name.
230 :param integ_key: The integrity key string.
231 :param tunnel_src: Tunnel header source IPv4 or IPv6 address. If not
232 specified ESP transport mode is used.
233 :param tunnel_dst: Tunnel header destination IPv4 or IPv6 address. If
234 not specified ESP transport mode is used.
238 :type crypto_alg: CryptoAlg
239 :type crypto_key: str
242 :type tunnel_src: str
243 :type tunnel_dst: str
245 ckey = crypto_key.encode('hex')
246 ikey = integ_key.encode('hex')
247 tunnel = 'tunnel_src {0} tunnel_dst {1}'.format(tunnel_src, tunnel_dst)\
248 if tunnel_src is not None and tunnel_dst is not None else ''
250 out = VatExecutor.cmd_from_template(node,
251 "ipsec/ipsec_sad_add_entry.vat",
252 sad_id=sad_id, spi=spi,
253 calg=crypto_alg.alg_name, ckey=ckey,
254 ialg=integ_alg.alg_name, ikey=ikey,
256 VatJsonUtil.verify_vat_retval(
258 err_msg='Add SAD entry failed on {0}'.format(node['host']))
261 def vpp_ipsec_add_sad_entries(node, n_entries, sad_id, spi, crypto_alg,
262 crypto_key, integ_alg, integ_key,
263 tunnel_src=None, tunnel_dst=None):
264 """Create multiple Security Association Database entries on VPP node.
266 :param node: VPP node to add SAD entry on.
267 :param n_entries: Number of SAD entries to be created.
268 :param sad_id: First SAD entry ID. All subsequent SAD entries will have
270 :param spi: Security Parameter Index of first SAD entry. All subsequent
271 SAD entries will have spi incremented by 1.
272 :param crypto_alg: The encryption algorithm name.
273 :param crypto_key: The encryption key string.
274 :param integ_alg: The integrity algorithm name.
275 :param integ_key: The integrity key string.
276 :param tunnel_src: Tunnel header source IPv4 or IPv6 address. If not
277 specified ESP transport mode is used.
278 :param tunnel_dst: Tunnel header destination IPv4 or IPv6 address. If
279 not specified ESP transport mode is used.
284 :type crypto_alg: CryptoAlg
285 :type crypto_key: str
286 :type integ_alg: IntegAlg
288 :type tunnel_src: str
289 :type tunnel_dst: str
291 tmp_filename = '/tmp/ipsec_sad_{0}_add_del_entry.script'.format(sad_id)
292 ckey = crypto_key.encode('hex')
293 ikey = integ_key.encode('hex')
294 tunnel = 'tunnel_src {0} tunnel_dst {1}'.format(tunnel_src, tunnel_dst)\
295 if tunnel_src is not None and tunnel_dst is not None else ''
297 integ = 'integ_alg {0} integ_key {1}'.format(integ_alg.alg_name, ikey)\
298 if crypto_alg.alg_name != 'aes-gcm-128' else ''
300 with open(tmp_filename, 'w') as tmp_file:
301 for i in range(0, n_entries):
302 buf_str = 'ipsec_sad_add_del_entry esp sad_id {0} spi {1} ' \
303 'crypto_alg {2} crypto_key {3} {4} {5}\n'.format(
304 sad_id+i, spi+i, crypto_alg.alg_name, ckey, integ,
306 tmp_file.write(buf_str)
308 vat.execute_script(tmp_filename, node, timeout=300, json_out=False,
309 copy_on_execute=True)
310 os.remove(tmp_filename)
313 def vpp_ipsec_sa_set_key(node, sa_id, crypto_key, integ_key):
314 """Update Security Association (SA) keys.
316 :param node: VPP node to update SA keys.
317 :param sa_id: SAD entry ID.
318 :param crypto_key: The encryption key string.
319 :param integ_key: The integrity key string.
322 :type crypto_key: str
325 ckey = crypto_key.encode('hex')
326 ikey = integ_key.encode('hex')
328 out = VatExecutor.cmd_from_template(node,
329 "ipsec/ipsec_sa_set_key.vat",
331 ckey=ckey, ikey=ikey)
332 VatJsonUtil.verify_vat_retval(
334 err_msg='Update SA key failed on {0}'.format(node['host']))
337 def vpp_ipsec_add_spd(node, spd_id):
338 """Create Security Policy Database on the VPP node.
340 :param node: VPP node to add SPD on.
341 :param spd_id: SPD ID.
345 out = VatExecutor.cmd_from_template(node, "ipsec/ipsec_spd_add.vat",
347 VatJsonUtil.verify_vat_retval(
349 err_msg='Add SPD {0} failed on {1}'.format(spd_id, node['host']))
352 def vpp_ipsec_spd_add_if(node, spd_id, interface):
353 """Add interface to the Security Policy Database.
355 :param node: VPP node.
356 :param spd_id: SPD ID to add interface on.
357 :param interface: Interface name or sw_if_index.
360 :type interface: str or int
362 sw_if_index = Topology.get_interface_sw_index(node, interface)\
363 if isinstance(interface, basestring) else interface
365 out = VatExecutor.cmd_from_template(node,
366 "ipsec/ipsec_interface_add_spd.vat",
367 spd_id=spd_id, sw_if_id=sw_if_index)
368 VatJsonUtil.verify_vat_retval(
370 err_msg='Add interface {0} to SPD {1} failed on {2}'.format(
371 interface, spd_id, node['host']))
374 def vpp_ipsec_spd_add_entry(node, spd_id, priority, action, inbound=True,
375 sa_id=None, laddr_range=None, raddr_range=None,
376 proto=None, lport_range=None, rport_range=None):
377 """Create Security Policy Database entry on the VPP node.
379 :param node: VPP node to add SPD entry on.
380 :param spd_id: SPD ID to add entry on.
381 :param priority: SPD entry priority, higher number = higher priority.
382 :param action: Policy action.
383 :param inbound: If True policy is for inbound traffic, otherwise
385 :param sa_id: SAD entry ID for protect action.
386 :param laddr_range: Policy selector local IPv4 or IPv6 address range in
387 format IP/prefix or IP/mask. If no mask is provided, it's considered
389 :param raddr_range: Policy selector remote IPv4 or IPv6 address range in
390 format IP/prefix or IP/mask. If no mask is provided, it's considered
392 :param proto: Policy selector next layer protocol number.
393 :param lport_range: Policy selector local TCP/UDP port range in format
394 <port_start>-<port_end>.
395 :param rport_range: Policy selector remote TCP/UDP port range in format
396 <port_start>-<port_end>.
400 :type action: PolicyAction
403 :type laddr_range: string
404 :type raddr_range: string
406 :type lport_range: string
407 :type rport_range: string
409 direction = 'inbound' if inbound else 'outbound'
411 act_str = action.value
412 if PolicyAction.PROTECT == action and sa_id is not None:
413 act_str += 'sa_id {0}'.format(sa_id)
416 if laddr_range is not None:
417 net = ip_network(unicode(laddr_range), strict=False)
418 selector += 'laddr_start {0} laddr_stop {1} '.format(
419 net.network_address, net.broadcast_address)
420 if raddr_range is not None:
421 net = ip_network(unicode(raddr_range), strict=False)
422 selector += 'raddr_start {0} raddr_stop {1} '.format(
423 net.network_address, net.broadcast_address)
424 if proto is not None:
425 selector += 'protocol {0} '.format(proto)
426 if lport_range is not None:
427 selector += 'lport_start {p[0]} lport_stop {p[1]} '.format(
428 p=lport_range.split('-'))
429 if rport_range is not None:
430 selector += 'rport_start {p[0]} rport_stop {p[1]} '.format(
431 p=rport_range.split('-'))
433 out = VatExecutor.cmd_from_template(node,
434 "ipsec/ipsec_spd_add_entry.vat",
435 spd_id=spd_id, priority=priority,
436 action=act_str, direction=direction,
438 VatJsonUtil.verify_vat_retval(
440 err_msg='Add entry to SPD {0} failed on {1}'.format(spd_id,
444 def vpp_ipsec_spd_add_entries(node, n_entries, spd_id, priority, inbound,
445 sa_id, raddr_ip, raddr_range):
446 """Create multiple Security Policy Database entries on the VPP node.
448 :param node: VPP node to add SPD entries on.
449 :param n_entries: Number of SPD entries to be added.
450 :param spd_id: SPD ID to add entries on.
451 :param priority: SPD entries priority, higher number = higher priority.
452 :param inbound: If True policy is for inbound traffic, otherwise
454 :param sa_id: SAD entry ID for first entry. Each subsequent entry will
455 SAD entry ID incremented by 1.
456 :param raddr_ip: Policy selector remote IPv4 start address for the first
457 entry. Remote IPv4 end address will be calculated depending on
458 raddr_range parameter. Each subsequent entry will have start address
459 next after IPv4 end address of previous entry.
460 :param raddr_range: Mask specifying range of Policy selector Remote IPv4
461 addresses. Valid values are from 1 to 32.
468 :type raddr_ip: string
469 :type raddr_range: int
471 tmp_filename = '/tmp/ipsec_spd_{0}_add_del_entry.script'.format(sa_id)
473 direction = 'inbound' if inbound else 'outbound'
474 addr_incr = 1 << (32 - raddr_range)
475 addr_ip = int(ip_address(unicode(raddr_ip)))
476 start_str = 'ipsec_spd_add_del_entry spd_id {0} priority {1} {2} ' \
477 'action protect sa_id'.format(spd_id, priority, direction)
478 with open(tmp_filename, 'w') as tmp_file:
479 for i in range(0, n_entries):
480 r_ip_s = ip_address(addr_ip + addr_incr * i)
481 r_ip_e = ip_address(addr_ip + addr_incr * (i+1) - 1)
482 buf_str = '{0} {1} raddr_start {2} raddr_stop {3}\n'.format(
483 start_str, sa_id+i, r_ip_s, r_ip_e)
484 tmp_file.write(buf_str)
486 vat.execute_script(tmp_filename, node, timeout=300, json_out=False,
487 copy_on_execute=True)
488 os.remove(tmp_filename)
491 def vpp_ipsec_create_tunnel_interfaces(node1, node2, if1_ip_addr,
492 if2_ip_addr, if1_key, if2_key,
493 n_tunnels, crypto_alg, crypto_key,
494 integ_alg, integ_key, raddr_ip1,
495 raddr_ip2, raddr_range):
496 """Create multiple IPsec tunnel interfaces between two VPP nodes.
498 :param node1: VPP node 1 to create tunnel interfaces.
499 :param node2: VPP node 2 to create tunnel interfaces.
500 :param if1_ip_addr: VPP node 1 interface IP4 address.
501 :param if2_ip_addr: VPP node 2 interface IP4 address.
502 :param if1_key: VPP node 1 interface key from topology file.
503 :param if2_key: VPP node 2 interface key from topology file.
504 :param n_tunnels: Number of tunnell interfaces to create.
505 :param crypto_alg: The encryption algorithm name.
506 :param crypto_key: The encryption key string.
507 :param integ_alg: The integrity algorithm name.
508 :param integ_key: The integrity key string.
509 :param raddr_ip1: Policy selector remote IPv4 start address for the
510 first tunnel in direction node1->node2.
511 :param raddr_ip2: Policy selector remote IPv4 start address for the
512 first tunnel in direction node2->node1.
513 :param raddr_range: Mask specifying range of Policy selector Remote IPv4
514 addresses. Valid values are from 1 to 32.
517 :type if1_ip_addr: str
518 :type if2_ip_addr: str
522 :type crypto_alg: CryptoAlg
523 :type crypto_key: str
524 :type integ_alg: IntegAlg
526 :type raddr_ip1: string
527 :type raddr_ip2: string
528 :type raddr_range: int
533 raddr_ip1_i = int(ip_address(unicode(raddr_ip1)))
534 raddr_ip2_i = int(ip_address(unicode(raddr_ip2)))
535 addr_incr = 1 << (32 - raddr_range)
537 tmp_fn1 = '/tmp/ipsec_create_tunnel_dut1.config'
538 tmp_fn2 = '/tmp/ipsec_create_tunnel_dut2.config'
540 ckey = crypto_key.encode('hex')
541 ikey = integ_key.encode('hex')
544 with open(tmp_fn1, 'w') as tmp_f1, open(tmp_fn2, 'w') as tmp_f2:
545 for i in range(0, n_tunnels):
547 if crypto_alg.alg_name != 'aes-gcm-128':
548 integ = 'integ_alg {integ_alg} '\
549 'local_integ_key {local_integ_key} '\
550 'remote_integ_key {remote_integ_key} '\
551 .format(integ_alg=integ_alg.alg_name,
552 local_integ_key=ikey,
553 remote_integ_key=ikey)
554 dut1_tunnel = 'ipsec_tunnel_if_add_del '\
555 'local_spi {local_spi} '\
556 'remote_spi {remote_spi} '\
557 'crypto_alg {crypto_alg} '\
558 'local_crypto_key {local_crypto_key} '\
559 'remote_crypto_key {remote_crypto_key} '\
561 'local_ip {local_ip} '\
562 'remote_ip {remote_ip}\n'\
563 .format(local_spi=spi_1+i,
565 crypto_alg=crypto_alg.alg_name,
566 local_crypto_key=ckey,
567 remote_crypto_key=ckey,
569 local_ip=if1_ip_addr,
570 remote_ip=if2_ip_addr)
571 dut2_tunnel = 'ipsec_tunnel_if_add_del '\
572 'local_spi {local_spi} '\
573 'remote_spi {remote_spi} '\
574 'crypto_alg {crypto_alg} '\
575 'local_crypto_key {local_crypto_key} '\
576 'remote_crypto_key {remote_crypto_key} '\
578 'local_ip {local_ip} '\
579 'remote_ip {remote_ip}\n'\
580 .format(local_spi=spi_2+i,
582 crypto_alg=crypto_alg.alg_name,
583 local_crypto_key=ckey,
584 remote_crypto_key=ckey,
586 local_ip=if2_ip_addr,
587 remote_ip=if1_ip_addr)
588 tmp_f1.write(dut1_tunnel)
589 tmp_f2.write(dut2_tunnel)
590 vat.execute_script(tmp_fn1, node1, timeout=300, json_out=False,
591 copy_on_execute=True)
592 vat.execute_script(tmp_fn2, node2, timeout=300, json_out=False,
593 copy_on_execute=True)
597 with open(tmp_fn1, 'w') as tmp_f1, open(tmp_fn2, 'w') as tmp_f2:
598 for i in range(0, n_tunnels):
599 raddr_ip1 = ip_address(raddr_ip1_i + addr_incr*i)
600 raddr_ip2 = ip_address(raddr_ip2_i + addr_incr*i)
601 dut1_if = Topology.get_interface_name(node1, if1_key)
602 dut1 = 'ip_add_del_route {raddr}/{mask} via {addr} ipsec{i}\n'\
603 'exec set interface unnumbered ipsec{i} use {uifc}\n'\
604 'sw_interface_set_flags ipsec{i} admin-up\n'\
605 .format(raddr=raddr_ip2, mask=raddr_range,
606 addr=if2_ip_addr, i=i, uifc=dut1_if)
607 dut2_if = Topology.get_interface_name(node2, if2_key)
608 dut2 = 'ip_add_del_route {raddr}/{mask} via {addr} ipsec{i}\n'\
609 'exec set interface unnumbered ipsec{i} use {uifc}\n'\
610 'sw_interface_set_flags ipsec{i} admin-up\n'\
611 .format(raddr=raddr_ip1, mask=raddr_range,
612 addr=if1_ip_addr, i=i, uifc=dut2_if)
616 vat.execute_script(tmp_fn1, node1, timeout=300, json_out=False,
617 copy_on_execute=True)
618 vat.execute_script(tmp_fn2, node2, timeout=300, json_out=False,
619 copy_on_execute=True)
624 def vpp_ipsec_add_multiple_tunnels(node1, node2, interface1, interface2,
625 n_tunnels, crypto_alg, crypto_key,
626 integ_alg, integ_key, tunnel_ip1,
627 tunnel_ip2, raddr_ip1, raddr_ip2,
629 """Create multiple IPsec tunnels between two VPP nodes.
631 :param node1: VPP node 1 to create tunnels.
632 :param node2: VPP node 2 to create tunnels.
633 :param interface1: Interface name or sw_if_index on node 1.
634 :param interface2: Interface name or sw_if_index on node 2.
635 :param n_tunnels: Number of tunnels to create.
636 :param crypto_alg: The encryption algorithm name.
637 :param crypto_key: The encryption key string.
638 :param integ_alg: The integrity algorithm name.
639 :param integ_key: The integrity key string.
640 :param tunnel_ip1: Tunnel node1 IPv4 address.
641 :param tunnel_ip2: Tunnel node2 IPv4 address.
642 :param raddr_ip1: Policy selector remote IPv4 start address for the
643 first tunnel in direction node1->node2.
644 :param raddr_ip2: Policy selector remote IPv4 start address for the
645 first tunnel in direction node2->node1.
646 :param raddr_range: Mask specifying range of Policy selector Remote IPv4
647 addresses. Valid values are from 1 to 32.
650 :type interface1: str or int
651 :type interface2: str or int
653 :type crypto_alg: CryptoAlg
654 :type crypto_key: str
657 :type tunnel_ip1: str
658 :type tunnel_ip2: str
659 :type raddr_ip1: string
660 :type raddr_ip2: string
661 :type raddr_range: int
672 IPsecUtil.vpp_ipsec_add_spd(node1, spd_id)
673 IPsecUtil.vpp_ipsec_spd_add_if(node1, spd_id, interface1)
674 IPsecUtil.vpp_ipsec_spd_add_entry(node1, spd_id, p_hi,
675 PolicyAction.BYPASS, inbound=False,
677 IPsecUtil.vpp_ipsec_spd_add_entry(node1, spd_id, p_hi,
678 PolicyAction.BYPASS, inbound=True,
681 IPsecUtil.vpp_ipsec_add_spd(node2, spd_id)
682 IPsecUtil.vpp_ipsec_spd_add_if(node2, spd_id, interface2)
683 IPsecUtil.vpp_ipsec_spd_add_entry(node2, spd_id, p_hi,
684 PolicyAction.BYPASS, inbound=False,
686 IPsecUtil.vpp_ipsec_spd_add_entry(node2, spd_id, p_hi,
687 PolicyAction.BYPASS, inbound=True,
690 IPsecUtil.vpp_ipsec_add_sad_entries(node1, n_tunnels, sa_id_1, spi_1,
691 crypto_alg, crypto_key, integ_alg,
692 integ_key, tunnel_ip1, tunnel_ip2)
694 IPsecUtil.vpp_ipsec_spd_add_entries(node1, n_tunnels, spd_id, p_lo,
695 False, sa_id_1, raddr_ip2,
698 IPsecUtil.vpp_ipsec_add_sad_entries(node2, n_tunnels, sa_id_1, spi_1,
699 crypto_alg, crypto_key, integ_alg,
700 integ_key, tunnel_ip1, tunnel_ip2)
702 IPsecUtil.vpp_ipsec_spd_add_entries(node2, n_tunnels, spd_id, p_lo,
703 True, sa_id_1, raddr_ip2,
706 IPsecUtil.vpp_ipsec_add_sad_entries(node2, n_tunnels, sa_id_2, spi_2,
707 crypto_alg, crypto_key, integ_alg,
708 integ_key, tunnel_ip2, tunnel_ip1)
710 IPsecUtil.vpp_ipsec_spd_add_entries(node2, n_tunnels, spd_id, p_lo,
711 False, sa_id_2, raddr_ip1,
714 IPsecUtil.vpp_ipsec_add_sad_entries(node1, n_tunnels, sa_id_2, spi_2,
715 crypto_alg, crypto_key, integ_alg,
716 integ_key, tunnel_ip2, tunnel_ip1)
718 IPsecUtil.vpp_ipsec_spd_add_entries(node1, n_tunnels, spd_id, p_lo,
719 True, sa_id_2, raddr_ip1,
723 def vpp_ipsec_show(node):
724 """Run "show ipsec" debug CLI command.
726 :param node: Node to run command on.
729 VatExecutor().execute_script("ipsec/ipsec_show.vat", node,