ip6_hbh_ioam_trace_data_list_handler (vlib_buffer_t * b, ip6_header_t * ip,
ip6_hop_by_hop_option_t * opt)
{
- ip6_main_t *im = &ip6_main;
- ip_lookup_main_t *lm = &im->lookup_main;
ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main;
u8 elt_index = 0;
ioam_trace_option_t *trace = (ioam_trace_option_t *) opt;
u32 adj_index = vnet_buffer (b)->ip.adj_index[VLIB_TX];
- ip_adjacency_t *adj = ip_get_adjacency (lm, adj_index);
+ ip_adjacency_t *adj = adj_get (adj_index);
time_u64_t time_u64;
u32 *elt;
int rv = 0;
continue;
}
- adj0 =
- ip_get_adjacency (&(ip4_main.lookup_main), adj_index0);
+ adj0 = adj_get (adj_index0);
sw_if_index0 = adj0->rewrite_header.sw_if_index;
if (~0 == sw_if_index0)
{
u16 tx_if = 0;
u32 adj_index = vnet_buffer (b)->ip.adj_index[VLIB_TX];
- ip4_main_t *im4 = &ip4_main;
- ip_lookup_main_t *lm = &im4->lookup_main;
+
if (use_adj)
{
- ip_adjacency_t *adj = ip_get_adjacency (lm, adj_index);
+ ip_adjacency_t *adj = adj_get (adj_index);
tx_if = adj->rewrite_header.sw_if_index & 0xFFFF;
}
{
u16 tx_if = 0;
u32 adj_index = vnet_buffer (b)->ip.adj_index[VLIB_TX];
- ip6_main_t *im6 = &ip6_main;
- ip_lookup_main_t *lm = &im6->lookup_main;
+
if (use_adj)
{
- ip_adjacency_t *adj = ip_get_adjacency (lm, adj_index);
+ ip_adjacency_t *adj = adj_get (adj_index);
tx_if = adj->rewrite_header.sw_if_index & 0xFFFF;
}
memset(&adj->sub_type.midchain.next_dpo, 0,
sizeof(adj->sub_type.midchain.next_dpo));
- ip4_main.lookup_main.adjacency_heap = adj_pool;
- ip6_main.lookup_main.adjacency_heap = adj_pool;
-
return (adj);
}
int
vnet_proxy_arp_fib_reset (u32 fib_id)
{
- ip4_main_t *im = &ip4_main;
ethernet_arp_main_t *am = ðernet_arp_main;
ethernet_proxy_arp_t *pa;
u32 *entries_to_delete = 0;
u32 fib_index;
- uword *p;
int i;
- p = hash_get (im->fib_index_by_table_id, fib_id);
- if (!p)
+ fib_index = fib_table_find (FIB_PROTOCOL_IP4, fib_id);
+ if (~0 == fib_index)
return VNET_API_ERROR_NO_SUCH_ENTRY;
- fib_index = p[0];
vec_foreach (pa, am->proxy_arps)
{
else if (unformat (input, "fib-id %d", &fib_id))
{
- ip4_main_t *im = &ip4_main;
- uword *p = hash_get (im->fib_index_by_table_id, fib_id);
- if (!p)
+ fib_index = fib_table_find (FIB_PROTOCOL_IP4, fib_id);
+
+ if (~0 == fib_index)
return clib_error_return (0, "fib ID %d doesn't exist\n", fib_id);
- fib_index = p[0];
}
else if (unformat (input, "proxy %U - %U",
} fp_nh;
/**
* The FIB table index in which to find the next-hop.
- * This needs to be fixed. We should lookup the adjacencies in
- * a separate table of adjacencies, rather than from the FIB.
- * Two reasons I can think of:
- * - consider:
- * int ip addr Gig0 10.0.0.1/24
- * ip route 10.0.0.2/32 via Gig1 192.168.1.2
- * ip route 1.1.1.1/32 via Gig0 10.0.0.2
- * this is perfectly valid.
- * Packets addressed to 10.0.0.2 should be sent via Gig1.
- * Packets address to 1.1.1.1 should be sent via Gig0.
- * when we perform the adj resolution from the FIB for the path
- * "via Gig0 10.0.0.2" the lookup will result in the route via Gig1
- * and so we will pick up the adj via Gig1 - which was not what the
- * operator wanted.
- * - we can only return link-type IPv4 and so not the link-type MPLS.
- * more on this in a later commit.
- *
- * The table ID should only belong to a recursive path and indicate
- * which FIB should be used to resolve the next-hop.
*/
fib_node_index_t fp_tbl_id;
} recursive;
p0 = vlib_get_buffer (vm, pi0);
adj_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
- adj0 = ip_get_adjacency (lm, adj_index0);
+ adj0 = adj_get (adj_index0);
ip0 = vlib_buffer_get_current (p0);
a0 = hash_seeds[0];
sw_if_index);
}
- adj = ip_get_adjacency (&im->lookup_main, ia->neighbor_probe_adj_index);
+ adj = adj_get (ia->neighbor_probe_adj_index);
h =
vlib_packet_template_get_packet (vm,
}
/* Rewrite packet header and updates lengths. */
- adj0 = ip_get_adjacency (lm, adj_index0);
- adj1 = ip_get_adjacency (lm, adj_index1);
+ adj0 = adj_get (adj_index0);
+ adj1 = adj_get (adj_index1);
/* Worth pipelining. No guarantee that adj0,1 are hot... */
rw_len0 = adj0[0].rewrite_header.data_bytes;
adj_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
- adj0 = ip_get_adjacency (lm, adj_index0);
+ adj0 = adj_get (adj_index0);
ip0 = vlib_buffer_get_current (p0);
int
vnet_set_ip4_flow_hash (u32 table_id, u32 flow_hash_config)
{
- ip4_main_t *im4 = &ip4_main;
ip4_fib_t *fib;
- uword *p = hash_get (im4->fib_index_by_table_id, table_id);
+ u32 fib_index;
+
+ fib_index = fib_table_find (FIB_PROTOCOL_IP4, table_id);
- if (p == 0)
+ if (~0 == fib_index)
return VNET_API_ERROR_NO_SUCH_FIB;
- fib = ip4_fib_get (p[0]);
+ fib = ip4_fib_get (fib_index);
fib->flow_hash_config = flow_hash_config;
return 0;
if (~0 != table_id)
{
- fib_index = fib_table_id_find_fib_index (pfx.fp_proto, table_id);
+ fib_index = fib_table_find (pfx.fp_proto, table_id);
if (~0 == fib_index)
{
error = clib_error_return (0, "Nonexistent table id %d", table_id);
ip0 = vlib_buffer_get_current (p0);
- adj0 = ip_get_adjacency (lm, adj_index0);
+ adj0 = adj_get (adj_index0);
if (!is_glean)
{
vnet_buffer (b)->sw_if_index[VLIB_TX] = sw_if_index;
/* Add encapsulation string for software interface (e.g. ethernet header). */
- adj = ip_get_adjacency (&im->lookup_main, ia->neighbor_probe_adj_index);
+ adj = adj_get (ia->neighbor_probe_adj_index);
vnet_rewrite_one_header (adj[0], h, sizeof (ethernet_header_t));
vlib_buffer_advance (b, -adj->rewrite_header.data_bytes);
{
p1->flags &= ~VNET_BUFFER_LOCALLY_ORIGINATED;
}
- adj0 = ip_get_adjacency (lm, adj_index0);
- adj1 = ip_get_adjacency (lm, adj_index1);
+ adj0 = adj_get (adj_index0);
+ adj1 = adj_get (adj_index1);
rw_len0 = adj0[0].rewrite_header.data_bytes;
rw_len1 = adj1[0].rewrite_header.data_bytes;
adj_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
- adj0 = ip_get_adjacency (lm, adj_index0);
+ adj0 = adj_get (adj_index0);
ip0 = vlib_buffer_get_current (p0);
ip6_hop_by_hop_main_t *hm = &ip6_hop_by_hop_main;
u32 n_left_from, *from, *to_next;
ip_lookup_next_t next_index;
- ip6_main_t *im = &ip6_main;
- ip_lookup_main_t *lm = &im->lookup_main;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
/* Default use the next_index from the adjacency. A HBH option rarely redirects to a different node */
u32 adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
- ip_adjacency_t *adj0 = ip_get_adjacency (lm, adj_index0);
+ ip_adjacency_t *adj0 = adj_get (adj_index0);
u32 adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
- ip_adjacency_t *adj1 = ip_get_adjacency (lm, adj_index1);
+ ip_adjacency_t *adj1 = adj_get (adj_index1);
/* Default use the next_index from the adjacency. A HBH option rarely redirects to a different node */
next0 = adj0->lookup_next_index;
* A HBH option rarely redirects to a different node
*/
u32 adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
- ip_adjacency_t *adj0 = ip_get_adjacency (lm, adj_index0);
+ ip_adjacency_t *adj0 = adj_get (adj_index0);
next0 = adj0->lookup_next_index;
ip0 = vlib_buffer_get_current (b0);
int
vnet_set_ip6_flow_hash (u32 table_id, u32 flow_hash_config)
{
- ip6_main_t *im6 = &ip6_main;
ip6_fib_t *fib;
- uword *p = hash_get (im6->fib_index_by_table_id, table_id);
+ u32 fib_index;
+
+ fib_index = fib_table_find (FIB_PROTOCOL_IP6, table_id);
- if (p == 0)
- return -1;
+ if (~0 == fib_index)
+ return VNET_API_ERROR_NO_SUCH_FIB;
- fib = ip6_fib_get (p[0]);
+ fib = ip6_fib_get (fib_index);
fib->flow_hash_config = flow_hash_config;
return 1;
ip6_pop_hop_by_hop_node_fn (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
- ip6_main_t *im = &ip6_main;
- ip_lookup_main_t *lm = &im->lookup_main;
u32 n_left_from, *from, *to_next;
ip_lookup_next_t next_index;
u32 processed = 0;
ip1 = vlib_buffer_get_current (b1);
adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
- adj0 = ip_get_adjacency (lm, adj_index0);
- adj1 = ip_get_adjacency (lm, adj_index1);
+ adj0 = adj_get (adj_index0);
+ adj1 = adj_get (adj_index1);
next0 = adj0->lookup_next_index;
next1 = adj1->lookup_next_index;
ip0 = vlib_buffer_get_current (b0);
adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
- adj0 = ip_get_adjacency (lm, adj_index0);
+ adj0 = adj_get (adj_index0);
/* Default use the next_index from the adjacency. */
next0 = adj0->lookup_next_index;
if (ADJ_INDEX_INVALID != src_adj_index0)
{
- ip_adjacency_t *adj0 =
- ip_get_adjacency (&im->lookup_main, src_adj_index0);
+ ip_adjacency_t *adj0 = adj_get (src_adj_index0);
/* Allow all realistic-looking rewrite adjacencies to pass */
ni0 = adj0->lookup_next_index;
if (ADJ_INDEX_INVALID != src_adj_index0)
{
- ip_adjacency_t *adj0 = ip_get_adjacency (&im->lookup_main,
- src_adj_index0);
+ ip_adjacency_t *adj0 = adj_get (src_adj_index0);
error0 = (adj0->rewrite_header.sw_if_index != sw_if_index0
?
void
ip_lookup_init (ip_lookup_main_t * lm, u32 is_ip6)
{
- /* Preallocate three "special" adjacencies */
- lm->adjacency_heap = adj_pool;
-
if (!lm->fib_result_n_bytes)
lm->fib_result_n_bytes = sizeof (uword);
0, 0},
};
-u32
-fib_table_id_find_fib_index (fib_protocol_t proto, u32 table_id)
-{
- ip4_main_t *im4 = &ip4_main;
- ip6_main_t *im6 = &ip6_main;
- uword *p;
-
- switch (proto)
- {
- case FIB_PROTOCOL_IP4:
- p = hash_get (im4->fib_index_by_table_id, table_id);
- break;
- case FIB_PROTOCOL_IP6:
- p = hash_get (im6->fib_index_by_table_id, table_id);
- break;
- default:
- p = NULL;
- break;
- }
- if (NULL != p)
- {
- return (p[0]);
- }
- return (~0);
-}
-
clib_error_t *
vnet_ip_route_cmd (vlib_main_t * vm,
unformat_input_t * main_input, vlib_cli_command_t * cmd)
}
else
{
- fib_index = fib_table_id_find_fib_index (prefixs[0].fp_proto, table_id);
+ fib_index = fib_table_find (prefixs[0].fp_proto, table_id);
if (~0 == fib_index)
{
/*
* the CLI parsing stored table Ids, swap to FIB indicies
*/
- fi = fib_table_id_find_fib_index (prefixs[i].fp_proto,
- rpaths[i].frp_fib_index);
+ fi = fib_table_find (prefixs[i].fp_proto,
+ rpaths[i].frp_fib_index);
if (~0 == fi)
{
typedef struct ip_lookup_main_t
{
- /* Adjacency heap. */
- ip_adjacency_t *adjacency_heap;
-
- /** load-balance packet/byte counters indexed by LB index. */
- vlib_combined_counter_main_t load_balance_counters;
-
/** Pool of addresses that are assigned to interfaces. */
ip_interface_address_t *if_address_pool;
sizeof (uword). First word is always adjacency index. */
u32 fib_result_n_bytes, fib_result_n_words;
- format_function_t *format_fib_result;
-
/** 1 for ip6; 0 for ip4. */
u32 is_ip6;
/** Either format_ip4_address_and_length or format_ip6_address_and_length. */
format_function_t *format_address_and_length;
- /** Special adjacency format functions */
- format_function_t **special_adjacency_format_functions;
-
/** Table mapping ip protocol to ip[46]-local node next index. */
u8 local_next_by_ip_protocol[256];
u8 builtin_protocol_by_ip_protocol[256];
} ip_lookup_main_t;
-always_inline ip_adjacency_t *
-ip_get_adjacency (ip_lookup_main_t * lm, u32 adj_index)
-{
- ip_adjacency_t *adj;
-
- adj = vec_elt_at_index (lm->adjacency_heap, adj_index);
-
- return adj;
-}
-
-#define ip_prefetch_adjacency(lm,adj_index,type) \
-do { \
- ip_adjacency_t * _adj = (lm)->adjacency_heap + (adj_index); \
- CLIB_PREFETCH (_adj, sizeof (_adj[0]), type); \
-} while (0)
-
clib_error_t *ip_interface_address_add_del (ip_lookup_main_t * lm,
u32 sw_if_index,
void *address,
return p ? pool_elt_at_index (lm->if_address_pool, p[0]) : 0;
}
-u32 fib_table_id_find_fib_index (fib_protocol_t proto, u32 table_id);
-
always_inline void *
ip_interface_address_get_address (ip_lookup_main_t * lm,
ip_interface_address_t * a)
*/
if (FIB_NODE_INDEX_INVALID == rpath.frp_sw_if_index)
{
- fi = fib_table_id_find_fib_index(dpo_proto_to_fib(pfx.fp_payload_proto),
- rpaths[0].frp_fib_index);
+ fi = fib_table_find(dpo_proto_to_fib(pfx.fp_payload_proto),
+ rpaths[0].frp_fib_index);
if (~0 == fi)
{
}
};
- fib_table_entry_delete (fib_table_id_find_fib_index
- (FIB_PROTOCOL_IP6, fib_table), &pfx,
- FIB_SOURCE_SR);
+ fib_table_entry_delete (fib_table_find (FIB_PROTOCOL_IP6,
+ fib_table),
+ &pfx, FIB_SOURCE_SR);
/* In case it is a Xconnect iface remove the (OIF, NHOP) adj */
if (ls->behavior == SR_BEHAVIOR_X || ls->behavior == SR_BEHAVIOR_DX6
pfx.fp_addr.as_u64[1] = localsid_addr->as_u64[1];
/* Lookup the FIB index associated to the table id provided */
- u32 fib_index = fib_table_id_find_fib_index (FIB_PROTOCOL_IP6, fib_table);
+ u32 fib_index = fib_table_find (FIB_PROTOCOL_IP6, fib_table);
if (fib_index == ~0)
return -3;
load_balance_create (0, DPO_PROTO_IP6, fhc));
/* Update FIB entry's to point to the LB DPO in the main FIB and hidden one */
- fib_table_entry_special_dpo_update (fib_table_id_find_fib_index
- (FIB_PROTOCOL_IP6,
- sr_policy->fib_table), &pfx,
- FIB_SOURCE_SR,
+ fib_table_entry_special_dpo_update (fib_table_find (FIB_PROTOCOL_IP6,
+ sr_policy->fib_table),
+ &pfx, FIB_SOURCE_SR,
FIB_ENTRY_FLAG_EXCLUSIVE,
&sr_policy->bsid_dpo);
.ip6 = sr_policy->bsid,
}
};
- fib_table_entry_special_dpo_update (fib_table_id_find_fib_index
- (FIB_PROTOCOL_IP6,
- sr_policy->fib_table), &pfx,
- FIB_SOURCE_SR,
+ fib_table_entry_special_dpo_update (fib_table_find (FIB_PROTOCOL_IP6,
+ sr_policy->fib_table),
+ &pfx, FIB_SOURCE_SR,
FIB_ENTRY_FLAG_EXCLUSIVE,
&sr_policy->bsid_dpo);
};
/* Lookup the FIB index associated to the table selected */
- u32 fib_index = fib_table_id_find_fib_index (FIB_PROTOCOL_IP6,
- (fib_table !=
- (u32) ~ 0 ? fib_table : 0));
+ u32 fib_index = fib_table_find (FIB_PROTOCOL_IP6,
+ (fib_table != (u32) ~ 0 ? fib_table : 0));
if (fib_index == ~0)
return -13;
,
};
- fib_table_entry_special_remove (fib_table_id_find_fib_index
- (FIB_PROTOCOL_IP6, sr_policy->fib_table),
+ fib_table_entry_special_remove (fib_table_find (FIB_PROTOCOL_IP6,
+ sr_policy->fib_table),
&pfx, FIB_SOURCE_SR);
fib_table_entry_special_remove (sm->fib_table_ip6, &pfx, FIB_SOURCE_SR);
pfx.fp_len = steer_pl->classify.l3.mask_width;
pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
- fib_table_entry_delete (fib_table_id_find_fib_index
+ fib_table_entry_delete (fib_table_find
(FIB_PROTOCOL_IP6,
- steer_pl->classify.l3.fib_table), &pfx,
- FIB_SOURCE_SR);
+ steer_pl->classify.l3.fib_table),
+ &pfx, FIB_SOURCE_SR);
}
else if (steer_pl->classify.traffic_type == SR_STEER_IPV4)
{
pfx.fp_len = steer_pl->classify.l3.mask_width;
pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
- fib_table_entry_delete (fib_table_id_find_fib_index
+ fib_table_entry_delete (fib_table_find
(FIB_PROTOCOL_IP4,
steer_pl->classify.l3.fib_table), &pfx,
FIB_SOURCE_SR);
pfx.fp_len = steer_pl->classify.l3.mask_width;
pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
- fib_table_entry_delete (fib_table_id_find_fib_index
+ fib_table_entry_delete (fib_table_find
(FIB_PROTOCOL_IP6,
- steer_pl->classify.l3.fib_table), &pfx,
- FIB_SOURCE_SR);
+ steer_pl->classify.l3.fib_table),
+ &pfx, FIB_SOURCE_SR);
/* Create a new one */
goto update_fib;
pfx.fp_len = steer_pl->classify.l3.mask_width;
pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
- fib_table_entry_delete (fib_table_id_find_fib_index
+ fib_table_entry_delete (fib_table_find
(FIB_PROTOCOL_IP4,
- steer_pl->classify.l3.fib_table), &pfx,
- FIB_SOURCE_SR);
+ steer_pl->classify.l3.fib_table),
+ &pfx, FIB_SOURCE_SR);
/* Create a new one */
goto update_fib;
pfx.fp_len = steer_pl->classify.l3.mask_width;
pfx.fp_addr.ip6 = steer_pl->classify.l3.prefix.ip6;
- fib_table_entry_path_add (fib_table_id_find_fib_index (FIB_PROTOCOL_IP6,
- (table_id !=
- (u32) ~ 0 ?
- table_id : 0)),
+ fib_table_entry_path_add (fib_table_find (FIB_PROTOCOL_IP6,
+ (table_id !=
+ (u32) ~ 0 ?
+ table_id : 0)),
&pfx, FIB_SOURCE_SR,
FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT,
FIB_PROTOCOL_IP6,
pfx.fp_len = steer_pl->classify.l3.mask_width;
pfx.fp_addr.ip4 = steer_pl->classify.l3.prefix.ip4;
- fib_table_entry_path_add (fib_table_id_find_fib_index (FIB_PROTOCOL_IP4,
- (table_id !=
- (u32) ~ 0 ?
- table_id : 0)),
+ fib_table_entry_path_add (fib_table_find (FIB_PROTOCOL_IP4,
+ (table_id !=
+ (u32) ~ 0 ?
+ table_id : 0)),
&pfx, FIB_SOURCE_SR,
FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT,
FIB_PROTOCOL_IP6,