diff options
Diffstat (limited to 'vnet/vnet')
-rw-r--r-- | vnet/vnet/lisp-cp/control.c | 50 | ||||
-rw-r--r-- | vnet/vnet/lisp-cp/lisp_msg_serdes.c | 55 | ||||
-rw-r--r-- | vnet/vnet/lisp-cp/lisp_msg_serdes.h | 2 | ||||
-rw-r--r-- | vnet/vnet/lisp-cp/lisp_types.c | 12 | ||||
-rw-r--r-- | vnet/vnet/lisp-cp/lisp_types.h | 1 |
5 files changed, 84 insertions, 36 deletions
diff --git a/vnet/vnet/lisp-cp/control.c b/vnet/vnet/lisp-cp/control.c index f4cb16fa..c1873972 100644 --- a/vnet/vnet/lisp-cp/control.c +++ b/vnet/vnet/lisp-cp/control.c @@ -692,6 +692,47 @@ get_local_iface_ip_for_dst (lisp_cp_main_t *lcm, ip_address_t * dst, } } + +static ip_address_t * +build_itr_rloc_list (lisp_cp_main_t * lcm, locator_set_t * loc_set) +{ + ip4_address_t * l4; + ip6_address_t * l6; + u32 i; + locator_t * loc; + u32 * loc_indexp; + ip_interface_address_t * ia = 0; + ip_address_t * rlocs = 0; + ip_address_t _rloc, * rloc = &_rloc; + + for (i = 0; i < vec_len(loc_set->locator_indices); i++) + { + loc_indexp = vec_elt_at_index(loc_set->locator_indices, i); + loc = pool_elt_at_index (lcm->locator_pool, loc_indexp[0]); + + ip_addr_version(rloc) = IP4; + /* Add ipv4 locators first TODO sort them */ + foreach_ip_interface_address (&lcm->im4->lookup_main, ia, + loc->sw_if_index, 1 /* unnumbered */, + ({ + l4 = ip_interface_address_get_address (&lcm->im4->lookup_main, ia); + ip_addr_v4(rloc) = l4[0]; + vec_add1(rlocs, rloc[0]); + })); + + ip_addr_version(rloc) = IP6; + /* Add ipv6 locators */ + foreach_ip_interface_address (&lcm->im6->lookup_main, ia, + loc->sw_if_index, 1 /* unnumbered */, + ({ + l6 = ip_interface_address_get_address (&lcm->im6->lookup_main, ia); + ip_addr_v6(rloc) = l6[0]; + vec_add1(rlocs, rloc[0]); + })); + } + return rlocs; +} + static vlib_buffer_t * build_encapsulated_map_request (vlib_main_t * vm, lisp_cp_main_t *lcm, gid_address_t * seid, gid_address_t * deid, @@ -701,6 +742,7 @@ build_encapsulated_map_request (vlib_main_t * vm, lisp_cp_main_t *lcm, vlib_buffer_t * b; u32 bi; ip_address_t * mr_ip, sloc; + ip_address_t * rlocs = 0; if (vlib_buffer_alloc (vm, &bi, 1) != 1) { @@ -713,8 +755,11 @@ build_encapsulated_map_request (vlib_main_t * vm, lisp_cp_main_t *lcm, /* leave some space for the encap headers */ vlib_buffer_make_headroom (b, MAX_LISP_MSG_ENCAP_LEN); + /* get rlocs */ + rlocs = build_itr_rloc_list (lcm, loc_set); + /* put lisp msg */ - lisp_msg_put_mreq (lcm, b, seid, deid, loc_set, is_smr_invoked, nonce_res); + lisp_msg_put_mreq (lcm, b, seid, deid, rlocs, is_smr_invoked, nonce_res); /* push ecm: udp-ip-lisp */ lisp_msg_push_ecm (vm, b, LISP_CONTROL_PORT, LISP_CONTROL_PORT, seid, deid); @@ -730,6 +775,9 @@ build_encapsulated_map_request (vlib_main_t * vm, lisp_cp_main_t *lcm, mr_ip); bi_res[0] = bi; + + if (rlocs) + vec_free(rlocs); return b; } diff --git a/vnet/vnet/lisp-cp/lisp_msg_serdes.c b/vnet/vnet/lisp-cp/lisp_msg_serdes.c index 0e5ba73d..48e40cff 100644 --- a/vnet/vnet/lisp-cp/lisp_msg_serdes.c +++ b/vnet/vnet/lisp-cp/lisp_msg_serdes.c @@ -27,42 +27,31 @@ lisp_msg_put_gid (vlib_buffer_t * b, gid_address_t * gid) void * lisp_msg_put_itr_rlocs (lisp_cp_main_t * lcm, vlib_buffer_t * b, - locator_set_t * loc_set, u8 * locs_put) + ip_address_t * rlocs, u8 * locs_put) { - ip_interface_address_t * ia = 0; - ip4_address_t * l4; - ip6_address_t * l6; - u32 * loc_indexp; - locator_t * loc; - u32 i; u8 * p, * bp, count = 0; + u32 i; + ip_address_t * addr; bp = vlib_buffer_get_current(b); - for (i = 0; i < vec_len(loc_set->locator_indices); i++) + for (i = 0; i < vec_len(rlocs); i++) + { + addr = &rlocs[i]; + switch (ip_addr_version(addr)) { - loc_indexp = vec_elt_at_index(loc_set->locator_indices, i); - loc = pool_elt_at_index (lcm->locator_pool, loc_indexp[0]); - - /* Add ipv4 locators first TODO sort them */ - foreach_ip_interface_address (&lcm->im4->lookup_main, ia, - loc->sw_if_index, 1 /* unnumbered */, - ({ - l4 = ip_interface_address_get_address (&lcm->im4->lookup_main, ia); - p = vlib_buffer_put_uninit (b, ip4_address_size_to_put()); - ip4_address_put (p, l4); - count++; - })); - - /* Add ipv6 locators */ - foreach_ip_interface_address (&lcm->im6->lookup_main, ia, - loc->sw_if_index, 1 /* unnumbered */, - ({ - l6 = ip_interface_address_get_address (&lcm->im6->lookup_main, ia); - p = vlib_buffer_put_uninit (b, ip6_address_size_to_put()); - ip6_address_put (p, l6); - count++; - })); + case IP4: + p = vlib_buffer_put_uninit (b, ip4_address_size_to_put()); + ip4_address_put (p, &ip_addr_v4(addr)); + count++; + break; + case IP6: + p = vlib_buffer_put_uninit (b, ip6_address_size_to_put()); + ip6_address_put (p, &ip_addr_v6(addr)); + count++; + break; } + } + *locs_put = count-1; return bp; } @@ -103,8 +92,8 @@ nonce_build (u32 seed) void * lisp_msg_put_mreq (lisp_cp_main_t * lcm, vlib_buffer_t * b, - gid_address_t * seid, gid_address_t * deid, - locator_set_t * loc_set, u8 is_smr_invoked, u64 * nonce) + gid_address_t * seid, gid_address_t * deid, + ip_address_t * rlocs, u8 is_smr_invoked, u64 * nonce) { u8 loc_count = 0; @@ -123,7 +112,7 @@ lisp_msg_put_mreq (lisp_cp_main_t * lcm, vlib_buffer_t * b, lisp_msg_put_gid (b, seid); /* Put itr rlocs */ - lisp_msg_put_itr_rlocs(lcm, b, loc_set, &loc_count); + lisp_msg_put_itr_rlocs(lcm, b, rlocs, &loc_count); MREQ_ITR_RLOC_COUNT(h) = loc_count; /* Put eid record */ diff --git a/vnet/vnet/lisp-cp/lisp_msg_serdes.h b/vnet/vnet/lisp-cp/lisp_msg_serdes.h index dddae074..d7eeb35d 100644 --- a/vnet/vnet/lisp-cp/lisp_msg_serdes.h +++ b/vnet/vnet/lisp-cp/lisp_msg_serdes.h @@ -23,7 +23,7 @@ void * lisp_msg_put_mreq (lisp_cp_main_t * lcm, vlib_buffer_t * b, gid_address_t * seid, gid_address_t * deid, - locator_set_t * loc_set, u8 is_smr_invoked, u64 * nonce); + ip_address_t * rlocs, u8 is_smr_invoked, u64 * nonce); void * lisp_msg_push_ecm (vlib_main_t * vm, vlib_buffer_t *b, int lp, int rp, diff --git a/vnet/vnet/lisp-cp/lisp_types.c b/vnet/vnet/lisp-cp/lisp_types.c index a04d36ff..c65745dd 100644 --- a/vnet/vnet/lisp-cp/lisp_types.c +++ b/vnet/vnet/lisp-cp/lisp_types.c @@ -313,7 +313,17 @@ ip_prefix_cmp(ip_prefix_t * p1, ip_prefix_t * p2) int cmp = 0; cmp = ip_address_cmp (&ip_prefix_addr(p1), &ip_prefix_addr(p2)); if (cmp == 0) - cmp = ip_prefix_len(p1) < ip_prefix_len(p2) ? 1 : 2; /* XXX ? */ + { + if (ip_prefix_len(p1) < ip_prefix_len(p2)) + { + cmp = 1; + } + else + { + if (ip_prefix_len(p1) > ip_prefix_len(p2)) + cmp = 2; + } + } return cmp; } diff --git a/vnet/vnet/lisp-cp/lisp_types.h b/vnet/vnet/lisp-cp/lisp_types.h index 9602387f..63adaa0e 100644 --- a/vnet/vnet/lisp-cp/lisp_types.h +++ b/vnet/vnet/lisp-cp/lisp_types.h @@ -96,6 +96,7 @@ typedef enum { u8 *format_gid_address (u8 * s, va_list * args); uword unformat_gid_address (unformat_input_t * input, va_list * args); +int gid_address_cmp (gid_address_t * a1, gid_address_t * a2); u16 gid_address_size_to_put (gid_address_t * a); u16 gid_address_put (u8 * b, gid_address_t * gid); |