summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-04-11 09:55:19 -0700
committerFlorin Coras <florin.coras@gmail.com>2017-04-11 19:20:38 +0000
commit107e7d4b5375295e94e01653e3cf064ea6647064 (patch)
tree7bdda8f00b5e29a70436b70bb005dc5c907c837d /src/vnet/ip
parent3a7956383420a1d2f5f28b5bd3d3b3f5dda0420d (diff)
Remove usued, redundant and deprecated code from lookup.h
Change-Id: Ic16bc10d0b2877b2afdf052615f9334f31b9519f Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/ip4_forward.c19
-rw-r--r--src/vnet/ip/ip4_source_check.c2
-rw-r--r--src/vnet/ip/ip6_forward.c29
-rw-r--r--src/vnet/ip/ip6_hop_by_hop.c8
-rw-r--r--src/vnet/ip/ip6_neighbor.c6
-rwxr-xr-xsrc/vnet/ip/lookup.c35
-rw-r--r--src/vnet/ip/lookup.h29
7 files changed, 33 insertions, 95 deletions
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index 9fdf9b3cee1..e42b36374e4 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -2036,7 +2036,7 @@ ip4_arp_inline (vlib_main_t * vm,
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];
@@ -2276,7 +2276,7 @@ ip4_probe_neighbor (vlib_main_t * vm, ip4_address_t * dst, u32 sw_if_index)
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,
@@ -2465,8 +2465,8 @@ ip4_rewrite_inline (vlib_main_t * 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;
@@ -2571,7 +2571,7 @@ ip4_rewrite_inline (vlib_main_t * vm,
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);
@@ -3003,14 +3003,15 @@ VLIB_CLI_COMMAND (lookup_test_command, static) =
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;
diff --git a/src/vnet/ip/ip4_source_check.c b/src/vnet/ip/ip4_source_check.c
index 6831066e550..63b7594d4e4 100644
--- a/src/vnet/ip/ip4_source_check.c
+++ b/src/vnet/ip/ip4_source_check.c
@@ -492,7 +492,7 @@ ip_source_check_accept (vlib_main_t * vm,
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);
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index a369f79fbb8..90a88b1cc0c 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -1611,7 +1611,7 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
ip0 = vlib_buffer_get_current (p0);
- adj0 = ip_get_adjacency (lm, adj_index0);
+ adj0 = adj_get (adj_index0);
if (!is_glean)
{
@@ -1862,7 +1862,7 @@ ip6_probe_neighbor (vlib_main_t * vm, ip6_address_t * dst, u32 sw_if_index)
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);
@@ -2007,8 +2007,8 @@ ip6_rewrite_inline (vlib_main_t * vm,
{
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;
@@ -2108,7 +2108,7 @@ ip6_rewrite_inline (vlib_main_t * vm,
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);
@@ -2531,8 +2531,6 @@ ip6_hop_by_hop (vlib_main_t * vm,
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;
@@ -2581,9 +2579,9 @@ ip6_hop_by_hop (vlib_main_t * vm,
/* 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;
@@ -2704,7 +2702,7 @@ ip6_hop_by_hop (vlib_main_t * vm,
* 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);
@@ -3114,14 +3112,15 @@ VLIB_CLI_COMMAND (test_link_command, static) =
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;
diff --git a/src/vnet/ip/ip6_hop_by_hop.c b/src/vnet/ip/ip6_hop_by_hop.c
index df2a932e00d..14fbb392e19 100644
--- a/src/vnet/ip/ip6_hop_by_hop.c
+++ b/src/vnet/ip/ip6_hop_by_hop.c
@@ -581,8 +581,6 @@ static uword
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;
@@ -640,8 +638,8 @@ ip6_pop_hop_by_hop_node_fn (vlib_main_t * vm,
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;
@@ -729,7 +727,7 @@ ip6_pop_hop_by_hop_node_fn (vlib_main_t * vm,
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;
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index 58b997aa0db..42edb79a545 100644
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -1001,8 +1001,7 @@ icmp6_neighbor_solicitation_or_advertisement (vlib_main_t * vm,
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;
@@ -1322,8 +1321,7 @@ icmp6_router_solicitation (vlib_main_t * vm,
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
?
diff --git a/src/vnet/ip/lookup.c b/src/vnet/ip/lookup.c
index 597de06b5e3..2321c072620 100755
--- a/src/vnet/ip/lookup.c
+++ b/src/vnet/ip/lookup.c
@@ -191,9 +191,6 @@ VNET_SW_INTERFACE_ADD_DEL_FUNCTION (ip_sw_interface_add_del);
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);
@@ -353,32 +350,6 @@ const ip46_address_t zero_addr = {
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)
@@ -602,7 +573,7 @@ vnet_ip_route_cmd (vlib_main_t * vm,
}
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)
{
@@ -651,8 +622,8 @@ vnet_ip_route_cmd (vlib_main_t * vm,
/*
* 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)
{
diff --git a/src/vnet/ip/lookup.h b/src/vnet/ip/lookup.h
index 662a1cc0066..941a6df965e 100644
--- a/src/vnet/ip/lookup.h
+++ b/src/vnet/ip/lookup.h
@@ -121,12 +121,6 @@ struct ip_lookup_main_t;
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;
@@ -149,17 +143,12 @@ typedef struct ip_lookup_main_t
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];
@@ -167,22 +156,6 @@ typedef struct ip_lookup_main_t
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,
@@ -198,8 +171,6 @@ ip_get_interface_address (ip_lookup_main_t * lm, void *addr_fib)
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)