X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_ipsec.py;h=0df8cb2a88acbe1133b8be26288647dc4d0bc249;hb=6c92f5babdc3c52cf343509fc9cf9d8a9a3df390;hp=5866a0bb72d55038c91aa4b1fed3ac0cd20cf8ac;hpb=8feeaff56fa9a4fbdfc06131f28a1060ffd9645d;p=vpp.git diff --git a/test/vpp_ipsec.py b/test/vpp_ipsec.py index 5866a0bb72d..0df8cb2a88a 100644 --- a/test/vpp_ipsec.py +++ b/test/vpp_ipsec.py @@ -24,9 +24,6 @@ class VppIpsecSpd(VppObject): def remove_vpp_config(self): self.test.vapi.ipsec_spd_add_del(self.id, is_add=0) - def __str__(self): - return self.object_id() - def object_id(self): return "ipsec-spd-%d" % self.id @@ -59,9 +56,6 @@ class VppIpsecSpdItfBinding(VppObject): self.itf.sw_if_index, is_add=0) - def __str__(self): - return self.object_id() - def object_id(self): return "bind-%s-to-%s" % (self.spd.id, self.itf) @@ -149,9 +143,6 @@ class VppIpsecSpdEntry(VppObject): remote_port_stop=self.remote_port_stop, is_add=0) - def __str__(self): - return self.object_id() - def object_id(self): return "spd-entry-%d-%d-%d-%d-%d-%d" % (self.spd.id, self.priority, @@ -187,7 +178,7 @@ class VppIpsecSA(VppObject): crypto_alg, crypto_key, proto, tun_src=None, tun_dst=None, - flags=None): + flags=None, salt=0): e = VppEnum.vl_api_ipsec_sad_flags_t self.test = test self.id = id @@ -197,6 +188,7 @@ class VppIpsecSA(VppObject): self.crypto_alg = crypto_alg self.crypto_key = crypto_key self.proto = proto + self.salt = salt self.tun_src = tun_src self.tun_dst = tun_dst @@ -223,7 +215,8 @@ class VppIpsecSA(VppObject): self.proto, (self.tun_src if self.tun_src else []), (self.tun_dst if self.tun_dst else []), - flags=self.flags) + flags=self.flags, + salt=self.salt) self.stat_index = r.stat_index self.test.registry.register(self, self.test.logger) @@ -241,9 +234,6 @@ class VppIpsecSA(VppObject): flags=self.flags, is_add=0) - def __str__(self): - return self.object_id() - def object_id(self): return "ipsec-sa-%d" % self.id @@ -257,3 +247,53 @@ class VppIpsecSA(VppObject): def get_stats(self): c = self.test.statistics.get_counter("/net/ipsec/sa") return c[0][self.stat_index] + + +class VppIpsecTunProtect(VppObject): + """ + VPP IPSEC tunnel protection + """ + + def __init__(self, test, itf, sa_out, sas_in): + self.test = test + self.itf = itf + self.sas_in = [] + for sa in sas_in: + self.sas_in.append(sa.id) + self.sa_out = sa_out.id + + def update_vpp_config(self, sa_out, sas_in): + self.sas_in = [] + for sa in sas_in: + self.sas_in.append(sa.id) + self.sa_out = sa_out.id + self.test.vapi.ipsec_tunnel_protect_update( + tunnel={ + 'sw_if_index': self.itf._sw_if_index, + 'n_sa_in': len(self.sas_in), + 'sa_out': self.sa_out, + 'sa_in': self.sas_in}) + + def object_id(self): + return "ipsec-tun-protect-%s" % self.itf + + def add_vpp_config(self): + self.test.vapi.ipsec_tunnel_protect_update( + tunnel={ + 'sw_if_index': self.itf._sw_if_index, + 'n_sa_in': len(self.sas_in), + 'sa_out': self.sa_out, + 'sa_in': self.sas_in}) + self.test.registry.register(self, self.test.logger) + + def remove_vpp_config(self): + self.test.vapi.ipsec_tunnel_protect_del( + sw_if_index=self.itf.sw_if_index) + + def query_vpp_config(self): + bs = self.test.vapi.ipsec_tunnel_protect_dump( + sw_if_index=self.itf.sw_if_index) + for b in bs: + if b.tun.sw_if_index == self.itf.sw_if_index: + return True + return False