diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-03-19 11:54:39 -0700 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2019-03-22 08:30:11 +0000 |
commit | f7f13347bc8bc941a2d9aa847ddd88a758d65f71 (patch) | |
tree | 4dae0b0ad0c9216eb5de75384f7fb0348b7d9dc1 | |
parent | bdd6e6ac4ebde344adeb3f7c78c4b2031a0eb52a (diff) |
tests: update test_lb.py to use api call lb_conf.
Change-Id: I96a1d4b2b3ae22cf164c0acd6db9b323cd70f51a
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
-rw-r--r-- | src/plugins/lb/api.c | 12 | ||||
-rw-r--r-- | src/plugins/lb/lb.api | 9 | ||||
-rw-r--r-- | src/plugins/lb/lb_test.c | 2 | ||||
-rw-r--r-- | test/test_lb.py | 8 | ||||
-rw-r--r-- | test/vpp_papi_provider.py | 2 |
5 files changed, 22 insertions, 11 deletions
diff --git a/src/plugins/lb/api.c b/src/plugins/lb/api.c index 07476be70fd..953654cd956 100644 --- a/src/plugins/lb/api.c +++ b/src/plugins/lb/api.c @@ -16,6 +16,7 @@ #include <lb/lb.h> #include <vppinfra/byte_order.h> +#include <vppinfra/string.h> #include <vlibapi/api.h> #include <vlibapi/api.h> #include <vlibmemory/api.h> @@ -79,8 +80,15 @@ vl_api_lb_conf_t_handler vl_api_lb_conf_reply_t * rmp; int rv = 0; + if (mp->sticky_buckets_per_core == ~0) { + mp->sticky_buckets_per_core = lbm->per_cpu_sticky_buckets; + } + if (mp->flow_timeout == ~0) { + mp->flow_timeout = lbm->flow_timeout; + } + rv = lb_conf((ip4_address_t *)&mp->ip4_src_address, - (ip6_address_t *)mp->ip6_src_address, + (ip6_address_t *)&mp->ip6_src_address, mp->sticky_buckets_per_core, mp->flow_timeout); @@ -93,7 +101,7 @@ static void *vl_api_lb_conf_t_print u8 * s; s = format (0, "SCRIPT: lb_conf "); s = format (s, "%U ", format_ip4_address, (ip4_address_t *)&mp->ip4_src_address); - s = format (s, "%U ", format_ip6_address, (ip6_address_t *)mp->ip6_src_address); + s = format (s, "%U ", format_ip6_address, (ip6_address_t *)&mp->ip6_src_address); s = format (s, "%u ", mp->sticky_buckets_per_core); s = format (s, "%u ", mp->flow_timeout); FINISH; diff --git a/src/plugins/lb/lb.api b/src/plugins/lb/lb.api index d36f857f5de..190e32011b3 100644 --- a/src/plugins/lb/lb.api +++ b/src/plugins/lb/lb.api @@ -1,6 +1,7 @@ option version = "1.0.0"; +import "vnet/ip/ip_types.api"; -/** \brief Configure Load-Balancer global parameters +/** \brief Configure Load-Balancer global parameters (unlike the CLI, both ip4_src_address and ip6_src_address need to be specified. @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param ip4_src_address - IPv4 address to be used as source for IPv4 traffic(applicable in GRE4/GRE6/NAT4/NAT6 mode only). @@ -14,8 +15,8 @@ autoreply define lb_conf { u32 client_index; u32 context; - u32 ip4_src_address; - u8 ip6_src_address[16]; + vl_api_ip4_address_t ip4_src_address; + vl_api_ip6_address_t ip6_src_address; u32 sticky_buckets_per_core; u32 flow_timeout; }; @@ -26,7 +27,7 @@ autoreply define lb_conf @param ip_prefix - IP address (IPv4 in lower order 32 bits). @param prefix_length - IP prefix length (96 + 'IPv4 prefix length' for IPv4). @param protocol - tcp or udp. - @param port - destination port. + @param port - destination port. (0) means 'all-port VIP' @param encap - Encap is ip4 GRE(0) or ip6 GRE(1) or L3DSR(2) or NAT4(3) or NAT6(4). @param dscp - DSCP bit corresponding to VIP(applicable in L3DSR mode only). @param type - service type(applicable in NAT4/NAT6 mode only). diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index f6016db7e13..cf55aec614f 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -161,7 +161,7 @@ static int api_lb_conf (vat_main_t * vam) M(LB_CONF, mp); clib_memcpy (&(mp->ip4_src_address), &ip4_src_address, sizeof (ip4_src_address)); - clib_memcpy (mp->ip6_src_address, &ip6_src_address, sizeof (ip6_src_address)); + clib_memcpy (&(mp->ip6_src_address), &ip6_src_address, sizeof (ip6_src_address)); mp->sticky_buckets_per_core = htonl (sticky_buckets_per_core); mp->flow_timeout = htonl (flow_timeout); diff --git a/test/test_lb.py b/test/test_lb.py index 1652cc5d4d4..01af0e56b5b 100644 --- a/test/test_lb.py +++ b/test/test_lb.py @@ -57,8 +57,8 @@ class TestLB(VppTestCase): cls.vapi.ip_add_del_route(dst_address=dst6, dst_address_length=16, next_hop_address=cls.pg1.remote_ip6n, is_ipv6=1) - cls.vapi.cli("lb conf ip4-src-address 39.40.41.42") - cls.vapi.cli("lb conf ip6-src-address 2004::1") + cls.vapi.lb_conf(ip4_src_address="39.40.41.42", + ip6_src_address="2004::1") except Exception: super(TestLB, cls).tearDownClass() raise @@ -186,8 +186,8 @@ class TestLB(VppTestCase): self.logger.error(ppp("Unexpected or invalid packet:", p)) raise - # This is just to 1roughly check that the balancing algorithm - # is not completly biased. + # This is just to roughly check that the balancing algorithm + # is not completely biased. for asid in self.ass: if load[asid] < len(self.packets) / (len(self.ass) * 2): self.logger.error( diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py index d393ce14c25..5e7d6df42b7 100644 --- a/test/vpp_papi_provider.py +++ b/test/vpp_papi_provider.py @@ -111,6 +111,8 @@ defaultmapping = { 'ipsec_tunnel_if_add_del': {'is_add': 1, 'anti_replay': 1, }, 'l2_emulation': {'enable': 1, }, 'l2fib_add_del': {'is_add': 1, }, + 'lb_conf': {'sticky_buckets_per_core': 4294967295, + 'flow_timeout': 4294967295}, 'lisp_add_del_adjacency': {'is_add': 1, }, 'lisp_add_del_local_eid': {'is_add': 1, }, 'lisp_add_del_locator': {'priority': 1, 'weight': 1, 'is_add': 1, }, |