X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fvpp_ipsec.py;h=268fe687876dee5bb2accc0cdfcd99bdb527fa7f;hb=61717cc38;hp=0df8cb2a88acbe1133b8be26288647dc4d0bc249;hpb=c87b66c86201458c0475d50c6e93f1497f9eec2e;p=vpp.git diff --git a/test/vpp_ipsec.py b/test/vpp_ipsec.py index 0df8cb2a88a..268fe687876 100644 --- a/test/vpp_ipsec.py +++ b/test/vpp_ipsec.py @@ -8,6 +8,10 @@ except NameError: text_type = str +def mk_counter(): + return {'packets': 0, 'bytes': 0} + + class VppIpsecSpd(VppObject): """ VPP SPD DB @@ -163,9 +167,16 @@ class VppIpsecSpdEntry(VppObject): return True return False - def get_stats(self): + def get_stats(self, worker=None): c = self.test.statistics.get_counter("/net/ipsec/policy") - return c[0][self.stat_index] + if worker is None: + total = mk_counter() + for t in c: + total['packets'] += t[self.stat_index]['packets'] + return total + else: + # +1 to skip main thread + return c[worker+1][self.stat_index] class VppIpsecSA(VppObject): @@ -244,9 +255,16 @@ class VppIpsecSA(VppObject): return True return False - def get_stats(self): + def get_stats(self, worker=None): c = self.test.statistics.get_counter("/net/ipsec/sa") - return c[0][self.stat_index] + if worker is None: + total = mk_counter() + for t in c: + total['packets'] += t[self.stat_index]['packets'] + return total + else: + # +1 to skip main thread + return c[worker+1][self.stat_index] class VppIpsecTunProtect(VppObject): @@ -254,13 +272,16 @@ class VppIpsecTunProtect(VppObject): VPP IPSEC tunnel protection """ - def __init__(self, test, itf, sa_out, sas_in): + def __init__(self, test, itf, sa_out, sas_in, nh=None): 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 + self.nh = nh + if not self.nh: + self.nh = "0.0.0.0" def update_vpp_config(self, sa_out, sas_in): self.sas_in = [] @@ -272,10 +293,11 @@ class VppIpsecTunProtect(VppObject): '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}) + 'sa_in': self.sas_in, + 'nh': self.nh}) def object_id(self): - return "ipsec-tun-protect-%s" % self.itf + return "ipsec-tun-protect-%s-%s" % (self.itf, self.nh) def add_vpp_config(self): self.test.vapi.ipsec_tunnel_protect_update( @@ -283,17 +305,20 @@ class VppIpsecTunProtect(VppObject): '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}) + 'sa_in': self.sas_in, + 'nh': self.nh}) 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) + sw_if_index=self.itf.sw_if_index, + nh=self.nh) 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: + if b.tun.sw_if_index == self.itf.sw_if_index and \ + self.nh == str(b.tun.nh): return True return False