diff options
Diffstat (limited to 'vnet/test/lisp-cp')
-rw-r--r-- | vnet/test/lisp-cp/test_cp_serdes.c | 53 | ||||
-rw-r--r-- | vnet/test/lisp-cp/test_lisp_types.c | 96 |
2 files changed, 28 insertions, 121 deletions
diff --git a/vnet/test/lisp-cp/test_cp_serdes.c b/vnet/test/lisp-cp/test_cp_serdes.c index 2ca391e35b7..7bfe6e35378 100644 --- a/vnet/test/lisp-cp/test_cp_serdes.c +++ b/vnet/test/lisp-cp/test_cp_serdes.c @@ -183,6 +183,8 @@ build_map_request (lisp_cp_main_t * lcm, vlib_buffer_t * b, u8 is_smr_invoked = 1; u64 nonce = 0; map_request_hdr_t * h = 0; + memset (deid, 0, sizeof (deid[0])); + memset (seid, 0, sizeof (seid[0])); gid_address_type (seid) = GID_ADDR_IP_PREFIX; ip_address_t * ip_addr = &gid_address_ip (seid); @@ -205,6 +207,7 @@ static void generate_rlocs (gid_address_t **rlocs, u32 * count) { gid_address_t gid_addr_data, * gid_addr = &gid_addr_data; + memset (gid_addr, 0, sizeof (gid_addr[0])); ip_address_t * addr = &gid_address_ip (gid_addr); gid_address_type (gid_addr) = GID_ADDR_IP_PREFIX; @@ -277,34 +280,20 @@ static clib_error_t * test_lisp_msg_put_mreq_with_lcaf () clib_error_t * error = 0; map_request_hdr_t *h = 0; gid_address_t * rlocs = 0; - gid_address_t rloc; ip_prefix_t ippref; ip_prefix_version (&ippref) = IP4; ip4_address_t * ip = &ip_prefix_v4 (&ippref); ip->as_u32 = 0x11223344; - gid_address_t gid1 = + gid_address_t g = { .type = GID_ADDR_IP_PREFIX, - .ippref = ippref + .ippref = ippref, + .vni = 0x90919293, + .vni_mask = 0x17 }; - - lcaf_t lcaf1 = - { - .type = LCAF_INSTANCE_ID, - .uni = - { - .vni_mask_len = 0x17, - .vni = 0x90919293, - .gid_addr = &gid1 - } - }; - - gid_address_type (&rloc) = GID_ADDR_LCAF; - gid_address_lcaf (&rloc) = lcaf1; - - vec_add1 (rlocs, rloc); + vec_add1 (rlocs, g); u8 * data = clib_mem_alloc (500); memset (data, 0, 500); @@ -482,16 +471,9 @@ test_lisp_parse_lcaf () _assert (locs[0].mpriority == 0xc); _assert (locs[0].mweight == 0xd); - /* check LCAF header data */ - lcaf_t * lcaf = &gid_address_lcaf (&locs[0].address); - _assert (gid_address_type (&locs[0].address) == GID_ADDR_LCAF); - _assert (lcaf_type (lcaf) == LCAF_INSTANCE_ID); - vni_t * v = (vni_t *) lcaf; - _assert (vni_vni (v) == 0x09); - - gid_address_t * nested_gid = vni_gid (v); - _assert (GID_ADDR_IP_PREFIX == gid_address_type (nested_gid)); - ip_prefix_t * ip_pref = &gid_address_ippref (nested_gid); + _assert (gid_address_type (&locs[0].address) == GID_ADDR_IP_PREFIX); + _assert (gid_address_vni (&locs[0].address) == 0x09); + ip_prefix_t * ip_pref = &gid_address_ippref (&locs[0].address); _assert (IP4 == ip_prefix_version (ip_pref)); /* 2nd locator - LCAF entry with ipv6 address */ @@ -501,16 +483,9 @@ test_lisp_parse_lcaf () _assert (locs[1].mpriority == 0x5); _assert (locs[1].mweight == 0x4); - /* LCAF header */ - _assert (gid_address_type (&locs[1].address) == GID_ADDR_LCAF); - lcaf = &gid_address_lcaf (&locs[1].address); - _assert (lcaf_type (lcaf) == LCAF_INSTANCE_ID); - v = (vni_t *) lcaf; - _assert (vni_vni (v) == 0x22446688); - - nested_gid = vni_gid (v); - _assert (GID_ADDR_IP_PREFIX == gid_address_type (nested_gid)); - ip_pref = &gid_address_ippref (nested_gid); + _assert (gid_address_type (&locs[1].address) == GID_ADDR_IP_PREFIX); + _assert (0x22446688 == gid_address_vni (&locs[1].address)); + ip_pref = &gid_address_ippref (&locs[1].address); _assert (IP6 == ip_prefix_version (ip_pref)); /* 3rd locator - simple ipv4 address */ diff --git a/vnet/test/lisp-cp/test_lisp_types.c b/vnet/test/lisp-cp/test_lisp_types.c index 5d4e2a80c60..4291bbebb20 100644 --- a/vnet/test/lisp-cp/test_lisp_types.c +++ b/vnet/test/lisp-cp/test_lisp_types.c @@ -154,21 +154,19 @@ static clib_error_t * test_gid_parse_lcaf () _assert (18 == len); gid_address_copy (gid_addr_copy, gid_addr); _assert (0 == gid_address_cmp (gid_addr_copy, gid_addr)); + _assert (GID_ADDR_IP_PREFIX == gid_address_type (gid_addr)); + _assert (9 == gid_address_vni (gid_addr)); + _assert (0x18 == gid_address_vni_mask (gid_addr)); + _assert (0xddccbb10 == gid_addr->ippref.addr.ip.v4.as_u32); - lcaf_t * lcaf = &gid_address_lcaf (gid_addr_copy); - vni_t * vni = (vni_t *) lcaf; - _assert (lcaf->type == LCAF_INSTANCE_ID); - _assert (vni->vni == 9); - _assert (vni->vni_mask_len == 0x18); - - gid_address_t * g = vni_gid (vni); - _assert (gid_address_type (g) == GID_ADDR_IP_PREFIX); done: gid_address_free (gid_addr); gid_address_free (gid_addr_copy); return error; } +/* recursive LCAFs are not supported */ +#if 0 static clib_error_t * test_gid_parse_lcaf_complex () { clib_error_t * error = 0; @@ -262,59 +260,7 @@ done: gid_address_free (gid_addr_copy); return error; } - -static clib_error_t * test_format_unformat_gid_address (void) -{ - u8 * s = 0; - clib_error_t * error = 0; - unformat_input_t _input; - unformat_input_t * input = &_input; - gid_address_t _gid_addr, * gid_addr = &_gid_addr; - gid_address_t unformated_gid; - - /* format/unformat IPv4 global ID address */ - gid_address_type(gid_addr) = GID_ADDR_IP_PREFIX; - gid_address_ippref_len(gid_addr) = 24; - ip_prefix_version(&gid_addr->ippref) = IP4; - gid_addr->ippref.addr.ip.v4.as_u32 = 0x20304050; - - s = format(0, "%U", format_gid_address, gid_addr); - vec_add1(s, 0); - unformat_init_string(input, (char *)s, vec_len(s)); - - _assert (unformat(input, "%U", - unformat_gid_address, &unformated_gid)); - _assert (0 == gid_address_cmp (&unformated_gid, gid_addr)); - - unformat_free(input); - vec_free(s); - s = 0; - - /* format/unformat IPv6 global ID address */ - gid_address_type(gid_addr) = GID_ADDR_IP_PREFIX; - gid_address_ippref_len(gid_addr) = 64; - ip_prefix_version(&gid_addr->ippref) = IP6; - u8 ipv6[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; - clib_memcpy(gid_addr->ippref.addr.ip.v6.as_u8, ipv6, sizeof(ipv6)); - - s = format(0, "%U", format_gid_address, gid_addr); - vec_add1(s, 0); - unformat_init_string(input, (char *)s, vec_len(s)); - - _assert (unformat (input, "%U", unformat_gid_address, - &unformated_gid)); - _assert (0 == gid_address_cmp(&unformated_gid, gid_addr)); - - /* test address copy */ - gid_address_t gid_addr_copy; - gid_address_copy(&gid_addr_copy, gid_addr); - _assert (0 == gid_address_cmp (&gid_addr_copy, gid_addr)); - -done: - unformat_free(input); - vec_free(s); - return error; -} +#endif #if 0 /* uncomment this once VNI is supported */ static clib_error_t * test_write_mac_in_lcaf (void) @@ -393,34 +339,22 @@ static clib_error_t * test_gid_address_write (void) memset(b, 0, 500); ip_prefix_version (ippref) = IP4; + ip_prefix_len (ippref) = 9; ip4_address_t * ip4 = &ip_prefix_v4 (ippref); ip4->as_u32 = 0xaabbccdd; - gid_address_t nested_gid = + gid_address_t g = { .ippref = ippref[0], .type = GID_ADDR_IP_PREFIX, + .vni = 0x01020304, + .vni_mask = 0x18 }; - lcaf_t lcaf = - { - .type = LCAF_INSTANCE_ID, - .uni = - { - .vni_mask_len = 0x18, - .vni = 0x01020304, - .gid_addr = &nested_gid - } - }; - - gid_address_t gid = - { - .type = GID_ADDR_LCAF, - .lcaf = lcaf - }; - _assert (18 == gid_address_size_to_put (&gid)); + _assert (18 == gid_address_size_to_put (&g)); + _assert (gid_address_len (&g) == 9); - u16 write_len = gid_address_put (b, &gid); + u16 write_len = gid_address_put (b, &g); _assert (18 == write_len); u8 expected_gid_data[] = @@ -443,12 +377,10 @@ done: } #define foreach_test_case \ - _(format_unformat_gid_address) \ _(locator_type) \ _(gid_parse_ip_pref) \ _(gid_parse_mac) \ _(gid_parse_lcaf) \ - _(gid_parse_lcaf_complex) \ _(mac_address_write) \ _(gid_address_write) |