65 u32 is_del,
u32 * result_if_address_index)
77 (address_length == 0) ||
78 (lm->
is_ip6 && address_length > 128) ||
79 (!lm->
is_ip6 && address_length > 32))
81 vnm->
api_errno = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
83 (
"%U wrong length (expected %d) for interface %U",
94 vnm->
api_errno = VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE;
97 addr_fib, address_length,
128 if (result_if_address_index)
129 *result_if_address_index = ~0;
139 memset (a, ~0,
sizeof (a[0]));
144 while (pi != (
u32) ~ 0)
162 (hi != ~0) ? hi : ai;
163 if (result_if_address_index)
164 *result_if_address_index = ai;
170 if (result_if_address_index)
171 *result_if_address_index = ~0;
172 vnm->
api_errno = VNET_API_ERROR_DUPLICATE_IF_ADDRESS;
174 (
"Prefix %U already found on interface %U",
179 if (result_if_address_index)
190 lookup_main.if_address_pool_index_by_sw_if_index,
193 lookup_main.if_address_pool_index_by_sw_if_index,
212 sizeof (ip6_address_fib_t));
225 for (i = 0; i < 256; i++)
247 #define _(n,v) if (flow_hash_config & v) s = format (s, "%s ", #n); 264 s =
format (s,
"unknown %d", n);
298 u32 adj_index = va_arg (*args,
u32);
299 u8 *packet_data = va_arg (*args,
u8 *);
300 u32 n_packet_data_bytes = va_arg (*args,
u32);
333 else if (
unformat (input,
"null-send-unreach"))
335 else if (
unformat (input,
"null-send-prohibit"))
339 else if (
unformat (input,
"classify"))
341 u32 classify_table_index;
343 if (!
unformat (input,
"%d", &classify_table_index))
373 u32 weight, preference;
374 u32 table_id, is_del;
384 memset (&pfx, 0,
sizeof (pfx));
393 memset (&rpath, 0,
sizeof (rpath));
395 if (
unformat (line_input,
"table %d", &table_id))
397 else if (
unformat (line_input,
"resolve-via-host"))
407 else if (
unformat (line_input,
"resolve-via-attached"))
417 else if (
unformat (line_input,
"out-labels"))
434 else if (
unformat (line_input,
"via-label %U",
437 rpath.frp_weight = 1;
440 rpath.frp_sw_if_index = ~0;
443 else if (
unformat (line_input,
"count %f", &count))
446 else if (
unformat (line_input,
"%U/%d",
452 else if (
unformat (line_input,
"%U/%d",
458 else if (
unformat (line_input,
"via %U %U",
462 &rpath.frp_sw_if_index))
464 rpath.frp_weight = 1;
469 else if (
unformat (line_input,
"via %U %U",
473 &rpath.frp_sw_if_index))
475 rpath.frp_weight = 1;
479 else if (
unformat (line_input,
"weight %u", &weight))
484 else if (
unformat (line_input,
"preference %u", &preference))
489 else if (
unformat (line_input,
"via %U next-hop-table %d",
491 &rpath.frp_addr.ip4, &rpath.frp_fib_index))
493 rpath.frp_weight = 1;
494 rpath.frp_sw_if_index = ~0;
498 else if (
unformat (line_input,
"via %U next-hop-table %d",
500 &rpath.frp_addr.ip6, &rpath.frp_fib_index))
502 rpath.frp_weight = 1;
503 rpath.frp_sw_if_index = ~0;
507 else if (
unformat (line_input,
"via %U",
514 rpath.frp_fib_index = table_id;
515 rpath.frp_weight = 1;
516 rpath.frp_sw_if_index = ~0;
520 else if (
unformat (line_input,
"via %U",
523 rpath.frp_fib_index = table_id;
524 rpath.frp_weight = 1;
525 rpath.frp_sw_if_index = ~0;
530 "lookup in table %d", &rpath.frp_fib_index))
533 rpath.frp_sw_if_index = ~0;
536 else if (
vec_len (prefixs) > 0 &&
539 &rpath.frp_sw_if_index))
541 rpath.frp_weight = 1;
545 else if (
vec_len (prefixs) > 0 &&
551 else if (
unformat (line_input,
"del"))
553 else if (
unformat (line_input,
"add"))
593 for (i = 0; i <
vec_len (prefixs); i++)
595 if (is_del && 0 == vec_len (rpaths))
599 else if (!is_del && 1 == vec_len (dpos))
608 else if (vec_len (dpos) > 0)
612 "Load-balancing over multiple special adjacencies is unsupported");
615 else if (0 < vec_len (rpaths))
618 ip46_address_t dst = prefixs[
i].
fp_addr;
625 for (k = 0; k < n; k++)
627 for (j = 0; j <
vec_len (rpaths); j++)
634 rpaths[i].frp_fib_index);
640 rpaths[i].frp_fib_index);
666 clib_host_to_net_u32 (incr +
667 clib_net_to_host_u32 (dst.
672 int bucket = (incr < 64 ? 0 : 1);
673 dst.ip6.as_u64[bucket] =
674 clib_host_to_net_u64 (incr +
675 clib_net_to_host_u64 (dst.ip6.as_u64
707 u32 table_id, is_add;
719 if (
unformat (line_input,
"%d", &table_id))
721 else if (
unformat (line_input,
"del"))
723 else if (
unformat (line_input,
"add"))
725 else if (
unformat (line_input,
"name %s", &name))
739 else if (0 == table_id)
778 .short_help =
"Internet protocol (IP) commands",
785 .short_help =
"Internet protocol version 6 (IPv6) commands",
792 .short_help =
"Internet protocol (IP) show commands",
799 .short_help =
"Internet protocol version 6 (IPv6) show commands",
833 .short_help =
"ip route [add|del] [count <n>] <dst-ip-addr>/<width> [table <table-id>] [via <next-hop-ip-addr> [<interface>] [weight <weight>]] | [via arp <interface> <adj-hop-ip-addr>] | [via drop|punt|local<id>|arp|classify <classify-idx>] [lookup in table <out-table-id>]",
848 .short_help =
"ip table [add|del] <table-id>",
864 .short_help =
"ip6 table [add|del] <table-id>",
877 u32 sw_if_index, table_id;
889 if (
unformat (input,
"%d", &table_id))
900 if (VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE == rv)
907 else if (VNET_API_ERROR_NO_SUCH_FIB == rv)
958 .path =
"set interface ip table",
960 .short_help =
"set interface ip table <interface> <table-id>",
986 .path =
"set interface ip6 table",
988 .short_help =
"set interface ip6 table <interface> <table-id>" 999 u32 table_id, is_del;
1005 u32 gcount, scount, ss, gg, incr;
1008 gcount = scount = 1;
1012 memset (&pfx, 0,
sizeof (pfx));
1013 memset (&rpath, 0,
sizeof (rpath));
1022 if (
unformat (line_input,
"table %d", &table_id))
1024 else if (
unformat (line_input,
"del"))
1026 else if (
unformat (line_input,
"add"))
1028 else if (
unformat (line_input,
"scount %d", &scount))
1030 else if (
unformat (line_input,
"gcount %d", &gcount))
1032 else if (
unformat (line_input,
"%U %U",
1040 else if (
unformat (line_input,
"%U %U",
1048 else if (
unformat (line_input,
"%U/%d",
1055 else if (
unformat (line_input,
"%U/%d",
1062 else if (
unformat (line_input,
"%U",
1069 else if (
unformat (line_input,
"%U",
1076 else if (
unformat (line_input,
"via %U",
1082 else if (
unformat (line_input,
"via local"))
1090 else if (
unformat (line_input,
"%U",
1111 if (~0 == fib_index)
1122 incr = 1 << (32 - (pfx.
fp_len % 32));
1126 incr = 1 << (128 - (pfx.
fp_len % 128));
1129 for (ss = 0; ss < scount; ss++)
1131 for (gg = 0; gg < gcount; gg++)
1157 clib_host_to_net_u32 (incr +
1158 clib_net_to_host_u32 (pfx.
1164 int bucket = (incr < 64 ? 0 : 1);
1166 clib_host_to_net_u64 (incr +
1167 clib_net_to_host_u64 (pfx.
1168 fp_grp_addr.ip6.as_u64
1176 clib_host_to_net_u32 (1 +
1183 clib_host_to_net_u64 (1 +
1191 if (scount > 1 || gcount > 1)
1193 (scount * gcount) / (timet[1] - timet[0]));
1225 .path =
"ip mroute",
1226 .short_help =
"ip mroute [add|del] <dst-ip-addr>/<width> [table <table-id>] [via <next-hop-ip-addr> [<interface>],",
1246 uword *event_data = 0;
1250 if (retry_count > 0)
1255 for (i = 0; i < retry_count; i++)
1298 uword *event_data = 0;
1302 if (retry_count > 0)
1307 for (i = 0; i < retry_count; i++)
1352 u32 sw_if_index = ~0;
1353 int retry_count = 3;
1355 int address_set = 0;
1366 else if (
unformat (line_input,
"retry %d", &retry_count))
1384 if (sw_if_index == ~0)
1389 if (address_set == 0)
1394 if (address_set > 1)
1429 .path =
"ip probe-neighbor",
1431 .short_help =
"ip probe-neighbor <interface> <ip4-addr> | <ip6-addr> [retry nn]",
static clib_error_t * ip6_probe_neighbor_wait(vlib_main_t *vm, ip6_address_t *a, u32 sw_if_index, int retry_count)
fib_protocol_t fp_proto
protocol type
void mfib_table_entry_delete(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source)
Delete a FIB entry.
clib_error_t * vnet_ip4_table_cmd(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
void ip_null_dpo_add_and_lock(dpo_proto_t proto, ip_null_dpo_action_t action, dpo_id_t *dpo)
void ip_table_create(fib_protocol_t fproto, u32 table_id, u8 is_api, const u8 *name)
ip46_address_t fp_src_addr
sll srl srl sll sra u16x4 i
void receive_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, const ip46_address_t *nh_addr, dpo_id_t *dpo)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
enum mfib_entry_flags_t_ mfib_entry_flags_t
static uword unformat_dpo(unformat_input_t *input, va_list *args)
A representation of a path as described by a route producer.
uword unformat_mfib_itf_flags(unformat_input_t *input, va_list *args)
ip_interface_address_t * if_address_pool
Pool of addresses that are assigned to interfaces.
vnet_main_t * vnet_get_main(void)
static clib_error_t * ip4_probe_neighbor_wait(vlib_main_t *vm, ip4_address_t *a, u32 sw_if_index, int retry_count)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
static f64 vlib_time_now(vlib_main_t *vm)
fib_node_index_t fib_table_entry_path_add2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, fib_route_path_t *rpath)
Add n paths to an entry (aka route) in the FIB.
u32 mpls_label_t
A label value only, i.e.
This packet is to be rewritten and forwarded to the next processing node.
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
fib_node_index_t mfib_table_entry_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, fib_rpf_id_t rpf_id, mfib_entry_flags_t entry_flags)
Add a new (with no replication) or lock an existing entry.
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
mhash_t address_to_if_address_index
Hash table mapping address to index in interface address pool.
format_function_t format_vnet_sw_if_index_name
ip_lookup_next_t
An adjacency is a representation of an attached L3 peer.
static clib_error_t * ip_table_bind_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd, fib_protocol_t fproto)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
clib_error_t * vnet_ip_route_cmd(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
unformat_function_t unformat_mpls_unicast_label
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
int ip_table_bind(fib_protocol_t fproto, u32 sw_if_index, u32 table_id, u8 is_api)
Adjacency to punt this packet.
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
u8 * format_ip_lookup_next(u8 *s, va_list *args)
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
static clib_error_t * ip6_table_bind_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 frp_sw_if_index
The interface.
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
Recursion constraint of via a host prefix.
Aggregrate type for a prefix.
const dpo_id_t * punt_dpo_get(dpo_proto_t proto)
#define clib_error_return(e, args...)
fib_node_index_t mfib_table_entry_path_update(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath, mfib_itf_flags_t itf_flags)
Add n paths to an entry (aka route) in the FIB.
#define clib_error_create(args...)
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
clib_error_t * ip6_probe_neighbor(vlib_main_t *vm, ip6_address_t *dst, u32 sw_if_index)
clib_error_t * ip4_probe_neighbor(vlib_main_t *vm, ip4_address_t *dst, u32 sw_if_index)
vnet_api_error_t api_errno
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
format_function_t format_vnet_sw_interface_name
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
void vnet_register_ip6_neighbor_resolution_event(vnet_main_t *vnm, void *address_arg, uword node_index, uword type_opaque, uword data)
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
index_t classify_dpo_create(dpo_proto_t proto, u32 classify_table_index)
#define pool_put(P, E)
Free an object E in pool P.
void fib_table_entry_path_remove2(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_route_path_t *rpath)
Remove n paths to an entry (aka route) in the FIB.
u8 local_next_by_ip_protocol[256]
Table mapping ip protocol to ip[46]-local node next index.
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Recursion constraint of via an attahced prefix.
static uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
clib_error_t * vnet_ip_table_cmd(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd, fib_protocol_t fproto)
clib_error_t * vnet_ip_mroute_cmd(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
uword unformat_mfib_entry_flags(unformat_input_t *input, va_list *args)
Adjacency to drop this packet.
void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
static vlib_process_t * vlib_get_current_process(vlib_main_t *vm)
#define MPLS_LABEL_INVALID
#define vec_free(V)
Free vector's memory (no header).
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
void ip_table_delete(fib_protocol_t fproto, u32 table_id, u8 is_api)
#define clib_warning(format, args...)
void ip_lookup_init(ip_lookup_main_t *lm, u32 is_ip6)
void vnet_register_ip4_arp_resolution_event(vnet_main_t *vnm, void *address_arg, uword node_index, uword type_opaque, uword data)
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Aggregrate type for a prefix.
u8 builtin_protocol_by_ip_protocol[256]
IP_BUILTIN_PROTOCOL_{TCP,UDP,ICMP,OTHER} by protocol in IP header.
#define VLIB_CLI_COMMAND(x,...)
#define foreach_flow_hash_bit
This packets follow a mid-chain adjacency.
u32 * if_address_pool_index_by_sw_if_index
Head of doubly linked list of interface addresses for each software interface.
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
static uword * mhash_get(mhash_t *h, const void *key)
u8 frp_preference
A path preference.
fib_route_path_flags_t frp_flags
flags on the path
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
static clib_error_t * ip4_table_bind_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
fib_protocol_t fp_proto
protocol type
clib_error_t * vnet_ip6_table_cmd(vlib_main_t *vm, unformat_input_t *main_input, vlib_cli_command_t *cmd)
static clib_error_t * ip_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
u32 mfib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u32 is_ip6
1 for ip6; 0 for ip4.
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
clib_error_t * ip_interface_address_add_del(ip_lookup_main_t *lm, u32 sw_if_index, void *addr_fib, u32 address_length, u32 is_del, u32 *result_if_address_index)
enum mfib_itf_flags_t_ mfib_itf_flags_t
static uword vlib_in_process_context(vlib_main_t *vm)
ip4_main_t ip4_main
Global ip4 main structure.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
u8 * format_ip_flow_hash_config(u8 *s, va_list *args)
static clib_error_t * probe_neighbor_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_ip_adjacency_packet_data(u8 *s, va_list *args)
u16 fp_len
The mask length.
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
void mfib_table_entry_path_remove(u32 fib_index, const mfib_prefix_t *prefix, mfib_source_t source, const fib_route_path_t *rpath)
Remove n paths to an entry (aka route) in the FIB.
u8 frp_weight
[un]equal cost path weight
u32 frp_fib_index
The FIB index to lookup the nexthop Only valid for recursive paths.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(ip_sw_interface_add_del)
const ip46_address_t zero_addr
u32 fib_result_n_bytes
Number of bytes in a fib result.
ip46_address_t fp_grp_addr
The address type is not deriveable from the fp_addr member.
u32 next_this_sw_interface
format_function_t * format_address_and_length
Either format_ip4_address_and_length or format_ip6_address_and_length.
u32 prev_this_sw_interface