35 u32 * map_index_result)
38 u32 mi, * map_indexp, map_index,
i;
50 return VNET_API_ERROR_VALUE_EXIST;
67 return VNET_API_ERROR_INVALID_VALUE;
81 map_index_result[0] = map_index;
89 return VNET_API_ERROR_INVALID_VALUE;
95 for (i = 0; i <
vec_len(eid_indexes[0]); i++)
98 if (map_indexp[0] == mi)
111 if (lm_indexp[0] == mi)
132 u32 * map_index_result)
134 uword * table_id, * refc;
151 return VNET_API_ERROR_INVALID_VALUE;
205 u8 * locator_set_name;
206 u32 locator_set_index = 0, map_index = 0;
220 else if (
unformat (line_input,
"del"))
226 else if (
unformat (line_input,
"locator-set %_%v%_", &locator_set_name))
235 locator_set_index = p[0];
257 .path =
"lisp eid-table",
258 .short_help =
"lisp eid-table add/del eid <eid> locator-set <locator-set>",
276 ip_address_t * rlocs,
u8 action,
u8 is_add)
282 u32 mi, ls_index = 0, dst_map_index, src_map_index;
287 memset (sm_args, 0,
sizeof (sm_args[0]));
288 memset (dm_args, 0,
sizeof (dm_args[0]));
289 memset (ls, 0,
sizeof (ls[0]));
294 memset (&loc, 0,
sizeof (loc));
304 if ((
u32)~0 == src_map_index)
354 if ((
u32)~0 == src_map_index)
403 ip_address_t rloc, * rlocs = 0;
404 ip_prefix_t * deid_ippref, * seid_ippref;
406 u8 deid_set = 0, seid_set = 0;
407 u32 vni, action = ~0;
413 memset (&deid, 0,
sizeof (deid));
414 memset (&seid, 0,
sizeof (seid));
428 else if (
unformat (line_input,
"deid %U",
433 else if (
unformat (line_input,
"vni %u", &vni))
438 else if (
unformat (line_input,
"seid %U",
443 else if (
unformat (line_input,
"action %d", &action))
452 if (is_add && (!deid_set || !seid_set))
458 if (!is_add && !deid_set)
469 " in the same IP family!");
473 if (is_add && (~0 == action)
484 is_add ?
"add" :
"delete");
492 .path =
"lisp remote-mapping",
493 .short_help =
"lisp remote-mapping add|del vni <vni> deid <dest-eid> " 494 "seid <src-eid> rloc <dst-locator> [rloc <dst-locator> ... ]",
510 locator_set_t * ls = pool_elt_at_index (lcm->locator_set_pool,
511 mapit->locator_set_index);
512 vlib_cli_output (vm,
"%-16U%16v", format_gid_address, &mapit->eid,
521 .path =
"show lisp eid-table",
522 .short_help =
"Shows local EID table",
531 u32 i, j, *loc_indexp, *ls_indexp, **ls_indexes;
538 for (j = 0; j <
vec_len(ls_indexes[0]); j++)
541 if (ls_indexp[0] == lsi)
549 if (vec_len (ls_indexes[0]) == 0)
593 return VNET_API_ERROR_VALUE_EXIST;
624 u32 loc_index = ~0, ls_index = ~0, * locit =
NULL, ** ls_indexes =
NULL;
634 return VNET_API_ERROR_INVALID_ARGUMENT;
642 clib_warning(
"locator-set %d to be overwritten doesn't exist!",
644 return VNET_API_ERROR_INVALID_ARGUMENT;
690 if (0 == loc->
local &&
720 if (p && p[0] != (
u32)~0)
725 clib_warning(
"locator-set %d to be overwritten doesn't exist!",
746 memset(ls, 0,
sizeof(*ls));
763 ls_result[0] = ls_index;
784 clib_warning(
"locator-set with index %d doesn't exists", p[0]);
791 if (
vec_len(eid_indexes[0]) != 0)
793 clib_warning (
"Can't delete a locator that supports a mapping!");
827 uword * table_id, * refc;
833 a->
is_en = is_enabled;
838 a->
is_en ?
"enable" :
"disable");
900 if (
unformat (line_input,
"enable"))
905 else if (
unformat (line_input,
"disable"))
922 .short_help =
"lisp [enable|disable]",
945 msg =
format (msg,
"feature: %U\ngpe: %U\n",
953 .path =
"show lisp status",
954 .short_help =
"show lisp status",
966 u8 * locator_set_name = 0;
971 memset(&locator, 0,
sizeof(locator));
972 memset(a, 0,
sizeof(a[0]));
980 if (
unformat (line_input,
"add %_%v%_", &locator_set_name))
982 else if (
unformat (line_input,
"del %_%v%_", &locator_set_name))
984 else if (
unformat (line_input,
"iface %U p %d w %d",
998 a->
name = locator_set_name;
1012 .path =
"lisp locator-set",
1013 .short_help =
"lisp locator-set add/del <name> iface <iface-name> " 1014 "p <priority> w <weight>",
1028 vlib_cli_output (vm,
"%=20s%=16s%=16s%=16s",
"Locator-set",
"Locator",
1029 "Priority",
"Weight");
1033 msg = format (msg,
"%-16v", lsit->name);
1034 vec_foreach (locit, lsit->locator_indices)
1036 loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
1038 msg = format (msg,
"%16d%16d%16d", loc->sw_if_index, loc->priority,
1041 msg = format (msg,
"%16U%16d%16d", format_gid_address, &loc->address,
1042 loc->priority, loc->weight);
1051 .path =
"show lisp locator-set",
1052 .short_help =
"Shows locator-sets",
1060 ip_address_t *
addr;
1098 ip_address_t ip_addr;
1110 else if (
unformat (line_input,
"del"))
1129 .path =
"lisp map-resolver",
1130 .short_help =
"lisp map-resolver add/del <ip_address>",
1135 #define foreach_lisp_cp_lookup_error \ 1137 _(MAP_REQUESTS_SENT, "map-request sent") 1140 #define _(sym,string) string, 1147 #define _(sym,str) LISP_CP_LOOKUP_ERROR_##sym, 1174 s =
format (s,
"LISP-CP-LOOKUP: map-resolver: %U destination eid %U",
1193 ip_address_t * sloc)
1201 ip_address_t * mrit;
1237 u32 sw_if_index = adj->rewrite_header.sw_if_index;
1246 l4 = ip_interface_address_get_address (&lcm->im4->lookup_main,
1257 l6 = ip_interface_address_get_address (&lcm->im6->lookup_main,
1280 clib_warning(
"Can't find map-resolver and local interface ip!");
1309 l4 = ip_interface_address_get_address (&lcm->im4->lookup_main, ia);
1310 ip_addr_v4 (rloc) = l4[0];
1311 ip_prefix_len (ippref) = 32;
1312 vec_add1 (rlocs, gid[0]);
1320 l6 = ip_interface_address_get_address (&lcm->im6->lookup_main, ia);
1321 ip_addr_v6 (rloc) = l6[0];
1322 ip_prefix_len (ippref) = 128;
1323 vec_add1 (rlocs, gid[0]);
1333 ip_address_t * sloc,
u8 is_smr_invoked,
1334 u64 *nonce_res,
u32 * bi_res)
1342 clib_warning (
"Can't allocate buffer for Map-Request!");
1376 u32 next_index, bi = 0, * to_next, map_index;
1383 ip_address_t mr_ip, sloc;
1387 if (map_index == ~0)
1389 clib_warning(
"No local mapping found in eid-table for %U!",
1398 clib_warning(
"Mapping found for src eid %U is not marked as local!",
1409 &sloc, is_smr_invoked, &nonce, &bi);
1463 u32 * from, * to_next_drop,
di, si;
1465 u32 pkts_mapped = 0;
1466 uword n_left_from, n_left_to_next_drop;
1471 while (n_left_from > 0)
1474 to_next_drop, n_left_to_next_drop);
1476 while (n_left_from > 0 && n_left_to_next_drop > 0)
1482 ip_prefix_t * spref, * dpref;
1492 to_next_drop[0] = pi0;
1494 n_left_to_next_drop -= 1;
1497 p0->
error = node->
errors[LISP_CP_LOOKUP_ERROR_DROP];
1528 memset(tr, 0,
sizeof(*tr));
1534 sizeof(ip_address_t));
1542 LISP_CP_LOOKUP_ERROR_MAP_REQUESTS_SENT,
1549 .name =
"lisp-cp-lookup",
1550 .vector_size =
sizeof (
u32),
1567 #define foreach_lisp_cp_input_error \ 1569 _(MAP_REPLIES_RECEIVED, "map-replies received") 1572 #define _(sym,string) string, 1579 #define _(sym,str) LISP_CP_INPUT_ERROR_##sym, 1604 s =
format (s,
"LISP-CP-INPUT: TODO");
1617 (
vec_len((lm)->if_address_pool_index_by_sw_if_index) > (sw_if_index)) ?
1618 vec_elt((lm)->if_address_pool_index_by_sw_if_index, (sw_if_index)) :
1628 lm, sw_if_index, loop);
1639 memset(a, 0,
sizeof(*a));
1667 u32 i, minp = ~0, sw_if_index;
1669 uword * feip = 0, * tidp;
1673 memset (a, 0,
sizeof(*a));
1751 LISP_GPE_INPUT_NEXT_IP4_INPUT : LISP_GPE_INPUT_NEXT_IP6_INPUT;
1775 for (i = 0; i <
vec_len(new_locators); i++)
1777 old_li =
vec_elt(old_ls_indexes, i);
1792 u32 len = 0,
i, ls_index = 0;
1800 u32 dst_map_index, mi;
1810 clib_warning(
"No pending map-request entry with nonce %lu!", nonce);
1819 memset (ls_arg, 0,
sizeof(*ls_arg));
1820 memset (m_args, 0,
sizeof(*m_args));
1853 old_map->
ttl = m_args->
ttl;
1907 clib_warning(
"Only SMR Map-Requests supported for now!");
1930 memset(&dst, 0,
sizeof(dst));
1946 u32 n_left_from, * from, * to_next_drop;
1954 while (n_left_from > 0)
1956 u32 n_left_to_next_drop;
1959 to_next_drop, n_left_to_next_drop);
1960 while (n_left_from > 0 && n_left_to_next_drop > 0)
1968 to_next_drop[0] = bi0;
1970 n_left_to_next_drop -= 1;
1984 clib_warning(
"Unsupported LISP message type %d", type);
1988 b0->
error = node->
errors[LISP_CP_INPUT_ERROR_DROP];
2003 .name =
"lisp-cp-input",
2004 .vector_size =
sizeof (
u32),
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
#define MREQ_ITR_RLOC_COUNT(h_)
static uword lisp_cp_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define MREP_REC_COUNT(h_)
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
#define gid_address_type(_a)
uword * dp_if_refcount_by_vni
#define hash_unset(h, key)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
ip_interface_address_t * if_address_pool
void * pkt_push_udp_and_ip(vlib_main_t *vm, vlib_buffer_t *b, u16 sp, u16 dp, ip_address_t *sip, ip_address_t *dip)
#define MREQ_REC_COUNT(h_)
ip_lookup_next_t lookup_next_index
int vnet_lisp_gpe_add_del_fwd_entry(vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u32 *hw_if_indexp)
clib_error_t * vnet_lisp_gpe_enable_disable(vnet_lisp_gpe_enable_disable_args_t *a)
#define foreach_lisp_cp_input_error
static clib_error_t * lisp_show_status_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 * local_mappings_indexes
#define ip_prefix_len(_a)
uword unformat_ip_address(unformat_input_t *input, va_list *args)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define hash_set_mem(h, key, value)
static char * lisp_cp_input_error_strings[]
ip_lookup_main_t lookup_main
unformat_function_t unformat_vnet_sw_interface
static uword lisp_cp_lookup(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
#define ip_prefix_version(_a)
always_inline void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
void gid_dictionary_init(gid_dictionary_t *db)
ip_address_t * map_resolvers
static void clean_locator_to_locator_set(lisp_cp_main_t *lcm, u32 lsi)
always_inline void * ip_interface_address_get_address(ip_lookup_main_t *lm, ip_interface_address_t *a)
static clib_error_t * lisp_cp_show_locator_sets_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_registration_t ip4_lookup_node
(constructor) VLIB_REGISTER_NODE (ip4_lookup_node)
static clib_error_t * lisp_show_local_eid_table_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 ** locator_to_locator_sets
vnet_main_t * vnet_get_main(void)
vlib_node_registration_t lisp_cp_lookup_node
(constructor) VLIB_REGISTER_NODE (lisp_cp_lookup_node)
void process_map_reply(lisp_cp_main_t *lcm, vlib_buffer_t *b)
#define pool_foreach(VAR, POOL, BODY)
static clib_error_t * lisp_add_del_local_eid_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_INIT_FUNCTION(x)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u32 ip4_fib_lookup_with_table(ip4_main_t *im, u32 fib_index, ip4_address_t *dst, u32 disable_default_route)
u32 * fwd_entry_by_mapping_index
#define clib_warning(format, args...)
void vnet_lisp_gpe_add_del_iface(vnet_lisp_gpe_add_del_iface_args_t *a, u32 *hw_if_indexp)
void * lisp_msg_put_mreq(lisp_cp_main_t *lcm, vlib_buffer_t *b, gid_address_t *seid, gid_address_t *deid, gid_address_t *rlocs, u8 is_smr_invoked, u64 *nonce)
#define vlib_call_init_function(vm, x)
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, locator_set_t *loc_set, ip_address_t *mr_ip, ip_address_t *sloc, u8 is_smr_invoked, u64 *nonce_res, u32 *bi_res)
always_inline void * vlib_frame_vector_args(vlib_frame_t *f)
#define ip_addr_version(_a)
static clib_error_t * lisp_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 gid_dictionary_lookup(gid_dictionary_t *db, gid_address_t *key)
#define pool_elt_at_index(p, i)
#define hash_unset_mem(h, key)
u32 gid_dictionary_add_del(gid_dictionary_t *db, gid_address_t *key, u32 value, u8 is_add)
int vnet_lisp_add_del_local_mapping(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index_result)
u32 lisp_msg_parse_addr(vlib_buffer_t *b, gid_address_t *eid)
vlib_node_registration_t lisp_cp_input_node
(constructor) VLIB_REGISTER_NODE (lisp_cp_input_node)
void gid_address_free(gid_address_t *a)
#define vec_dup(V)
Return copy of vector (no header, no alignment)
u32 * local_locator_set_indexes
#define vec_del1(v, i)
Delete the element at index I.
u8 * format_gid_address(u8 *s, va_list *args)
always_inline void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static void del_fwd_entry(lisp_cp_main_t *lcm, u32 src_map_index, u32 dst_map_index)
static u8 compare_locators(lisp_cp_main_t *lcm, u32 *old_ls_indexes, locator_t *new_locators)
static void send_encapsulated_map_request(vlib_main_t *vm, lisp_cp_main_t *lcm, gid_address_t *seid, gid_address_t *deid, u8 is_smr_invoked)
clib_error_t * vnet_lisp_enable_disable(u8 is_enabled)
#define foreach_lisp_cp_lookup_error
void vlib_put_frame_to_node(vlib_main_t *vm, u32 to_node_index, vlib_frame_t *f)
#define MAX_LISP_MSG_ENCAP_LEN
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
void * ip_interface_get_first_ip_addres(ip_lookup_main_t *lm, u32 sw_if_index, u8 loop)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
ip_address_t map_resolver_ip
static clib_error_t * lisp_add_del_map_resolver_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void remove_locator_from_locator_set(locator_set_t *ls, u32 *locit, u32 ls_index, u32 loc_id)
#define gid_address_ippref(_a)
static int is_locator_in_locator_set(lisp_cp_main_t *lcm, locator_set_t *ls, locator_t *loc)
u32 lisp_msg_parse_itr_rlocs(vlib_buffer_t *b, gid_address_t **rlocs, u8 rloc_count)
clib_error_t * lisp_cp_init(vlib_main_t *vm)
int vnet_lisp_add_del_remote_mapping(gid_address_t *deid, gid_address_t *seid, ip_address_t *rlocs, u8 action, u8 is_add)
Adds/removes/updates static remote mapping.
uword * pending_map_requests_by_nonce
u8 * format_lisp_cp_input_trace(u8 *s, va_list *args)
#define MAP_REC_ACTION(h)
int gid_address_cmp(gid_address_t *a1, gid_address_t *a2)
#define vec_free(V)
Free vector's memory (no header).
u32 lisp_msg_parse_mapping_record(vlib_buffer_t *b, gid_address_t *eid, locator_t **locs, locator_t *probed_)
void * lisp_msg_push_ecm(vlib_main_t *vm, vlib_buffer_t *b, int lp, int rp, gid_address_t *la, gid_address_t *ra)
#define clib_memcpy(a, b, c)
u32 locator_cmp(locator_t *l1, locator_t *l2)
u32 ip6_fib_lookup_with_table(ip6_main_t *im, u32 fib_index, ip6_address_t *dst)
#define pool_is_free_index(P, I)
lisp_gpe_main_t lisp_gpe_main
always_inline lisp_cp_main_t * vnet_lisp_cp_get_main()
u32 unnumbered_sw_if_index
#define VLIB_CLI_COMMAND(x,...)
u8 vnet_lisp_enable_disable_status(void)
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
struct _gid_address_t gid_address_t
u8 * format_vnet_lisp_gpe_status(u8 *s, va_list *args)
#define pool_put_index(p, i)
static void get_src_and_dst(void *hdr, ip_address_t *src, ip_address_t *dst)
void get_mr_and_local_iface_ip(lisp_cp_main_t *lcm, ip_address_t *mr_ip, ip_address_t *sloc)
u8 * format_ip_address(u8 *s, va_list *args)
ip_lookup_main_t lookup_main
#define vec_delete(V, N, M)
Delete N elements starting at element M.
clib_error_t * lisp_gpe_init(vlib_main_t *vm)
gid_dictionary_t mapping_index_by_gid
ip_interface_address_t * ip_interface_get_first_interface_address(ip_lookup_main_t *lm, u32 sw_if_index, u8 loop)
always_inline void * vlib_buffer_make_headroom(vlib_buffer_t *b, u8 size)
locator_set_t * locator_set_pool
always_inline void * vlib_buffer_pull(vlib_buffer_t *b, u8 size)
u32 ** locator_set_to_eids
#define LISP_CONTROL_PORT
u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
fwd_entry_t * fwd_entry_pool
#define VLIB_BUFFER_IS_TRACED
always_inline ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
#define vec_elt(v, i)
Get vector value at index i.
pending_map_request_t * pending_map_requests_pool
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
#define gid_address_ip(_a)
negative_fwd_actions_e action
#define gid_address_vni(_a)
#define hash_create_vec(elts, key_bytes, value_bytes)
static uword * get_locator_set_index(vnet_lisp_add_del_locator_set_args_t *a, uword *p)
void locator_free(locator_t *l)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static char * lisp_cp_lookup_error_strings[]
always_inline vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
int ip_address_cmp(ip_address_t *ip1, ip_address_t *ip2)
int vnet_lisp_add_del_locator(vnet_lisp_add_del_locator_set_args_t *a, locator_set_t *ls, u32 *ls_result)
u8 ip_address_max_len(u8 version)
uword * locator_set_index_by_name
static gid_address_t * build_itr_rloc_list(lisp_cp_main_t *lcm, locator_set_t *loc_set)
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
always_inline void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
#define hash_get_mem(h, key)
u32 lisp_msg_parse_eid_rec(vlib_buffer_t *b, gid_address_t *eid)
#define VLIB_REGISTER_NODE(x,...)
int vnet_lisp_add_del_map_resolver(vnet_lisp_add_del_map_resolver_args_t *a)
void process_map_request(vlib_main_t *vm, lisp_cp_main_t *lcm, vlib_buffer_t *b)
#define gid_address_set_vni(_a, _val)
#define vec_foreach(var, vec)
Vector iterator.
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
#define clib_error_return(e, args...)
vlib_frame_t * vlib_get_frame_to_node(vlib_main_t *vm, u32 to_node_index)
always_inline lisp_msg_type_e lisp_msg_type(void *b)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static u8 * format_lisp_status(u8 *s, va_list *args)
always_inline vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u32 ip_fib_lookup_with_table(lisp_cp_main_t *lcm, u32 fib_index, ip_address_t *dst)
int vnet_lisp_add_del_mapping(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index_result)
static clib_error_t * lisp_add_del_locator_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_lisp_cp_lookup_trace(u8 *s, va_list *args)
void ip_address_copy(ip_address_t *dst, ip_address_t *src)
static clib_error_t * lisp_add_del_remote_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Handler for add/del remote mapping CLI.
#define ip_prefix_addr(_a)
static void add_fwd_entry(lisp_cp_main_t *lcm, u32 src_map_index, u32 dst_map_index)