summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/lisp-gpe/decap.c603
-rw-r--r--vnet/vnet/lisp-gpe/interface.c1092
-rw-r--r--vnet/vnet/lisp-gpe/ip_forward.c1440
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe.c719
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe.h109
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe_packet.h18
6 files changed, 2046 insertions, 1935 deletions
diff --git a/vnet/vnet/lisp-gpe/decap.c b/vnet/vnet/lisp-gpe/decap.c
index 132262ebd09..2d051af49db 100644
--- a/vnet/vnet/lisp-gpe/decap.c
+++ b/vnet/vnet/lisp-gpe/decap.c
@@ -30,49 +30,48 @@ format_lisp_gpe_rx_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- lisp_gpe_rx_trace_t * t = va_arg (*args, lisp_gpe_rx_trace_t *);
+ lisp_gpe_rx_trace_t *t = va_arg (*args, lisp_gpe_rx_trace_t *);
if (t->tunnel_index != ~0)
{
s = format (s, "LISP-GPE: tunnel %d next %d error %d", t->tunnel_index,
- t->next_index, t->error);
+ t->next_index, t->error);
}
else
{
s = format (s, "LISP-GPE: no tunnel next %d error %d\n", t->next_index,
- t->error);
+ t->error);
}
s = format (s, "\n %U", format_lisp_gpe_header_with_length, &t->h,
- (u32) sizeof (t->h) /* max size */);
+ (u32) sizeof (t->h) /* max size */ );
return s;
}
-static u32
-next_proto_to_next_index[LISP_GPE_NEXT_PROTOS] = {
- LISP_GPE_INPUT_NEXT_DROP,
- LISP_GPE_INPUT_NEXT_IP4_INPUT,
- LISP_GPE_INPUT_NEXT_IP6_INPUT,
- LISP_GPE_INPUT_NEXT_L2_INPUT,
- LISP_GPE_INPUT_NEXT_DROP
+static u32 next_proto_to_next_index[LISP_GPE_NEXT_PROTOS] = {
+ LISP_GPE_INPUT_NEXT_DROP,
+ LISP_GPE_INPUT_NEXT_IP4_INPUT,
+ LISP_GPE_INPUT_NEXT_IP6_INPUT,
+ LISP_GPE_INPUT_NEXT_L2_INPUT,
+ LISP_GPE_INPUT_NEXT_DROP
};
always_inline u32
next_protocol_to_next_index (lisp_gpe_header_t * lgh, u8 * next_header)
{
/* lisp-gpe router */
- if (PREDICT_TRUE((lgh->flags & LISP_GPE_FLAGS_P)
- && lgh->next_protocol < LISP_GPE_NEXT_PROTOS))
+ if (PREDICT_TRUE ((lgh->flags & LISP_GPE_FLAGS_P)
+ && lgh->next_protocol < LISP_GPE_NEXT_PROTOS))
return next_proto_to_next_index[lgh->next_protocol];
/* legacy lisp router */
else if ((lgh->flags & LISP_GPE_FLAGS_P) == 0)
{
- ip4_header_t * iph = (ip4_header_t *) next_header;
+ ip4_header_t *iph = (ip4_header_t *) next_header;
if ((iph->ip_version_and_header_length & 0xF0) == 0x40)
- return LISP_GPE_INPUT_NEXT_IP4_INPUT;
+ return LISP_GPE_INPUT_NEXT_IP4_INPUT;
else if ((iph->ip_version_and_header_length & 0xF0) == 0x60)
- return LISP_GPE_INPUT_NEXT_IP6_INPUT;
+ return LISP_GPE_INPUT_NEXT_IP6_INPUT;
else
- return LISP_GPE_INPUT_NEXT_DROP;
+ return LISP_GPE_INPUT_NEXT_DROP;
}
else
return LISP_GPE_INPUT_NEXT_DROP;
@@ -86,31 +85,33 @@ next_index_to_iface (lisp_gpe_main_t * lgm, u32 next_index)
return &lgm->l3_ifaces;
else if (LISP_GPE_INPUT_NEXT_L2_INPUT == next_index)
return &lgm->l2_ifaces;
- clib_warning("next_index not associated to an interface!");
+ clib_warning ("next_index not associated to an interface!");
return 0;
}
static_always_inline void
-incr_decap_stats (vnet_main_t * vnm, u32 cpu_index, u32 length, u32 sw_if_index,
- u32 * last_sw_if_index, u32 * n_packets, u32 * n_bytes)
+incr_decap_stats (vnet_main_t * vnm, u32 cpu_index, u32 length,
+ u32 sw_if_index, u32 * last_sw_if_index, u32 * n_packets,
+ u32 * n_bytes)
{
- vnet_interface_main_t * im;
+ vnet_interface_main_t *im;
- if (PREDICT_TRUE(sw_if_index == *last_sw_if_index))
+ if (PREDICT_TRUE (sw_if_index == *last_sw_if_index))
{
*n_packets += 1;
*n_bytes += length;
}
else
{
- if (PREDICT_TRUE(*last_sw_if_index != ~0))
- {
- im = &vnm->interface_main;
-
- vlib_increment_combined_counter (
- im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, *last_sw_if_index, *n_packets, *n_bytes);
- }
+ if (PREDICT_TRUE (*last_sw_if_index != ~0))
+ {
+ im = &vnm->interface_main;
+
+ vlib_increment_combined_counter (im->combined_sw_if_counters +
+ VNET_INTERFACE_COUNTER_RX,
+ cpu_index, *last_sw_if_index,
+ *n_packets, *n_bytes);
+ }
*last_sw_if_index = sw_if_index;
*n_packets = 1;
*n_bytes = length;
@@ -119,13 +120,13 @@ incr_decap_stats (vnet_main_t * vnm, u32 cpu_index, u32 length, u32 sw_if_index,
static uword
lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * from_frame, u8 is_v4)
+ vlib_frame_t * from_frame, u8 is_v4)
{
- u32 n_left_from, next_index, * from, * to_next, cpu_index;
+ u32 n_left_from, next_index, *from, *to_next, cpu_index;
u32 n_bytes = 0, n_packets = 0, last_sw_if_index = ~0, drops = 0;
- lisp_gpe_main_t * lgm = vnet_lisp_gpe_get_main ();
+ lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
- cpu_index = os_get_cpu_number();
+ cpu_index = os_get_cpu_number ();
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -135,292 +136,299 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
{
u32 n_left_to_next;
- vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- ip4_udp_lisp_gpe_header_t * iul4_0, * iul4_1;
- ip6_udp_lisp_gpe_header_t * iul6_0, * iul6_1;
- lisp_gpe_header_t * lh0, * lh1;
- u32 next0, next1, error0, error1;
- uword * si0, * si1;
- tunnel_lookup_t * tl0, * tl1;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t * p2, * p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
-
- vlib_prefetch_buffer_header (p2, LOAD);
- vlib_prefetch_buffer_header (p3, LOAD);
-
- CLIB_PREFETCH (p2->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- CLIB_PREFETCH (p3->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- }
-
- bi0 = from[0];
- bi1 = from[1];
- to_next[0] = bi0;
- to_next[1] = bi1;
- from += 2;
- to_next += 2;
- n_left_to_next -= 2;
- n_left_from -= 2;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
-
- /* udp leaves current_data pointing at the lisp header */
- if (is_v4)
- {
- vlib_buffer_advance (
- b0, -(word) (sizeof(udp_header_t) + sizeof(ip4_header_t)));
- vlib_buffer_advance (
- b1, -(word) (sizeof(udp_header_t) + sizeof(ip4_header_t)));
-
- iul4_0 = vlib_buffer_get_current (b0);
- iul4_1 = vlib_buffer_get_current (b1);
-
- /* pop (ip, udp, lisp-gpe) */
- vlib_buffer_advance (b0, sizeof(*iul4_0));
- vlib_buffer_advance (b1, sizeof(*iul4_1));
-
- lh0 = &iul4_0->lisp;
- lh1 = &iul4_1->lisp;
- }
- else
- {
- vlib_buffer_advance (
- b0, -(word) (sizeof(udp_header_t) + sizeof(ip6_header_t)));
- vlib_buffer_advance (
- b1, -(word) (sizeof(udp_header_t) + sizeof(ip6_header_t)));
-
- iul6_0 = vlib_buffer_get_current (b0);
- iul6_1 = vlib_buffer_get_current (b1);
-
- /* pop (ip, udp, lisp-gpe) */
- vlib_buffer_advance (b0, sizeof(*iul6_0));
- vlib_buffer_advance (b1, sizeof(*iul6_1));
-
- lh0 = &iul6_0->lisp;
- lh1 = &iul6_1->lisp;
- }
-
- /* determine next_index from lisp-gpe header */
- next0 = next_protocol_to_next_index (lh0,
- vlib_buffer_get_current (b0));
- next1 = next_protocol_to_next_index (lh1,
- vlib_buffer_get_current (b1));
-
- /* determine if tunnel is l2 or l3 */
- tl0 = next_index_to_iface(lgm, next0);
- tl1 = next_index_to_iface(lgm, next1);
-
- /* map iid/vni to lisp-gpe sw_if_index which is used by ipx_input to
- * decide the rx vrf and the input features to be applied */
- si0 = hash_get(tl0->sw_if_index_by_vni,
- clib_net_to_host_u32 (lh0->iid));
- si1 = hash_get(tl1->sw_if_index_by_vni,
- clib_net_to_host_u32 (lh1->iid));
-
-
- /* Required to make the l2 tag push / pop code work on l2 subifs */
- vnet_update_l2_len (b0);
- vnet_update_l2_len (b1);
-
- if (si0)
- {
- incr_decap_stats (lgm->vnet_main, cpu_index,
- vlib_buffer_length_in_chain (vm, b0), si0[0],
- &last_sw_if_index, &n_packets, &n_bytes);
- vnet_buffer(b0)->sw_if_index[VLIB_RX] = si0[0];
- error0 = 0;
- }
- else
- {
- next0 = LISP_GPE_INPUT_NEXT_DROP;
- error0 = LISP_GPE_ERROR_NO_TUNNEL;
- drops++;
- }
-
- if (si1)
- {
- incr_decap_stats (lgm->vnet_main, cpu_index,
- vlib_buffer_length_in_chain (vm, b1), si1[0],
- &last_sw_if_index, &n_packets, &n_bytes);
- vnet_buffer(b1)->sw_if_index[VLIB_RX] = si1[0];
- error1 = 0;
- }
- else
- {
- next1 = LISP_GPE_INPUT_NEXT_DROP;
- error1 = LISP_GPE_ERROR_NO_TUNNEL;
- drops++;
- }
-
- b0->error = error0 ? node->errors[error0] : 0;
- b1->error = error1 ? node->errors[error1] : 0;
-
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- lisp_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0,
- sizeof(*tr));
- tr->next_index = next0;
- tr->error = error0;
- tr->h = lh0[0];
- }
-
- if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
- {
- lisp_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b1,
- sizeof(*tr));
- tr->next_index = next1;
- tr->error = error1;
- tr->h = lh1[0];
- }
-
- vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
- n_left_to_next, bi0, bi1, next0,
- next1);
- }
-
+ {
+ u32 bi0, bi1;
+ vlib_buffer_t *b0, *b1;
+ ip4_udp_lisp_gpe_header_t *iul4_0, *iul4_1;
+ ip6_udp_lisp_gpe_header_t *iul6_0, *iul6_1;
+ lisp_gpe_header_t *lh0, *lh1;
+ u32 next0, next1, error0, error1;
+ uword *si0, *si1;
+ tunnel_lookup_t *tl0, *tl1;
+
+ /* Prefetch next iteration. */
+ {
+ vlib_buffer_t *p2, *p3;
+
+ p2 = vlib_get_buffer (vm, from[2]);
+ p3 = vlib_get_buffer (vm, from[3]);
+
+ vlib_prefetch_buffer_header (p2, LOAD);
+ vlib_prefetch_buffer_header (p3, LOAD);
+
+ CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ }
+
+ bi0 = from[0];
+ bi1 = from[1];
+ to_next[0] = bi0;
+ to_next[1] = bi1;
+ from += 2;
+ to_next += 2;
+ n_left_to_next -= 2;
+ n_left_from -= 2;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+
+ /* udp leaves current_data pointing at the lisp header */
+ if (is_v4)
+ {
+ vlib_buffer_advance (b0,
+ -(word) (sizeof (udp_header_t) +
+ sizeof (ip4_header_t)));
+ vlib_buffer_advance (b1,
+ -(word) (sizeof (udp_header_t) +
+ sizeof (ip4_header_t)));
+
+ iul4_0 = vlib_buffer_get_current (b0);
+ iul4_1 = vlib_buffer_get_current (b1);
+
+ /* pop (ip, udp, lisp-gpe) */
+ vlib_buffer_advance (b0, sizeof (*iul4_0));
+ vlib_buffer_advance (b1, sizeof (*iul4_1));
+
+ lh0 = &iul4_0->lisp;
+ lh1 = &iul4_1->lisp;
+ }
+ else
+ {
+ vlib_buffer_advance (b0,
+ -(word) (sizeof (udp_header_t) +
+ sizeof (ip6_header_t)));
+ vlib_buffer_advance (b1,
+ -(word) (sizeof (udp_header_t) +
+ sizeof (ip6_header_t)));
+
+ iul6_0 = vlib_buffer_get_current (b0);
+ iul6_1 = vlib_buffer_get_current (b1);
+
+ /* pop (ip, udp, lisp-gpe) */
+ vlib_buffer_advance (b0, sizeof (*iul6_0));
+ vlib_buffer_advance (b1, sizeof (*iul6_1));
+
+ lh0 = &iul6_0->lisp;
+ lh1 = &iul6_1->lisp;
+ }
+
+ /* determine next_index from lisp-gpe header */
+ next0 = next_protocol_to_next_index (lh0,
+ vlib_buffer_get_current (b0));
+ next1 = next_protocol_to_next_index (lh1,
+ vlib_buffer_get_current (b1));
+
+ /* determine if tunnel is l2 or l3 */
+ tl0 = next_index_to_iface (lgm, next0);
+ tl1 = next_index_to_iface (lgm, next1);
+
+ /* map iid/vni to lisp-gpe sw_if_index which is used by ipx_input to
+ * decide the rx vrf and the input features to be applied */
+ si0 = hash_get (tl0->sw_if_index_by_vni,
+ clib_net_to_host_u32 (lh0->iid));
+ si1 = hash_get (tl1->sw_if_index_by_vni,
+ clib_net_to_host_u32 (lh1->iid));
+
+
+ /* Required to make the l2 tag push / pop code work on l2 subifs */
+ vnet_update_l2_len (b0);
+ vnet_update_l2_len (b1);
+
+ if (si0)
+ {
+ incr_decap_stats (lgm->vnet_main, cpu_index,
+ vlib_buffer_length_in_chain (vm, b0), si0[0],
+ &last_sw_if_index, &n_packets, &n_bytes);
+ vnet_buffer (b0)->sw_if_index[VLIB_RX] = si0[0];
+ error0 = 0;
+ }
+ else
+ {
+ next0 = LISP_GPE_INPUT_NEXT_DROP;
+ error0 = LISP_GPE_ERROR_NO_TUNNEL;
+ drops++;
+ }
+
+ if (si1)
+ {
+ incr_decap_stats (lgm->vnet_main, cpu_index,
+ vlib_buffer_length_in_chain (vm, b1), si1[0],
+ &last_sw_if_index, &n_packets, &n_bytes);
+ vnet_buffer (b1)->sw_if_index[VLIB_RX] = si1[0];
+ error1 = 0;
+ }
+ else
+ {
+ next1 = LISP_GPE_INPUT_NEXT_DROP;
+ error1 = LISP_GPE_ERROR_NO_TUNNEL;
+ drops++;
+ }
+
+ b0->error = error0 ? node->errors[error0] : 0;
+ b1->error = error1 ? node->errors[error1] : 0;
+
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ lisp_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0,
+ sizeof (*tr));
+ tr->next_index = next0;
+ tr->error = error0;
+ tr->h = lh0[0];
+ }
+
+ if (PREDICT_FALSE (b1->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ lisp_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b1,
+ sizeof (*tr));
+ tr->next_index = next1;
+ tr->error = error1;
+ tr->h = lh1[0];
+ }
+
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
+ }
+
while (n_left_from > 0 && n_left_to_next > 0)
- {
- u32 bi0;
- vlib_buffer_t * b0;
- u32 next0;
- ip4_udp_lisp_gpe_header_t * iul4_0;
- ip6_udp_lisp_gpe_header_t * iul6_0;
- lisp_gpe_header_t * lh0;
- u32 error0;
- uword * si0;
- tunnel_lookup_t * tl0;
-
- bi0 = from[0];
- to_next[0] = bi0;
- from += 1;
- to_next += 1;
- n_left_from -= 1;
- n_left_to_next -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
-
- /* udp leaves current_data pointing at the lisp header
- * TODO: there's no difference in processing between v4 and v6
- * encapsulated packets so the code should be simplified if ip header
- * info is not going to be used for dp smrs/dpsec */
- if (is_v4)
- {
- vlib_buffer_advance (
- b0, -(word) (sizeof(udp_header_t) + sizeof(ip4_header_t)));
-
- iul4_0 = vlib_buffer_get_current (b0);
-
- /* pop (ip, udp, lisp-gpe) */
- vlib_buffer_advance (b0, sizeof(*iul4_0));
-
- lh0 = &iul4_0->lisp;
- }
- else
- {
- vlib_buffer_advance (
- b0, -(word) (sizeof(udp_header_t) + sizeof(ip6_header_t)));
-
- iul6_0 = vlib_buffer_get_current (b0);
-
- /* pop (ip, udp, lisp-gpe) */
- vlib_buffer_advance (b0, sizeof(*iul6_0));
-
- lh0 = &iul6_0->lisp;
- }
-
- /* TODO if security is to be implemented, something similar to RPF,
- * probably we'd like to check that the peer is allowed to send us
- * packets. For this, we should use the tunnel table OR check that
- * we have a mapping for the source eid and that the outer source of
- * the packet is one of its locators */
-
- /* determine next_index from lisp-gpe header */
- next0 = next_protocol_to_next_index (lh0,
- vlib_buffer_get_current (b0));
-
- /* determine if tunnel is l2 or l3 */
- tl0 = next_index_to_iface(lgm, next0);
-
- /* map iid/vni to lisp-gpe sw_if_index which is used by ipx_input to
- * decide the rx vrf and the input features to be applied */
- si0 = hash_get(tl0->sw_if_index_by_vni,
- clib_net_to_host_u32 (lh0->iid));
-
- /* Required to make the l2 tag push / pop code work on l2 subifs */
- vnet_update_l2_len (b0);
-
- if (si0)
- {
- incr_decap_stats (lgm->vnet_main, cpu_index,
- vlib_buffer_length_in_chain (vm, b0), si0[0],
- &last_sw_if_index, &n_packets, &n_bytes);
- vnet_buffer(b0)->sw_if_index[VLIB_RX] = si0[0];
- error0 = 0;
- }
- else
- {
- next0 = LISP_GPE_INPUT_NEXT_DROP;
- error0 = LISP_GPE_ERROR_NO_TUNNEL;
- drops++;
- }
-
- /* TODO error handling if security is implemented */
- b0->error = error0 ? node->errors[error0] : 0;
-
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- lisp_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0,
- sizeof(*tr));
- tr->next_index = next0;
- tr->error = error0;
- tr->h = lh0[0];
- }
-
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
- n_left_to_next, bi0, next0);
- }
+ {
+ u32 bi0;
+ vlib_buffer_t *b0;
+ u32 next0;
+ ip4_udp_lisp_gpe_header_t *iul4_0;
+ ip6_udp_lisp_gpe_header_t *iul6_0;
+ lisp_gpe_header_t *lh0;
+ u32 error0;
+ uword *si0;
+ tunnel_lookup_t *tl0;
+
+ bi0 = from[0];
+ to_next[0] = bi0;
+ from += 1;
+ to_next += 1;
+ n_left_from -= 1;
+ n_left_to_next -= 1;
+
+ b0 = vlib_get_buffer (vm, bi0);
+
+ /* udp leaves current_data pointing at the lisp header
+ * TODO: there's no difference in processing between v4 and v6
+ * encapsulated packets so the code should be simplified if ip header
+ * info is not going to be used for dp smrs/dpsec */
+ if (is_v4)
+ {
+ vlib_buffer_advance (b0,
+ -(word) (sizeof (udp_header_t) +
+ sizeof (ip4_header_t)));
+
+ iul4_0 = vlib_buffer_get_current (b0);
+
+ /* pop (ip, udp, lisp-gpe) */
+ vlib_buffer_advance (b0, sizeof (*iul4_0));
+
+ lh0 = &iul4_0->lisp;
+ }
+ else
+ {
+ vlib_buffer_advance (b0,
+ -(word) (sizeof (udp_header_t) +
+ sizeof (ip6_header_t)));
+
+ iul6_0 = vlib_buffer_get_current (b0);
+
+ /* pop (ip, udp, lisp-gpe) */
+ vlib_buffer_advance (b0, sizeof (*iul6_0));
+
+ lh0 = &iul6_0->lisp;
+ }
+
+ /* TODO if security is to be implemented, something similar to RPF,
+ * probably we'd like to check that the peer is allowed to send us
+ * packets. For this, we should use the tunnel table OR check that
+ * we have a mapping for the source eid and that the outer source of
+ * the packet is one of its locators */
+
+ /* determine next_index from lisp-gpe header */
+ next0 = next_protocol_to_next_index (lh0,
+ vlib_buffer_get_current (b0));
+
+ /* determine if tunnel is l2 or l3 */
+ tl0 = next_index_to_iface (lgm, next0);
+
+ /* map iid/vni to lisp-gpe sw_if_index which is used by ipx_input to
+ * decide the rx vrf and the input features to be applied */
+ si0 = hash_get (tl0->sw_if_index_by_vni,
+ clib_net_to_host_u32 (lh0->iid));
+
+ /* Required to make the l2 tag push / pop code work on l2 subifs */
+ vnet_update_l2_len (b0);
+
+ if (si0)
+ {
+ incr_decap_stats (lgm->vnet_main, cpu_index,
+ vlib_buffer_length_in_chain (vm, b0), si0[0],
+ &last_sw_if_index, &n_packets, &n_bytes);
+ vnet_buffer (b0)->sw_if_index[VLIB_RX] = si0[0];
+ error0 = 0;
+ }
+ else
+ {
+ next0 = LISP_GPE_INPUT_NEXT_DROP;
+ error0 = LISP_GPE_ERROR_NO_TUNNEL;
+ drops++;
+ }
+
+ /* TODO error handling if security is implemented */
+ b0->error = error0 ? node->errors[error0] : 0;
+
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ lisp_gpe_rx_trace_t *tr = vlib_add_trace (vm, node, b0,
+ sizeof (*tr));
+ tr->next_index = next0;
+ tr->error = error0;
+ tr->h = lh0[0];
+ }
+
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
+ }
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
/* flush iface stats */
incr_decap_stats (lgm->vnet_main, cpu_index, 0, ~0, &last_sw_if_index,
- &n_packets, &n_bytes);
+ &n_packets, &n_bytes);
vlib_node_increment_counter (vm, lisp_gpe_ip4_input_node.index,
- LISP_GPE_ERROR_NO_TUNNEL, drops);
+ LISP_GPE_ERROR_NO_TUNNEL, drops);
return from_frame->n_vectors;
}
static uword
lisp_gpe_ip4_input (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+ vlib_frame_t * from_frame)
{
- return lisp_gpe_input_inline(vm, node, from_frame, 1);
+ return lisp_gpe_input_inline (vm, node, from_frame, 1);
}
static uword
lisp_gpe_ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+ vlib_frame_t * from_frame)
{
- return lisp_gpe_input_inline(vm, node, from_frame, 0);
+ return lisp_gpe_input_inline (vm, node, from_frame, 0);
}
-static char * lisp_gpe_ip4_input_error_strings[] = {
+static char *lisp_gpe_ip4_input_error_strings[] = {
#define lisp_gpe_error(n,s) s,
#include <vnet/lisp-gpe/lisp_gpe_error.def>
#undef lisp_gpe_error
};
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (lisp_gpe_ip4_input_node) = {
.function = lisp_gpe_ip4_input,
.name = "lisp-gpe-ip4-input",
@@ -440,7 +448,9 @@ VLIB_REGISTER_NODE (lisp_gpe_ip4_input_node) = {
.format_trace = format_lisp_gpe_rx_trace,
// $$$$ .unformat_buffer = unformat_lisp_gpe_header,
};
+/* *INDENT-ON* */
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node) = {
.function = lisp_gpe_ip6_input,
.name = "lisp-gpe-ip6-input",
@@ -460,3 +470,12 @@ VLIB_REGISTER_NODE (lisp_gpe_ip6_input_node) = {
.format_trace = format_lisp_gpe_rx_trace,
// $$$$ .unformat_buffer = unformat_lisp_gpe_header,
};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/lisp-gpe/interface.c b/vnet/vnet/lisp-gpe/interface.c
index c7bba47b1c2..cc12c9ff288 100644
--- a/vnet/vnet/lisp-gpe/interface.c
+++ b/vnet/vnet/lisp-gpe/interface.c
@@ -31,7 +31,7 @@ typedef enum
#define _(sym,str) LISP_GPE_TX_NEXT_##sym,
foreach_lisp_gpe_tx_next
#undef _
- LISP_GPE_TX_N_NEXT,
+ LISP_GPE_TX_N_NEXT,
} lisp_gpe_tx_next_t;
typedef struct
@@ -44,7 +44,7 @@ format_lisp_gpe_tx_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- lisp_gpe_tx_trace_t * t = va_arg (*args, lisp_gpe_tx_trace_t *);
+ lisp_gpe_tx_trace_t *t = va_arg (*args, lisp_gpe_tx_trace_t *);
s = format (s, "LISP-GPE-TX: tunnel %d", t->tunnel_index);
return s;
@@ -52,13 +52,13 @@ format_lisp_gpe_tx_trace (u8 * s, va_list * args)
always_inline void
get_one_tunnel_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
- lisp_gpe_tunnel_t ** t0, u8 is_v4)
+ lisp_gpe_tunnel_t ** t0, u8 is_v4)
{
u32 adj_index0, tunnel_index0;
- ip_adjacency_t * adj0;
+ ip_adjacency_t *adj0;
/* Get adjacency and from it the tunnel_index */
- adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
+ adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
if (is_v4)
adj0 = ip_get_adjacency (lgm->lm4, adj_index0);
@@ -66,24 +66,25 @@ get_one_tunnel_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
adj0 = ip_get_adjacency (lgm->lm6, adj_index0);
tunnel_index0 = adj0->if_address_index;
- t0[0] = pool_elt_at_index(lgm->tunnels, tunnel_index0);
+ t0[0] = pool_elt_at_index (lgm->tunnels, tunnel_index0);
- ASSERT(t0[0] != 0);
+ ASSERT (t0[0] != 0);
}
always_inline void
encap_one_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
- lisp_gpe_tunnel_t * t0, u32 * next0)
+ lisp_gpe_tunnel_t * t0, u32 * next0)
{
- ASSERT(sizeof(ip4_udp_lisp_gpe_header_t) == 36);
- ASSERT(sizeof(ip6_udp_lisp_gpe_header_t) == 56);
+ ASSERT (sizeof (ip4_udp_lisp_gpe_header_t) == 36);
+ ASSERT (sizeof (ip6_udp_lisp_gpe_header_t) == 56);
- lisp_gpe_sub_tunnel_t * st0;
- u32 * sti0;
+ lisp_gpe_sub_tunnel_t *st0;
+ u32 *sti0;
- sti0 = vec_elt_at_index(t0->sub_tunnels_lbv,
- vnet_buffer(b0)->ip.flow_hash % t0->sub_tunnels_lbv_count);
- st0 = vec_elt_at_index(t0->sub_tunnels, sti0[0]);
+ sti0 = vec_elt_at_index (t0->sub_tunnels_lbv,
+ vnet_buffer (b0)->ip.flow_hash %
+ t0->sub_tunnels_lbv_count);
+ st0 = vec_elt_at_index (t0->sub_tunnels, sti0[0]);
if (st0->is_ip4)
{
ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
@@ -96,20 +97,20 @@ encap_one_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
}
/* Reset to look up tunnel partner in the configured FIB */
- vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->encap_fib_index;
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = t0->encap_fib_index;
}
always_inline void
get_two_tunnels_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
- vlib_buffer_t * b1, lisp_gpe_tunnel_t ** t0,
- lisp_gpe_tunnel_t ** t1, u8 is_v4)
+ vlib_buffer_t * b1, lisp_gpe_tunnel_t ** t0,
+ lisp_gpe_tunnel_t ** t1, u8 is_v4)
{
u32 adj_index0, adj_index1, tunnel_index0, tunnel_index1;
- ip_adjacency_t * adj0, * adj1;
+ ip_adjacency_t *adj0, *adj1;
/* Get adjacency and from it the tunnel_index */
- adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
- adj_index1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX];
+ adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
+ adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
if (is_v4)
{
@@ -125,76 +126,79 @@ get_two_tunnels_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
tunnel_index0 = adj0->if_address_index;
tunnel_index1 = adj1->if_address_index;
- t0[0] = pool_elt_at_index(lgm->tunnels, tunnel_index0);
- t1[0] = pool_elt_at_index(lgm->tunnels, tunnel_index1);
+ t0[0] = pool_elt_at_index (lgm->tunnels, tunnel_index0);
+ t1[0] = pool_elt_at_index (lgm->tunnels, tunnel_index1);
- ASSERT(t0[0] != 0);
- ASSERT(t1[0] != 0);
+ ASSERT (t0[0] != 0);
+ ASSERT (t1[0] != 0);
}
always_inline void
-encap_two_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0, vlib_buffer_t * b1,
- lisp_gpe_tunnel_t * t0, lisp_gpe_tunnel_t * t1, u32 * next0,
- u32 * next1)
+encap_two_inline (lisp_gpe_main_t * lgm, vlib_buffer_t * b0,
+ vlib_buffer_t * b1, lisp_gpe_tunnel_t * t0,
+ lisp_gpe_tunnel_t * t1, u32 * next0, u32 * next1)
{
- ASSERT(sizeof(ip4_udp_lisp_gpe_header_t) == 36);
- ASSERT(sizeof(ip6_udp_lisp_gpe_header_t) == 56);
-
- lisp_gpe_sub_tunnel_t * st0, * st1;
- u32 * sti0, * sti1;
- sti0 = vec_elt_at_index(t0->sub_tunnels_lbv,
- vnet_buffer(b0)->ip.flow_hash % t0->sub_tunnels_lbv_count);
- sti1 = vec_elt_at_index(t1->sub_tunnels_lbv,
- vnet_buffer(b1)->ip.flow_hash % t1->sub_tunnels_lbv_count);
- st0 = vec_elt_at_index(t0->sub_tunnels, sti0[0]);
- st1 = vec_elt_at_index(t1->sub_tunnels, sti1[0]);
-
- if (PREDICT_TRUE(st0->is_ip4 == st1->is_ip4))
+ ASSERT (sizeof (ip4_udp_lisp_gpe_header_t) == 36);
+ ASSERT (sizeof (ip6_udp_lisp_gpe_header_t) == 56);
+
+ lisp_gpe_sub_tunnel_t *st0, *st1;
+ u32 *sti0, *sti1;
+ sti0 = vec_elt_at_index (t0->sub_tunnels_lbv,
+ vnet_buffer (b0)->ip.flow_hash %
+ t0->sub_tunnels_lbv_count);
+ sti1 =
+ vec_elt_at_index (t1->sub_tunnels_lbv,
+ vnet_buffer (b1)->ip.flow_hash %
+ t1->sub_tunnels_lbv_count);
+ st0 = vec_elt_at_index (t0->sub_tunnels, sti0[0]);
+ st1 = vec_elt_at_index (t1->sub_tunnels, sti1[0]);
+
+ if (PREDICT_TRUE (st0->is_ip4 == st1->is_ip4))
{
if (st0->is_ip4)
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 36, 1);
- next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- }
+ {
+ ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
+ ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 36, 1);
+ next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
+ }
else
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 56, 0);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 56, 0);
- next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
- }
+ {
+ ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 56, 0);
+ ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 56, 0);
+ next0[0] = next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
+ }
}
else
{
if (st0->is_ip4)
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 56, 1);
- next0[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
- }
+ {
+ ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 36, 1);
+ ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 56, 1);
+ next0[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
+ next1[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
+ }
else
- {
- ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 56, 1);
- ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 36, 1);
- next0[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
- next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- }
+ {
+ ip_udp_encap_one (lgm->vlib_main, b0, st0->rewrite, 56, 1);
+ ip_udp_encap_one (lgm->vlib_main, b1, st1->rewrite, 36, 1);
+ next0[0] = LISP_GPE_TX_NEXT_IP6_LOOKUP;
+ next1[0] = LISP_GPE_TX_NEXT_IP4_LOOKUP;
+ }
}
/* Reset to look up tunnel partner in the configured FIB */
- vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->encap_fib_index;
- vnet_buffer(b1)->sw_if_index[VLIB_TX] = t1->encap_fib_index;
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = t0->encap_fib_index;
+ vnet_buffer (b1)->sw_if_index[VLIB_TX] = t1->encap_fib_index;
}
#define is_v4_packet(_h) ((*(u8*) _h) & 0xF0) == 0x40
static uword
lisp_gpe_interface_tx (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+ vlib_frame_t * from_frame)
{
- u32 n_left_from, next_index, * from, * to_next;
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ u32 n_left_from, next_index, *from, *to_next;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -205,109 +209,108 @@ lisp_gpe_interface_tx (vlib_main_t * vm, vlib_node_runtime_t * node,
{
u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index,
- to_next, n_left_to_next);
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- u32 next0, next1;
- lisp_gpe_tunnel_t * t0 = 0, * t1 = 0;
- u8 is_v4_eid0, is_v4_eid1;
-
- next0 = next1 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t * p2, *p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
-
- vlib_prefetch_buffer_header(p2, LOAD);
- vlib_prefetch_buffer_header(p3, LOAD);
-
- CLIB_PREFETCH(p2->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- CLIB_PREFETCH(p3->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- }
-
- bi0 = from[0];
- bi1 = from[1];
- to_next[0] = bi0;
- to_next[1] = bi1;
- from += 2;
- to_next += 2;
- n_left_to_next -= 2;
- n_left_from -= 2;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
-
- is_v4_eid0 = is_v4_packet(vlib_buffer_get_current (b0));
- is_v4_eid1 = is_v4_packet(vlib_buffer_get_current (b1));
-
- if (PREDICT_TRUE(is_v4_eid0 == is_v4_eid1))
- {
- get_two_tunnels_inline (lgm, b0, b1, &t0, &t1,
- is_v4_eid0 ? 1 : 0);
- }
- else
- {
- get_one_tunnel_inline (lgm, b0, &t0, is_v4_eid0 ? 1 : 0);
- get_one_tunnel_inline (lgm, b1, &t1, is_v4_eid1 ? 1 : 0);
- }
-
- encap_two_inline (lgm, b0, b1, t0, t1, &next0, &next1);
-
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
- sizeof(*tr));
- tr->tunnel_index = t0 - lgm->tunnels;
- }
- if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
- {
- lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b1,
- sizeof(*tr));
- tr->tunnel_index = t1 - lgm->tunnels;
- }
-
- vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
- n_left_to_next, bi0, bi1, next0,
- next1);
- }
+ {
+ u32 bi0, bi1;
+ vlib_buffer_t *b0, *b1;
+ u32 next0, next1;
+ lisp_gpe_tunnel_t *t0 = 0, *t1 = 0;
+ u8 is_v4_eid0, is_v4_eid1;
+
+ next0 = next1 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
+
+ /* Prefetch next iteration. */
+ {
+ vlib_buffer_t *p2, *p3;
+
+ p2 = vlib_get_buffer (vm, from[2]);
+ p3 = vlib_get_buffer (vm, from[3]);
+
+ vlib_prefetch_buffer_header (p2, LOAD);
+ vlib_prefetch_buffer_header (p3, LOAD);
+
+ CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ }
+
+ bi0 = from[0];
+ bi1 = from[1];
+ to_next[0] = bi0;
+ to_next[1] = bi1;
+ from += 2;
+ to_next += 2;
+ n_left_to_next -= 2;
+ n_left_from -= 2;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+
+ is_v4_eid0 = is_v4_packet (vlib_buffer_get_current (b0));
+ is_v4_eid1 = is_v4_packet (vlib_buffer_get_current (b1));
+
+ if (PREDICT_TRUE (is_v4_eid0 == is_v4_eid1))
+ {
+ get_two_tunnels_inline (lgm, b0, b1, &t0, &t1,
+ is_v4_eid0 ? 1 : 0);
+ }
+ else
+ {
+ get_one_tunnel_inline (lgm, b0, &t0, is_v4_eid0 ? 1 : 0);
+ get_one_tunnel_inline (lgm, b1, &t1, is_v4_eid1 ? 1 : 0);
+ }
+
+ encap_two_inline (lgm, b0, b1, t0, t1, &next0, &next1);
+
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
+ sizeof (*tr));
+ tr->tunnel_index = t0 - lgm->tunnels;
+ }
+ if (PREDICT_FALSE (b1->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b1,
+ sizeof (*tr));
+ tr->tunnel_index = t1 - lgm->tunnels;
+ }
+
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
+ }
while (n_left_from > 0 && n_left_to_next > 0)
- {
- vlib_buffer_t * b0;
- u32 bi0, next0 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
- lisp_gpe_tunnel_t * t0 = 0;
- u8 is_v4_0;
-
- bi0 = from[0];
- to_next[0] = bi0;
- from += 1;
- to_next += 1;
- n_left_from -= 1;
- n_left_to_next -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
-
- is_v4_0 = is_v4_packet(vlib_buffer_get_current (b0));
- get_one_tunnel_inline (lgm, b0, &t0, is_v4_0 ? 1 : 0);
-
- encap_one_inline (lgm, b0, t0, &next0);
-
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
- sizeof(*tr));
- tr->tunnel_index = t0 - lgm->tunnels;
- }
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
- n_left_to_next, bi0, next0);
- }
+ {
+ vlib_buffer_t *b0;
+ u32 bi0, next0 = LISP_GPE_TX_NEXT_IP4_LOOKUP;
+ lisp_gpe_tunnel_t *t0 = 0;
+ u8 is_v4_0;
+
+ bi0 = from[0];
+ to_next[0] = bi0;
+ from += 1;
+ to_next += 1;
+ n_left_from -= 1;
+ n_left_to_next -= 1;
+
+ b0 = vlib_get_buffer (vm, bi0);
+
+ is_v4_0 = is_v4_packet (vlib_buffer_get_current (b0));
+ get_one_tunnel_inline (lgm, b0, &t0, is_v4_0 ? 1 : 0);
+
+ encap_one_inline (lgm, b0, t0, &next0);
+
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
+ sizeof (*tr));
+ tr->tunnel_index = t0 - lgm->tunnels;
+ }
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
+ }
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
@@ -322,6 +325,7 @@ format_lisp_gpe_name (u8 * s, va_list * args)
return format (s, "lisp_gpe%d", dev_instance);
}
+/* *INDENT-OFF* */
VNET_DEVICE_CLASS (lisp_gpe_device_class,static) = {
.name = "LISP_GPE",
.format_device_name = format_lisp_gpe_name,
@@ -329,10 +333,11 @@ VNET_DEVICE_CLASS (lisp_gpe_device_class,static) = {
.tx_function = lisp_gpe_interface_tx,
.no_flatten_output_chains = 1,
};
+/* *INDENT-ON* */
static uword
dummy_set_rewrite (vnet_main_t * vnm, u32 sw_if_index, u32 l3_type,
- void * dst_address, void * rewrite, uword max_rewrite_bytes)
+ void *dst_address, void *rewrite, uword max_rewrite_bytes)
{
return 0;
}
@@ -340,7 +345,7 @@ dummy_set_rewrite (vnet_main_t * vnm, u32 sw_if_index, u32 l3_type,
u8 *
format_lisp_gpe_header_with_length (u8 * s, va_list * args)
{
- lisp_gpe_header_t * h = va_arg (*args, lisp_gpe_header_t *);
+ lisp_gpe_header_t *h = va_arg (*args, lisp_gpe_header_t *);
u32 max_header_bytes = va_arg (*args, u32);
u32 header_bytes;
@@ -354,35 +359,36 @@ format_lisp_gpe_header_with_length (u8 * s, va_list * args)
#undef _
s = format (s, "\n ver_res %d res %d next_protocol %d iid %d(%x)",
- h->ver_res, h->res, h->next_protocol,
- clib_net_to_host_u32 (h->iid),
- clib_net_to_host_u32 (h->iid));
+ h->ver_res, h->res, h->next_protocol,
+ clib_net_to_host_u32 (h->iid), clib_net_to_host_u32 (h->iid));
return s;
}
+/* *INDENT-OFF* */
VNET_HW_INTERFACE_CLASS (lisp_gpe_hw_class) = {
.name = "LISP_GPE",
.format_header = format_lisp_gpe_header_with_length,
.set_rewrite = dummy_set_rewrite,
};
+/* *INDENT-ON* */
int
add_del_ip_prefix_route (ip_prefix_t * dst_prefix, u32 table_id,
- ip_adjacency_t * add_adj, u8 is_add, u32 * adj_index)
+ ip_adjacency_t * add_adj, u8 is_add, u32 * adj_index)
{
- uword * p;
+ uword *p;
- if (ip_prefix_version(dst_prefix) == IP4)
+ if (ip_prefix_version (dst_prefix) == IP4)
{
- ip4_main_t * im4 = &ip4_main;
+ ip4_main_t *im4 = &ip4_main;
ip4_add_del_route_args_t a;
- ip4_address_t addr = ip_prefix_v4(dst_prefix);
+ ip4_address_t addr = ip_prefix_v4 (dst_prefix);
- memset(&a, 0, sizeof(a));
+ memset (&a, 0, sizeof (a));
a.flags = IP4_ROUTE_FLAG_TABLE_ID;
a.table_index_or_table_id = table_id;
a.adj_index = ~0;
- a.dst_address_length = ip_prefix_len(dst_prefix);
+ a.dst_address_length = ip_prefix_len (dst_prefix);
a.dst_address = addr;
a.flags |= is_add ? IP4_ROUTE_FLAG_ADD : IP4_ROUTE_FLAG_DEL;
a.add_adj = add_adj;
@@ -391,30 +397,30 @@ add_del_ip_prefix_route (ip_prefix_t * dst_prefix, u32 table_id,
ip4_add_del_route (im4, &a);
if (is_add)
- {
- p = ip4_get_route (im4, table_id, 0, addr.as_u8,
- ip_prefix_len(dst_prefix));
- if (p == 0)
- {
- clib_warning("Failed to insert route for eid %U!",
- format_ip4_address_and_length, addr.as_u8,
- ip_prefix_len(dst_prefix));
- return -1;
- }
- adj_index[0] = p[0];
- }
+ {
+ p = ip4_get_route (im4, table_id, 0, addr.as_u8,
+ ip_prefix_len (dst_prefix));
+ if (p == 0)
+ {
+ clib_warning ("Failed to insert route for eid %U!",
+ format_ip4_address_and_length, addr.as_u8,
+ ip_prefix_len (dst_prefix));
+ return -1;
+ }
+ adj_index[0] = p[0];
+ }
}
else
{
- ip6_main_t * im6 = &ip6_main;
+ ip6_main_t *im6 = &ip6_main;
ip6_add_del_route_args_t a;
- ip6_address_t addr = ip_prefix_v6(dst_prefix);
+ ip6_address_t addr = ip_prefix_v6 (dst_prefix);
- memset(&a, 0, sizeof(a));
+ memset (&a, 0, sizeof (a));
a.flags = IP6_ROUTE_FLAG_TABLE_ID;
a.table_index_or_table_id = table_id;
a.adj_index = ~0;
- a.dst_address_length = ip_prefix_len(dst_prefix);
+ a.dst_address_length = ip_prefix_len (dst_prefix);
a.dst_address = addr;
a.flags |= is_add ? IP6_ROUTE_FLAG_ADD : IP6_ROUTE_FLAG_DEL;
a.add_adj = add_adj;
@@ -423,17 +429,17 @@ add_del_ip_prefix_route (ip_prefix_t * dst_prefix, u32 table_id,
ip6_add_del_route (im6, &a);
if (is_add)
- {
- adj_index[0] = ip6_get_route (im6, table_id, 0, &addr,
- ip_prefix_len(dst_prefix));
- if (adj_index[0] == 0)
- {
- clib_warning("Failed to insert route for eid %U!",
- format_ip6_address_and_length, addr.as_u8,
- ip_prefix_len(dst_prefix));
- return -1;
- }
- }
+ {
+ adj_index[0] = ip6_get_route (im6, table_id, 0, &addr,
+ ip_prefix_len (dst_prefix));
+ if (adj_index[0] == 0)
+ {
+ clib_warning ("Failed to insert route for eid %U!",
+ format_ip6_address_and_length, addr.as_u8,
+ ip_prefix_len (dst_prefix));
+ return -1;
+ }
+ }
}
return 0;
}
@@ -441,24 +447,24 @@ add_del_ip_prefix_route (ip_prefix_t * dst_prefix, u32 table_id,
static void
add_del_lisp_gpe_default_route (u32 table_id, u8 is_v4, u8 is_add)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
ip_adjacency_t adj;
ip_prefix_t prefix;
u32 adj_index = 0;
/* setup adjacency */
- memset (&adj, 0, sizeof(adj));
+ memset (&adj, 0, sizeof (adj));
adj.n_adj = 1;
adj.explicit_fib_index = ~0;
adj.lookup_next_index = is_v4 ? lgm->ip4_lookup_next_lgpe_ip4_lookup :
- lgm->ip6_lookup_next_lgpe_ip6_lookup;
+ lgm->ip6_lookup_next_lgpe_ip6_lookup;
/* default route has tunnel_index ~0 */
adj.rewrite_header.sw_if_index = ~0;
/* set prefix to 0/0 */
- memset(&prefix, 0, sizeof(prefix));
- ip_prefix_version(&prefix) = is_v4 ? IP4 : IP6;
+ memset (&prefix, 0, sizeof (prefix));
+ ip_prefix_version (&prefix) = is_v4 ? IP4 : IP6;
/* add/delete route for prefix */
add_del_ip_prefix_route (&prefix, table_id, &adj, is_add, &adj_index);
@@ -469,28 +475,28 @@ lisp_gpe_iface_set_table (u32 sw_if_index, u32 table_id, u8 is_ip4)
{
if (is_ip4)
{
- ip4_main_t * im4 = &ip4_main;
- ip4_fib_t * fib;
+ ip4_main_t *im4 = &ip4_main;
+ ip4_fib_t *fib;
fib = find_ip4_fib_by_table_index_or_id (im4, table_id,
- IP4_ROUTE_FLAG_TABLE_ID);
+ IP4_ROUTE_FLAG_TABLE_ID);
/* fib's created if it doesn't exist */
- ASSERT(fib != 0);
+ ASSERT (fib != 0);
- vec_validate(im4->fib_index_by_sw_if_index, sw_if_index);
+ vec_validate (im4->fib_index_by_sw_if_index, sw_if_index);
im4->fib_index_by_sw_if_index[sw_if_index] = fib->index;
}
else
{
- ip6_main_t * im6 = &ip6_main;
- ip6_fib_t * fib;
+ ip6_main_t *im6 = &ip6_main;
+ ip6_fib_t *fib;
fib = find_ip6_fib_by_table_index_or_id (im6, table_id,
- IP6_ROUTE_FLAG_TABLE_ID);
+ IP6_ROUTE_FLAG_TABLE_ID);
/* fib's created if it doesn't exist */
- ASSERT(fib != 0);
+ ASSERT (fib != 0);
- vec_validate(im6->fib_index_by_sw_if_index, sw_if_index);
+ vec_validate (im6->fib_index_by_sw_if_index, sw_if_index);
im6->fib_index_by_sw_if_index[sw_if_index] = fib->index;
}
}
@@ -506,7 +512,7 @@ typedef enum
#define _(sym,str) L2_LISP_GPE_TX_NEXT_##sym,
foreach_l2_lisp_gpe_tx_next
#undef _
- L2_LISP_GPE_TX_N_NEXT,
+ L2_LISP_GPE_TX_N_NEXT,
} l2_lisp_gpe_tx_next_t;
typedef struct
@@ -519,7 +525,7 @@ format_l2_lisp_gpe_tx_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- l2_lisp_gpe_tx_trace_t * t = va_arg (*args, l2_lisp_gpe_tx_trace_t *);
+ l2_lisp_gpe_tx_trace_t *t = va_arg (*args, l2_lisp_gpe_tx_trace_t *);
s = format (s, "L2-LISP-GPE-TX: tunnel %d", t->tunnel_index);
return s;
@@ -531,7 +537,7 @@ l2_process_tunnel_action (vlib_buffer_t * b0, u8 action, u32 * next0)
if (LISP_SEND_MAP_REQUEST == action)
{
next0[0] = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
- vnet_buffer(b0)->lisp.overlay_afi = LISP_AFI_MAC;
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_MAC;
}
else
{
@@ -540,9 +546,9 @@ l2_process_tunnel_action (vlib_buffer_t * b0, u8 action, u32 * next0)
}
always_inline u32
-ip_flow_hash (void * data)
+ip_flow_hash (void *data)
{
- ip4_header_t * iph = (ip4_header_t *) data;
+ ip4_header_t *iph = (ip4_header_t *) data;
if ((iph->ip_version_and_header_length & 0xF0) == 0x40)
return ip4_compute_flow_hash (iph, IP_FLOW_HASH_DEFAULT);
@@ -553,14 +559,14 @@ ip_flow_hash (void * data)
always_inline u32
l2_flow_hash (vlib_buffer_t * b0)
{
- ethernet_header_t * eh;
+ ethernet_header_t *eh;
u64 a, b, c;
uword is_ip, eh_size;
u16 eh_type;
eh = vlib_buffer_get_current (b0);
- eh_type = clib_net_to_host_u16(eh->type);
- eh_size = ethernet_buffer_header_size(b0);
+ eh_type = clib_net_to_host_u16 (eh->type);
+ eh_size = ethernet_buffer_header_size (b0);
is_ip = (eh_type == ETHERNET_TYPE_IP4 || eh_type == ETHERNET_TYPE_IP6);
@@ -570,84 +576,85 @@ l2_flow_hash (vlib_buffer_t * b0)
else
a = eh->type;
- b = mac_to_u64((u8 *)eh->dst_address);
- c = mac_to_u64((u8 *)eh->src_address);
+ b = mac_to_u64 ((u8 *) eh->dst_address);
+ c = mac_to_u64 ((u8 *) eh->src_address);
hash_mix64 (a, b, c);
return (u32) c;
}
always_inline void
-l2_process_one (lisp_gpe_main_t * lgm, vlib_buffer_t * b0, u32 ti0, u32 * next0)
+l2_process_one (lisp_gpe_main_t * lgm, vlib_buffer_t * b0, u32 ti0,
+ u32 * next0)
{
- lisp_gpe_tunnel_t * t0;
+ lisp_gpe_tunnel_t *t0;
- t0 = pool_elt_at_index(lgm->tunnels, ti0);
- ASSERT(0 != t0);
+ t0 = pool_elt_at_index (lgm->tunnels, ti0);
+ ASSERT (0 != t0);
- if (PREDICT_TRUE(LISP_NO_ACTION == t0->action))
+ if (PREDICT_TRUE (LISP_NO_ACTION == t0->action))
{
/* compute 'flow' hash */
- if (PREDICT_TRUE(t0->sub_tunnels_lbv_count > 1))
- vnet_buffer(b0)->ip.flow_hash = l2_flow_hash (b0);
+ if (PREDICT_TRUE (t0->sub_tunnels_lbv_count > 1))
+ vnet_buffer (b0)->ip.flow_hash = l2_flow_hash (b0);
encap_one_inline (lgm, b0, t0, next0);
}
else
{
- l2_process_tunnel_action(b0, t0->action, next0);
+ l2_process_tunnel_action (b0, t0->action, next0);
}
}
always_inline void
l2_process_two (lisp_gpe_main_t * lgm, vlib_buffer_t * b0, vlib_buffer_t * b1,
- u32 ti0, u32 ti1, u32 * next0, u32 * next1)
+ u32 ti0, u32 ti1, u32 * next0, u32 * next1)
{
- lisp_gpe_tunnel_t * t0, * t1;
+ lisp_gpe_tunnel_t *t0, *t1;
- t0 = pool_elt_at_index(lgm->tunnels, ti0);
- t1 = pool_elt_at_index(lgm->tunnels, ti1);
+ t0 = pool_elt_at_index (lgm->tunnels, ti0);
+ t1 = pool_elt_at_index (lgm->tunnels, ti1);
- ASSERT(0 != t0 && 0 != t1);
+ ASSERT (0 != t0 && 0 != t1);
- if (PREDICT_TRUE(LISP_NO_ACTION == t0->action
- && LISP_NO_ACTION == t1->action))
+ if (PREDICT_TRUE (LISP_NO_ACTION == t0->action
+ && LISP_NO_ACTION == t1->action))
{
- if (PREDICT_TRUE(t0->sub_tunnels_lbv_count > 1))
- vnet_buffer(b0)->ip.flow_hash = l2_flow_hash(b0);
- if (PREDICT_TRUE(t1->sub_tunnels_lbv_count > 1))
- vnet_buffer(b1)->ip.flow_hash = l2_flow_hash(b1);
+ if (PREDICT_TRUE (t0->sub_tunnels_lbv_count > 1))
+ vnet_buffer (b0)->ip.flow_hash = l2_flow_hash (b0);
+ if (PREDICT_TRUE (t1->sub_tunnels_lbv_count > 1))
+ vnet_buffer (b1)->ip.flow_hash = l2_flow_hash (b1);
encap_two_inline (lgm, b0, b1, t0, t1, next0, next1);
}
else
{
if (LISP_NO_ACTION == t0->action)
- {
- if (PREDICT_TRUE(t0->sub_tunnels_lbv_count > 1))
- vnet_buffer(b0)->ip.flow_hash = l2_flow_hash(b0);
- encap_one_inline (lgm, b0, t0, next0);
- l2_process_tunnel_action (b1, t1->action, next1);
- }
+ {
+ if (PREDICT_TRUE (t0->sub_tunnels_lbv_count > 1))
+ vnet_buffer (b0)->ip.flow_hash = l2_flow_hash (b0);
+ encap_one_inline (lgm, b0, t0, next0);
+ l2_process_tunnel_action (b1, t1->action, next1);
+ }
else if (LISP_NO_ACTION == t1->action)
- {
- if (PREDICT_TRUE(t1->sub_tunnels_lbv_count > 1))
- vnet_buffer(b1)->ip.flow_hash = l2_flow_hash(b1);
- encap_one_inline (lgm, b1, t1, next1);
- l2_process_tunnel_action (b0, t0->action, next0);
- }
+ {
+ if (PREDICT_TRUE (t1->sub_tunnels_lbv_count > 1))
+ vnet_buffer (b1)->ip.flow_hash = l2_flow_hash (b1);
+ encap_one_inline (lgm, b1, t1, next1);
+ l2_process_tunnel_action (b0, t0->action, next0);
+ }
else
- {
- l2_process_tunnel_action (b0, t0->action, next0);
- l2_process_tunnel_action (b1, t1->action, next1);
- }
+ {
+ l2_process_tunnel_action (b0, t0->action, next0);
+ l2_process_tunnel_action (b1, t1->action, next1);
+ }
}
}
static uword
l2_lisp_gpe_interface_tx (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+ vlib_frame_t * from_frame)
{
- u32 n_left_from, next_index, * from, * to_next;
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ u32 n_left_from, next_index, *from, *to_next;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -658,147 +665,146 @@ l2_lisp_gpe_interface_tx (vlib_main_t * vm, vlib_node_runtime_t * node,
{
u32 n_left_to_next;
- vlib_get_next_frame (vm, node, next_index,
- to_next, n_left_to_next);
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- u32 next0, next1, ti0, ti1;
- lisp_gpe_tunnel_t * t0 = 0, * t1 = 0;
- ethernet_header_t * e0, * e1;
-
- next0 = next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t * p2, *p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
-
- vlib_prefetch_buffer_header(p2, LOAD);
- vlib_prefetch_buffer_header(p3, LOAD);
-
- CLIB_PREFETCH(p2->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- CLIB_PREFETCH(p3->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- }
-
- bi0 = from[0];
- bi1 = from[1];
- to_next[0] = bi0;
- to_next[1] = bi1;
- from += 2;
- to_next += 2;
- n_left_to_next -= 2;
- n_left_from -= 2;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
-
- e0 = vlib_buffer_get_current (b0);
- e1 = vlib_buffer_get_current (b1);
-
- /* lookup dst + src mac */
- ti0 = lisp_l2_fib_lookup (lgm, vnet_buffer(b0)->l2.bd_index,
- e0->src_address, e0->dst_address);
- ti1 = lisp_l2_fib_lookup (lgm, vnet_buffer(b1)->l2.bd_index,
- e1->src_address, e1->dst_address);
-
- if (PREDICT_TRUE((u32)~0 != ti0) && (u32)~0 != ti1)
- {
- /* process both tunnels */
- l2_process_two (lgm, b0, b1, ti0, ti1, &next0, &next1);
- }
- else
- {
- if ((u32)~0 != ti0)
- {
- /* process tunnel for b0 */
- l2_process_one (lgm, b0, ti0, &next0);
-
- /* no tunnel found for b1, send to control plane */
- next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
- vnet_buffer(b1)->lisp.overlay_afi = LISP_AFI_MAC;
- }
- else if ((u32)~0 != ti1)
- {
- /* process tunnel for b1 */
- l2_process_one (lgm, b1, ti1, &next1);
-
- /* no tunnel found b0, send to control plane */
- next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
- vnet_buffer(b0)->lisp.overlay_afi = LISP_AFI_MAC;
- }
- else
- {
- /* no tunnels found */
- next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
- vnet_buffer(b0)->lisp.overlay_afi = LISP_AFI_MAC;
- next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
- vnet_buffer(b1)->lisp.overlay_afi = LISP_AFI_MAC;
- }
- }
-
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- l2_lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
- sizeof(*tr));
- tr->tunnel_index = t0 - lgm->tunnels;
- }
- if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED))
- {
- l2_lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b1,
- sizeof(*tr));
- tr->tunnel_index = t1 - lgm->tunnels;
- }
-
- vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
- n_left_to_next, bi0, bi1, next0,
- next1);
- }
+ {
+ u32 bi0, bi1;
+ vlib_buffer_t *b0, *b1;
+ u32 next0, next1, ti0, ti1;
+ lisp_gpe_tunnel_t *t0 = 0, *t1 = 0;
+ ethernet_header_t *e0, *e1;
+
+ next0 = next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
+
+ /* Prefetch next iteration. */
+ {
+ vlib_buffer_t *p2, *p3;
+
+ p2 = vlib_get_buffer (vm, from[2]);
+ p3 = vlib_get_buffer (vm, from[3]);
+
+ vlib_prefetch_buffer_header (p2, LOAD);
+ vlib_prefetch_buffer_header (p3, LOAD);
+
+ CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ }
+
+ bi0 = from[0];
+ bi1 = from[1];
+ to_next[0] = bi0;
+ to_next[1] = bi1;
+ from += 2;
+ to_next += 2;
+ n_left_to_next -= 2;
+ n_left_from -= 2;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+
+ e0 = vlib_buffer_get_current (b0);
+ e1 = vlib_buffer_get_current (b1);
+
+ /* lookup dst + src mac */
+ ti0 = lisp_l2_fib_lookup (lgm, vnet_buffer (b0)->l2.bd_index,
+ e0->src_address, e0->dst_address);
+ ti1 = lisp_l2_fib_lookup (lgm, vnet_buffer (b1)->l2.bd_index,
+ e1->src_address, e1->dst_address);
+
+ if (PREDICT_TRUE ((u32) ~ 0 != ti0) && (u32) ~ 0 != ti1)
+ {
+ /* process both tunnels */
+ l2_process_two (lgm, b0, b1, ti0, ti1, &next0, &next1);
+ }
+ else
+ {
+ if ((u32) ~ 0 != ti0)
+ {
+ /* process tunnel for b0 */
+ l2_process_one (lgm, b0, ti0, &next0);
+
+ /* no tunnel found for b1, send to control plane */
+ next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
+ vnet_buffer (b1)->lisp.overlay_afi = LISP_AFI_MAC;
+ }
+ else if ((u32) ~ 0 != ti1)
+ {
+ /* process tunnel for b1 */
+ l2_process_one (lgm, b1, ti1, &next1);
+
+ /* no tunnel found b0, send to control plane */
+ next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_MAC;
+ }
+ else
+ {
+ /* no tunnels found */
+ next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_MAC;
+ next1 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
+ vnet_buffer (b1)->lisp.overlay_afi = LISP_AFI_MAC;
+ }
+ }
+
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ l2_lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
+ sizeof (*tr));
+ tr->tunnel_index = t0 - lgm->tunnels;
+ }
+ if (PREDICT_FALSE (b1->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ l2_lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b1,
+ sizeof (*tr));
+ tr->tunnel_index = t1 - lgm->tunnels;
+ }
+
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
+ }
while (n_left_from > 0 && n_left_to_next > 0)
- {
- vlib_buffer_t * b0;
- u32 bi0, ti0, next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
- ethernet_header_t * e0;
-
- bi0 = from[0];
- to_next[0] = bi0;
- from += 1;
- to_next += 1;
- n_left_from -= 1;
- n_left_to_next -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
- e0 = vlib_buffer_get_current (b0);
-
- /* lookup dst + src mac */
- ti0 = lisp_l2_fib_lookup (lgm, vnet_buffer(b0)->l2.bd_index,
- e0->src_address, e0->dst_address);
-
- if (PREDICT_TRUE((u32)~0 != ti0))
- {
- l2_process_one (lgm, b0, ti0, &next0);
- }
- else
- {
- /* no tunnel found send to control plane */
- next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
- vnet_buffer(b0)->lisp.overlay_afi = LISP_AFI_MAC;
- }
-
- if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
- {
- l2_lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
- sizeof(*tr));
- tr->tunnel_index = ti0 ? ti0 : ~0;
- }
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
- n_left_to_next, bi0, next0);
- }
+ {
+ vlib_buffer_t *b0;
+ u32 bi0, ti0, next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
+ ethernet_header_t *e0;
+
+ bi0 = from[0];
+ to_next[0] = bi0;
+ from += 1;
+ to_next += 1;
+ n_left_from -= 1;
+ n_left_to_next -= 1;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ e0 = vlib_buffer_get_current (b0);
+
+ /* lookup dst + src mac */
+ ti0 = lisp_l2_fib_lookup (lgm, vnet_buffer (b0)->l2.bd_index,
+ e0->src_address, e0->dst_address);
+
+ if (PREDICT_TRUE ((u32) ~ 0 != ti0))
+ {
+ l2_process_one (lgm, b0, ti0, &next0);
+ }
+ else
+ {
+ /* no tunnel found send to control plane */
+ next0 = L2_LISP_GPE_TX_NEXT_LISP_CP_LOOKUP;
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_MAC;
+ }
+
+ if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
+ {
+ l2_lisp_gpe_tx_trace_t *tr = vlib_add_trace (vm, node, b0,
+ sizeof (*tr));
+ tr->tunnel_index = ti0 ? ti0 : ~0;
+ }
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
+ }
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
@@ -813,6 +819,7 @@ format_l2_lisp_gpe_name (u8 * s, va_list * args)
return format (s, "l2_lisp_gpe%d", dev_instance);
}
+/* *INDENT-OFF* */
VNET_DEVICE_CLASS (l2_lisp_gpe_device_class,static) = {
.name = "L2_LISP_GPE",
.format_device_name = format_l2_lisp_gpe_name,
@@ -820,170 +827,169 @@ VNET_DEVICE_CLASS (l2_lisp_gpe_device_class,static) = {
.tx_function = l2_lisp_gpe_interface_tx,
.no_flatten_output_chains = 1,
};
-
+/* *INDENT-ON* */
static vnet_hw_interface_t *
create_lisp_gpe_iface (lisp_gpe_main_t * lgm, u32 vni, u32 dp_table,
- vnet_device_class_t * dev_class,
- tunnel_lookup_t * tuns)
+ vnet_device_class_t * dev_class,
+ tunnel_lookup_t * tuns)
{
u32 flen;
u32 hw_if_index = ~0;
- u8 * new_name;
- vnet_hw_interface_t * hi;
- vnet_main_t * vnm = lgm->vnet_main;
+ u8 *new_name;
+ vnet_hw_interface_t *hi;
+ vnet_main_t *vnm = lgm->vnet_main;
/* create hw lisp_gpeX iface if needed, otherwise reuse existing */
- flen = vec_len(lgm->free_tunnel_hw_if_indices);
+ flen = vec_len (lgm->free_tunnel_hw_if_indices);
if (flen > 0)
{
hw_if_index = lgm->free_tunnel_hw_if_indices[flen - 1];
- _vec_len(lgm->free_tunnel_hw_if_indices) -= 1;
+ _vec_len (lgm->free_tunnel_hw_if_indices) -= 1;
hi = vnet_get_hw_interface (vnm, hw_if_index);
/* rename interface */
- new_name = format (0, "%U", dev_class->format_device_name,
- vni);
+ new_name = format (0, "%U", dev_class->format_device_name, vni);
- vec_add1(new_name, 0);
+ vec_add1 (new_name, 0);
vnet_rename_interface (vnm, hw_if_index, (char *) new_name);
- vec_free(new_name);
+ vec_free (new_name);
/* clear old stats of freed interface before reuse */
- vnet_interface_main_t * im = &vnm->interface_main;
+ vnet_interface_main_t *im = &vnm->interface_main;
vnet_interface_counter_lock (im);
- vlib_zero_combined_counter (
- &im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_TX],
- hi->sw_if_index);
- vlib_zero_combined_counter (
- &im->combined_sw_if_counters[VNET_INTERFACE_COUNTER_RX],
- hi->sw_if_index);
- vlib_zero_simple_counter (
- &im->sw_if_counters[VNET_INTERFACE_COUNTER_DROP],
- hi->sw_if_index);
+ vlib_zero_combined_counter (&im->combined_sw_if_counters
+ [VNET_INTERFACE_COUNTER_TX],
+ hi->sw_if_index);
+ vlib_zero_combined_counter (&im->combined_sw_if_counters
+ [VNET_INTERFACE_COUNTER_RX],
+ hi->sw_if_index);
+ vlib_zero_simple_counter (&im->sw_if_counters
+ [VNET_INTERFACE_COUNTER_DROP],
+ hi->sw_if_index);
vnet_interface_counter_unlock (im);
}
else
{
hw_if_index = vnet_register_interface (vnm, dev_class->index, vni,
- lisp_gpe_hw_class.index, 0);
+ lisp_gpe_hw_class.index, 0);
hi = vnet_get_hw_interface (vnm, hw_if_index);
}
- hash_set(tuns->hw_if_index_by_dp_table, dp_table, hw_if_index);
+ hash_set (tuns->hw_if_index_by_dp_table, dp_table, hw_if_index);
/* set tunnel termination: post decap, packets are tagged as having been
* originated by lisp-gpe interface */
- hash_set(tuns->sw_if_index_by_vni, vni, hi->sw_if_index);
- hash_set(tuns->vni_by_sw_if_index, hi->sw_if_index, vni);
+ hash_set (tuns->sw_if_index_by_vni, vni, hi->sw_if_index);
+ hash_set (tuns->vni_by_sw_if_index, hi->sw_if_index, vni);
return hi;
}
static void
remove_lisp_gpe_iface (lisp_gpe_main_t * lgm, u32 hi_index, u32 dp_table,
- tunnel_lookup_t * tuns)
+ tunnel_lookup_t * tuns)
{
- vnet_main_t * vnm = lgm->vnet_main;
- vnet_hw_interface_t * hi;
- uword * vnip;
+ vnet_main_t *vnm = lgm->vnet_main;
+ vnet_hw_interface_t *hi;
+ uword *vnip;
hi = vnet_get_hw_interface (vnm, hi_index);
/* disable interface */
- vnet_sw_interface_set_flags (vnm, hi->sw_if_index, 0/* down */);
- vnet_hw_interface_set_flags (vnm, hi->hw_if_index, 0/* down */);
- hash_unset(tuns->hw_if_index_by_dp_table, dp_table);
- vec_add1(lgm->free_tunnel_hw_if_indices, hi->hw_if_index);
+ vnet_sw_interface_set_flags (vnm, hi->sw_if_index, 0 /* down */ );
+ vnet_hw_interface_set_flags (vnm, hi->hw_if_index, 0 /* down */ );
+ hash_unset (tuns->hw_if_index_by_dp_table, dp_table);
+ vec_add1 (lgm->free_tunnel_hw_if_indices, hi->hw_if_index);
/* clean tunnel termination and vni to sw_if_index binding */
- vnip = hash_get(tuns->vni_by_sw_if_index, hi->sw_if_index);
+ vnip = hash_get (tuns->vni_by_sw_if_index, hi->sw_if_index);
if (0 == vnip)
{
clib_warning ("No vni associated to interface %d", hi->sw_if_index);
return;
}
- hash_unset(tuns->sw_if_index_by_vni, vnip[0]);
- hash_unset(tuns->vni_by_sw_if_index, hi->sw_if_index);
+ hash_unset (tuns->sw_if_index_by_vni, vnip[0]);
+ hash_unset (tuns->vni_by_sw_if_index, hi->sw_if_index);
}
static int
lisp_gpe_add_del_l3_iface (lisp_gpe_main_t * lgm,
- vnet_lisp_gpe_add_del_iface_args_t * a)
+ vnet_lisp_gpe_add_del_iface_args_t * a)
{
- vnet_main_t * vnm = lgm->vnet_main;
- tunnel_lookup_t * l3_ifaces = &lgm->l3_ifaces;
- vnet_hw_interface_t * hi;
+ vnet_main_t *vnm = lgm->vnet_main;
+ tunnel_lookup_t *l3_ifaces = &lgm->l3_ifaces;
+ vnet_hw_interface_t *hi;
u32 lookup_next_index4, lookup_next_index6;
- uword * hip, * si;
+ uword *hip, *si;
- hip = hash_get(l3_ifaces->hw_if_index_by_dp_table, a->table_id);
+ hip = hash_get (l3_ifaces->hw_if_index_by_dp_table, a->table_id);
if (a->is_add)
{
if (hip)
- {
- clib_warning ("vrf %d already mapped to a vni", a->table_id);
- return -1;
- }
+ {
+ clib_warning ("vrf %d already mapped to a vni", a->table_id);
+ return -1;
+ }
- si = hash_get(l3_ifaces->sw_if_index_by_vni, a->vni);
+ si = hash_get (l3_ifaces->sw_if_index_by_vni, a->vni);
if (si)
- {
- clib_warning ("Interface for vni %d already exists", a->vni);
- return -1;
- }
+ {
+ clib_warning ("Interface for vni %d already exists", a->vni);
+ return -1;
+ }
/* create lisp iface and populate tunnel tables */
hi = create_lisp_gpe_iface (lgm, a->vni, a->table_id,
- &lisp_gpe_device_class, l3_ifaces);
+ &lisp_gpe_device_class, l3_ifaces);
/* set ingress arc from lgpe_ipX_lookup */
lookup_next_index4 = vlib_node_add_next (lgm->vlib_main,
- lgpe_ip4_lookup_node.index,
- hi->output_node_index);
+ lgpe_ip4_lookup_node.index,
+ hi->output_node_index);
lookup_next_index6 = vlib_node_add_next (lgm->vlib_main,
- lgpe_ip6_lookup_node.index,
- hi->output_node_index);
- hash_set(lgm->lgpe_ip4_lookup_next_index_by_table_id, a->table_id,
- lookup_next_index4);
- hash_set(lgm->lgpe_ip6_lookup_next_index_by_table_id, a->table_id,
- lookup_next_index6);
+ lgpe_ip6_lookup_node.index,
+ hi->output_node_index);
+ hash_set (lgm->lgpe_ip4_lookup_next_index_by_table_id, a->table_id,
+ lookup_next_index4);
+ hash_set (lgm->lgpe_ip6_lookup_next_index_by_table_id, a->table_id,
+ lookup_next_index6);
/* insert default routes that point to lgpe-ipx-lookup */
- add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */1, 1);
- add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */0, 1);
+ add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */ 1, 1);
+ add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */ 0, 1);
/* set egress arcs */
#define _(sym,str) vlib_node_add_named_next_with_slot (vnm->vlib_main, \
hi->tx_node_index, str, LISP_GPE_TX_NEXT_##sym);
- foreach_lisp_gpe_tx_next
+ foreach_lisp_gpe_tx_next
#undef _
-
- /* set interface in appropriate v4 and v6 FIBs */
- lisp_gpe_iface_set_table (hi->sw_if_index, a->table_id, 1);
+ /* set interface in appropriate v4 and v6 FIBs */
+ lisp_gpe_iface_set_table (hi->sw_if_index, a->table_id, 1);
lisp_gpe_iface_set_table (hi->sw_if_index, a->table_id, 0);
/* enable interface */
vnet_sw_interface_set_flags (vnm, hi->sw_if_index,
- VNET_SW_INTERFACE_FLAG_ADMIN_UP);
+ VNET_SW_INTERFACE_FLAG_ADMIN_UP);
vnet_hw_interface_set_flags (vnm, hi->hw_if_index,
- VNET_HW_INTERFACE_FLAG_LINK_UP);
+ VNET_HW_INTERFACE_FLAG_LINK_UP);
}
else
{
if (hip == 0)
- {
- clib_warning("The interface for vrf %d doesn't exist", a->table_id);
- return -1;
- }
+ {
+ clib_warning ("The interface for vrf %d doesn't exist",
+ a->table_id);
+ return -1;
+ }
remove_lisp_gpe_iface (lgm, hip[0], a->table_id, &lgm->l3_ifaces);
/* unset default routes */
- add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */1, 0);
- add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */0, 0);
+ add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */ 1, 0);
+ add_del_lisp_gpe_default_route (a->table_id, /* is_v4 */ 0, 0);
}
return 0;
@@ -991,60 +997,59 @@ lisp_gpe_add_del_l3_iface (lisp_gpe_main_t * lgm,
static int
lisp_gpe_add_del_l2_iface (lisp_gpe_main_t * lgm,
- vnet_lisp_gpe_add_del_iface_args_t * a)
+ vnet_lisp_gpe_add_del_iface_args_t * a)
{
- vnet_main_t * vnm = lgm->vnet_main;
- tunnel_lookup_t * l2_ifaces = &lgm->l2_ifaces;
- vnet_hw_interface_t * hi;
- uword * hip, * si;
+ vnet_main_t *vnm = lgm->vnet_main;
+ tunnel_lookup_t *l2_ifaces = &lgm->l2_ifaces;
+ vnet_hw_interface_t *hi;
+ uword *hip, *si;
u16 bd_index;
- bd_index = bd_find_or_add_bd_index(&bd_main, a->bd_id);
- hip = hash_get(l2_ifaces->hw_if_index_by_dp_table, bd_index);
+ bd_index = bd_find_or_add_bd_index (&bd_main, a->bd_id);
+ hip = hash_get (l2_ifaces->hw_if_index_by_dp_table, bd_index);
if (a->is_add)
{
if (hip)
- {
- clib_warning("bridge domain %d already mapped to a vni", a->bd_id);
- return -1;
- }
+ {
+ clib_warning ("bridge domain %d already mapped to a vni", a->bd_id);
+ return -1;
+ }
- si = hash_get(l2_ifaces->sw_if_index_by_vni, a->vni);
+ si = hash_get (l2_ifaces->sw_if_index_by_vni, a->vni);
if (si)
- {
- clib_warning ("Interface for vni %d already exists", a->vni);
- return -1;
- }
+ {
+ clib_warning ("Interface for vni %d already exists", a->vni);
+ return -1;
+ }
/* create lisp iface and populate tunnel tables */
hi = create_lisp_gpe_iface (lgm, a->vni, bd_index,
- &l2_lisp_gpe_device_class, &lgm->l2_ifaces);
+ &l2_lisp_gpe_device_class, &lgm->l2_ifaces);
/* add iface to l2 bridge domain */
set_int_l2_mode (lgm->vlib_main, vnm, MODE_L2_BRIDGE, hi->sw_if_index,
- bd_index, 0, 0, 0);
+ bd_index, 0, 0, 0);
/* set egress arcs */
#define _(sym,str) vlib_node_add_named_next_with_slot (vnm->vlib_main, \
hi->tx_node_index, str, L2_LISP_GPE_TX_NEXT_##sym);
- foreach_l2_lisp_gpe_tx_next
+ foreach_l2_lisp_gpe_tx_next
#undef _
-
- /* enable interface */
- vnet_sw_interface_set_flags (vnm, hi->sw_if_index,
- VNET_SW_INTERFACE_FLAG_ADMIN_UP);
+ /* enable interface */
+ vnet_sw_interface_set_flags (vnm, hi->sw_if_index,
+ VNET_SW_INTERFACE_FLAG_ADMIN_UP);
vnet_hw_interface_set_flags (vnm, hi->hw_if_index,
- VNET_HW_INTERFACE_FLAG_LINK_UP);
+ VNET_HW_INTERFACE_FLAG_LINK_UP);
}
else
{
if (hip == 0)
- {
- clib_warning("The interface for bridge domain %d doesn't exist",
- a->bd_id);
- return -1;
- }
+ {
+ clib_warning ("The interface for bridge domain %d doesn't exist",
+ a->bd_id);
+ return -1;
+ }
remove_lisp_gpe_iface (lgm, hip[0], bd_index, &lgm->l2_ifaces);
}
@@ -1053,11 +1058,11 @@ lisp_gpe_add_del_l2_iface (lisp_gpe_main_t * lgm,
int
vnet_lisp_gpe_add_del_iface (vnet_lisp_gpe_add_del_iface_args_t * a,
- u32 * hw_if_indexp)
+ u32 * hw_if_indexp)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
- if (vnet_lisp_gpe_enable_disable_status() == 0)
+ if (vnet_lisp_gpe_enable_disable_status () == 0)
{
clib_warning ("LISP is disabled!");
return VNET_API_ERROR_LISP_DISABLED;
@@ -1071,54 +1076,55 @@ vnet_lisp_gpe_add_del_iface (vnet_lisp_gpe_add_del_iface_args_t * a,
static clib_error_t *
lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ vlib_cli_command_t * cmd)
{
- unformat_input_t _line_input, * line_input = &_line_input;
+ unformat_input_t _line_input, *line_input = &_line_input;
u8 is_add = 1;
- clib_error_t * error = 0;
+ clib_error_t *error = 0;
int rv = 0;
u32 table_id, vni, bd_id;
u8 vni_is_set = 0, vrf_is_set = 0, bd_index_is_set = 0;
- vnet_lisp_gpe_add_del_iface_args_t _a, * a = &_a;
+ vnet_lisp_gpe_add_del_iface_args_t _a, *a = &_a;
/* Get a line of input. */
- if (! unformat_user (input, unformat_line_input, line_input))
+ if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "add"))
- is_add = 1;
+ is_add = 1;
else if (unformat (line_input, "del"))
- is_add = 0;
+ is_add = 0;
else if (unformat (line_input, "vrf %d", &table_id))
- {
- vrf_is_set = 1;
- }
+ {
+ vrf_is_set = 1;
+ }
else if (unformat (line_input, "vni %d", &vni))
- {
- vni_is_set = 1;
- }
+ {
+ vni_is_set = 1;
+ }
else if (unformat (line_input, "bd %d", &bd_id))
- {
- bd_index_is_set = 1;
- }
+ {
+ bd_index_is_set = 1;
+ }
else
- {
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
- }
+ {
+ return clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ }
}
if (vrf_is_set && bd_index_is_set)
- return clib_error_return(0, "Cannot set both vrf and brdige domain index!");
+ return clib_error_return (0,
+ "Cannot set both vrf and brdige domain index!");
if (!vni_is_set)
- return clib_error_return(0, "vni must be set!");
+ return clib_error_return (0, "vni must be set!");
if (!vrf_is_set && !bd_index_is_set)
- return clib_error_return(0, "vrf or bridge domain index must be set!");
+ return clib_error_return (0, "vrf or bridge domain index must be set!");
a->is_add = is_add;
a->dp_table = vrf_is_set ? table_id : bd_id;
@@ -1128,15 +1134,25 @@ lisp_gpe_add_del_iface_command_fn (vlib_main_t * vm, unformat_input_t * input,
rv = vnet_lisp_gpe_add_del_iface (a, 0);
if (0 != rv)
{
- error = clib_error_return(0, "failed to %s gpe iface!",
- is_add ? "add" : "delete");
+ error = clib_error_return (0, "failed to %s gpe iface!",
+ is_add ? "add" : "delete");
}
return error;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (add_del_lisp_gpe_iface_command, static) = {
.path = "lisp gpe iface",
.short_help = "lisp gpe iface add/del vni <vni> vrf <vrf>",
.function = lisp_gpe_add_del_iface_command_fn,
};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/lisp-gpe/ip_forward.c b/vnet/vnet/lisp-gpe/ip_forward.c
index 98c52226280..d8ddfd8f016 100644
--- a/vnet/vnet/lisp-gpe/ip_forward.c
+++ b/vnet/vnet/lisp-gpe/ip_forward.c
@@ -18,15 +18,15 @@
/* avoids calling route callbacks for src fib */
static void
ip4_sd_fib_set_adj_index (lisp_gpe_main_t * lgm, ip4_fib_t * fib, u32 flags,
- u32 dst_address_u32, u32 dst_address_length,
- u32 adj_index)
+ u32 dst_address_u32, u32 dst_address_length,
+ u32 adj_index)
{
- ip_lookup_main_t * lm = lgm->lm4;
- uword * hash;
+ ip_lookup_main_t *lm = lgm->lm4;
+ uword *hash;
- if (vec_bytes(fib->old_hash_values))
+ if (vec_bytes (fib->old_hash_values))
memset (fib->old_hash_values, ~0, vec_bytes (fib->old_hash_values));
- if (vec_bytes(fib->new_hash_values))
+ if (vec_bytes (fib->new_hash_values))
memset (fib->new_hash_values, ~0, vec_bytes (fib->new_hash_values));
fib->new_hash_values[0] = adj_index;
@@ -37,8 +37,7 @@ ip4_sd_fib_set_adj_index (lisp_gpe_main_t * lgm, ip4_fib_t * fib, u32 flags,
hash = fib->adj_index_by_dst_address[dst_address_length];
hash = _hash_set3 (hash, dst_address_u32,
- fib->new_hash_values,
- fib->old_hash_values);
+ fib->new_hash_values, fib->old_hash_values);
fib->adj_index_by_dst_address[dst_address_length] = hash;
}
@@ -46,21 +45,20 @@ ip4_sd_fib_set_adj_index (lisp_gpe_main_t * lgm, ip4_fib_t * fib, u32 flags,
/* copied from ip4_forward since it's static */
static void
ip4_fib_init_adj_index_by_dst_address (ip_lookup_main_t * lm,
- ip4_fib_t * fib,
- u32 address_length)
+ ip4_fib_t * fib, u32 address_length)
{
- hash_t * h;
+ hash_t *h;
uword max_index;
ASSERT (lm->fib_result_n_bytes >= sizeof (uword));
- lm->fib_result_n_words = round_pow2 (lm->fib_result_n_bytes, sizeof(uword))
- / sizeof(uword);
+ lm->fib_result_n_words = round_pow2 (lm->fib_result_n_bytes, sizeof (uword))
+ / sizeof (uword);
fib->adj_index_by_dst_address[address_length] =
- hash_create (32 /* elts */, lm->fib_result_n_words * sizeof (uword));
+ hash_create (32 /* elts */ , lm->fib_result_n_words * sizeof (uword));
hash_set_flags (fib->adj_index_by_dst_address[address_length],
- HASH_FLAG_NO_AUTO_SHRINK);
+ HASH_FLAG_NO_AUTO_SHRINK);
h = hash_header (fib->adj_index_by_dst_address[address_length]);
max_index = (hash_value_bytes (h) / sizeof (fib->new_hash_values[0])) - 1;
@@ -72,25 +70,25 @@ ip4_fib_init_adj_index_by_dst_address (ip_lookup_main_t * lm,
static void
ip4_sd_fib_add_del_src_route (lisp_gpe_main_t * lgm,
- ip4_add_del_route_args_t * a)
+ ip4_add_del_route_args_t * a)
{
- ip_lookup_main_t * lm = lgm->lm4;
- ip4_fib_t * fib;
+ ip_lookup_main_t *lm = lgm->lm4;
+ ip4_fib_t *fib;
u32 dst_address, dst_address_length, adj_index, old_adj_index;
- uword * hash, is_del;
+ uword *hash, is_del;
/* Either create new adjacency or use given one depending on arguments. */
if (a->n_add_adj > 0)
- ip_add_adjacency (lm, a->add_adj, a->n_add_adj, &adj_index);
+ ip_add_adjacency (lm, a->add_adj, a->n_add_adj, &adj_index);
else
adj_index = a->adj_index;
dst_address = a->dst_address.data_u32;
dst_address_length = a->dst_address_length;
- fib = pool_elt_at_index(lgm->ip4_src_fibs, a->table_index_or_table_id);
+ fib = pool_elt_at_index (lgm->ip4_src_fibs, a->table_index_or_table_id);
- if (! fib->adj_index_by_dst_address[dst_address_length])
+ if (!fib->adj_index_by_dst_address[dst_address_length])
ip4_fib_init_adj_index_by_dst_address (lm, fib, dst_address_length);
hash = fib->adj_index_by_dst_address[dst_address_length];
@@ -105,83 +103,86 @@ ip4_sd_fib_add_del_src_route (lisp_gpe_main_t * lgm,
}
else
ip4_sd_fib_set_adj_index (lgm, fib, a->flags, dst_address,
- dst_address_length, adj_index);
+ dst_address_length, adj_index);
old_adj_index = fib->old_hash_values[0];
/* Avoid spurious reference count increments */
if (old_adj_index == adj_index
- && adj_index != ~0
- && !(a->flags & IP4_ROUTE_FLAG_KEEP_OLD_ADJACENCY))
+ && adj_index != ~0 && !(a->flags & IP4_ROUTE_FLAG_KEEP_OLD_ADJACENCY))
{
- ip_adjacency_t * adj = ip_get_adjacency (lm, adj_index);
+ ip_adjacency_t *adj = ip_get_adjacency (lm, adj_index);
if (adj->share_count > 0)
- adj->share_count --;
+ adj->share_count--;
}
ip4_fib_mtrie_add_del_route (fib, a->dst_address, dst_address_length,
- is_del ? old_adj_index : adj_index,
- is_del);
+ is_del ? old_adj_index : adj_index, is_del);
/* Delete old adjacency index if present and changed. */
- if (! (a->flags & IP4_ROUTE_FLAG_KEEP_OLD_ADJACENCY)
- && old_adj_index != ~0
- && old_adj_index != adj_index)
+ if (!(a->flags & IP4_ROUTE_FLAG_KEEP_OLD_ADJACENCY)
+ && old_adj_index != ~0 && old_adj_index != adj_index)
ip_del_adjacency (lm, old_adj_index);
}
static void *
ip4_sd_get_src_route (lisp_gpe_main_t * lgm, u32 src_fib_index,
- ip4_address_t * src, u32 address_length)
+ ip4_address_t * src, u32 address_length)
{
- ip4_fib_t * fib = pool_elt_at_index (lgm->ip4_src_fibs, src_fib_index);
- uword * hash, * p;
+ ip4_fib_t *fib = pool_elt_at_index (lgm->ip4_src_fibs, src_fib_index);
+ uword *hash, *p;
hash = fib->adj_index_by_dst_address[address_length];
p = hash_get (hash, src->as_u32);
return (void *) p;
}
+/* *INDENT-OFF* */
typedef CLIB_PACKED (struct ip4_route {
ip4_address_t address;
u32 address_length : 6;
u32 index : 26;
}) ip4_route_t;
+/* *INDENT-ON* */
void
ip4_sd_fib_clear_src_fib (lisp_gpe_main_t * lgm, ip4_fib_t * fib)
{
- ip4_route_t * routes = 0, * r;
+ ip4_route_t *routes = 0, *r;
u32 i;
vec_reset_length (routes);
- for (i = 0; i < ARRAY_LEN (fib->adj_index_by_dst_address); i++) {
- uword * hash = fib->adj_index_by_dst_address[i];
- hash_pair_t * p;
+ for (i = 0; i < ARRAY_LEN (fib->adj_index_by_dst_address); i++)
+ {
+ uword *hash = fib->adj_index_by_dst_address[i];
+ hash_pair_t *p;
ip4_route_t x;
x.address_length = i;
- x.index = 0; /* shut up coverity */
+ x.index = 0; /* shut up coverity */
+ /* *INDENT-OFF* */
hash_foreach_pair (p, hash,
({
x.address.data_u32 = p->key;
vec_add1 (routes, x);
}));
- }
+ /* *INDENT-ON* */
+ }
- vec_foreach (r, routes) {
- ip4_add_del_route_args_t a;
+ vec_foreach (r, routes)
+ {
+ ip4_add_del_route_args_t a;
- memset (&a, 0, sizeof (a));
- a.flags = IP4_ROUTE_FLAG_FIB_INDEX | IP4_ROUTE_FLAG_DEL;
- a.table_index_or_table_id = fib - lgm->ip4_src_fibs;
- a.dst_address = r->address;
- a.dst_address_length = r->address_length;
- a.adj_index = ~0;
+ memset (&a, 0, sizeof (a));
+ a.flags = IP4_ROUTE_FLAG_FIB_INDEX | IP4_ROUTE_FLAG_DEL;
+ a.table_index_or_table_id = fib - lgm->ip4_src_fibs;
+ a.dst_address = r->address;
+ a.dst_address_length = r->address_length;
+ a.adj_index = ~0;
- ip4_sd_fib_add_del_src_route (lgm, &a);
+ ip4_sd_fib_add_del_src_route (lgm, &a);
}
}
@@ -194,36 +195,36 @@ ip4_fib_is_empty (ip4_fib_t * fib)
fib_is_empty = 1;
for (i = ARRAY_LEN (fib->adj_index_by_dst_address) - 1; i >= 0; i--)
{
- uword * hash = fib->adj_index_by_dst_address[i];
+ uword *hash = fib->adj_index_by_dst_address[i];
uword n_elts = hash_elts (hash);
if (n_elts)
- {
- fib_is_empty = 0;
- break;
- }
+ {
+ fib_is_empty = 0;
+ break;
+ }
}
return fib_is_empty;
}
static int
ip4_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id,
- ip_adjacency_t * add_adj, u8 is_add)
+ ip_prefix_t * src_prefix, u32 table_id,
+ ip_adjacency_t * add_adj, u8 is_add)
{
- uword * p;
+ uword *p;
ip4_add_del_route_args_t a;
- ip_adjacency_t * dst_adjp, dst_adj;
- ip4_address_t dst = ip_prefix_v4(dst_prefix), src;
- u32 dst_address_length = ip_prefix_len(dst_prefix), src_address_length = 0;
- ip4_fib_t * src_fib;
+ ip_adjacency_t *dst_adjp, dst_adj;
+ ip4_address_t dst = ip_prefix_v4 (dst_prefix), src;
+ u32 dst_address_length = ip_prefix_len (dst_prefix), src_address_length = 0;
+ ip4_fib_t *src_fib;
if (src_prefix)
{
- src = ip_prefix_v4(src_prefix);
- src_address_length = ip_prefix_len(src_prefix);
+ src = ip_prefix_v4 (src_prefix);
+ src_address_length = ip_prefix_len (src_prefix);
}
else
- memset(&src, 0, sizeof(src));
+ memset (&src, 0, sizeof (src));
/* lookup dst adj */
p = ip4_get_route (lgm->im4, table_id, 0, dst.as_u8, dst_address_length);
@@ -232,71 +233,71 @@ ip4_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
{
/* insert dst prefix to ip4 fib, if it's not in yet */
if (p == 0)
- {
- /* allocate and init src ip4 fib */
- pool_get(lgm->ip4_src_fibs, src_fib);
- ip4_mtrie_init (&src_fib->mtrie);
-
- /* configure adjacency */
- memset(&dst_adj, 0, sizeof(dst_adj));
-
- /* reuse rewrite header to store pointer to src fib */
- dst_adj.rewrite_header.sw_if_index = src_fib - lgm->ip4_src_fibs;
-
- /* dst adj should point to lisp gpe lookup */
- dst_adj.lookup_next_index = lgm->ip4_lookup_next_lgpe_ip4_lookup;
-
- /* explicit_fib_index is used in IP6 FIB lookup, don't reuse it */
- dst_adj.explicit_fib_index = ~0;
- dst_adj.n_adj = 1;
-
- /* make sure we have different signatures for adj in different tables
- * but with the same lookup_next_index and for adj in the same table
- * but associated to different destinations */
- dst_adj.if_address_index = table_id;
- dst_adj.indirect.next_hop.ip4 = dst;
-
- memset(&a, 0, sizeof(a));
- a.flags = IP4_ROUTE_FLAG_TABLE_ID;
- a.table_index_or_table_id = table_id; /* vrf */
- a.adj_index = ~0;
- a.dst_address_length = dst_address_length;
- a.dst_address = dst;
- a.flags |= IP4_ROUTE_FLAG_ADD;
- a.add_adj = &dst_adj;
- a.n_add_adj = 1;
-
- ip4_add_del_route (lgm->im4, &a);
-
- /* lookup dst adj to obtain the adj index */
- p = ip4_get_route (lgm->im4, table_id, 0, dst.as_u8,
- dst_address_length);
-
- /* make sure insertion succeeded */
- if (CLIB_DEBUG)
- {
- ASSERT(p != 0);
- dst_adjp = ip_get_adjacency (lgm->lm4, p[0]);
- ASSERT(dst_adjp->rewrite_header.sw_if_index
- == dst_adj.rewrite_header.sw_if_index);
- }
- }
+ {
+ /* allocate and init src ip4 fib */
+ pool_get (lgm->ip4_src_fibs, src_fib);
+ ip4_mtrie_init (&src_fib->mtrie);
+
+ /* configure adjacency */
+ memset (&dst_adj, 0, sizeof (dst_adj));
+
+ /* reuse rewrite header to store pointer to src fib */
+ dst_adj.rewrite_header.sw_if_index = src_fib - lgm->ip4_src_fibs;
+
+ /* dst adj should point to lisp gpe lookup */
+ dst_adj.lookup_next_index = lgm->ip4_lookup_next_lgpe_ip4_lookup;
+
+ /* explicit_fib_index is used in IP6 FIB lookup, don't reuse it */
+ dst_adj.explicit_fib_index = ~0;
+ dst_adj.n_adj = 1;
+
+ /* make sure we have different signatures for adj in different tables
+ * but with the same lookup_next_index and for adj in the same table
+ * but associated to different destinations */
+ dst_adj.if_address_index = table_id;
+ dst_adj.indirect.next_hop.ip4 = dst;
+
+ memset (&a, 0, sizeof (a));
+ a.flags = IP4_ROUTE_FLAG_TABLE_ID;
+ a.table_index_or_table_id = table_id; /* vrf */
+ a.adj_index = ~0;
+ a.dst_address_length = dst_address_length;
+ a.dst_address = dst;
+ a.flags |= IP4_ROUTE_FLAG_ADD;
+ a.add_adj = &dst_adj;
+ a.n_add_adj = 1;
+
+ ip4_add_del_route (lgm->im4, &a);
+
+ /* lookup dst adj to obtain the adj index */
+ p = ip4_get_route (lgm->im4, table_id, 0, dst.as_u8,
+ dst_address_length);
+
+ /* make sure insertion succeeded */
+ if (CLIB_DEBUG)
+ {
+ ASSERT (p != 0);
+ dst_adjp = ip_get_adjacency (lgm->lm4, p[0]);
+ ASSERT (dst_adjp->rewrite_header.sw_if_index
+ == dst_adj.rewrite_header.sw_if_index);
+ }
+ }
}
else
{
if (p == 0)
- {
- clib_warning("Trying to delete inexistent dst route for %U. Aborting",
- format_ip4_address_and_length, dst.as_u8,
- dst_address_length);
- return -1;
- }
+ {
+ clib_warning
+ ("Trying to delete inexistent dst route for %U. Aborting",
+ format_ip4_address_and_length, dst.as_u8, dst_address_length);
+ return -1;
+ }
}
dst_adjp = ip_get_adjacency (lgm->lm4, p[0]);
/* add/del src prefix to src fib */
- memset(&a, 0, sizeof(a));
+ memset (&a, 0, sizeof (a));
a.flags = IP4_ROUTE_FLAG_TABLE_ID;
a.table_index_or_table_id = dst_adjp->rewrite_header.sw_if_index;
a.adj_index = ~0;
@@ -311,40 +312,40 @@ ip4_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
/* make sure insertion succeeded */
if (CLIB_DEBUG && is_add)
{
- uword * sai;
- ip_adjacency_t * src_adjp;
+ uword *sai;
+ ip_adjacency_t *src_adjp;
sai = ip4_sd_get_src_route (lgm, dst_adjp->rewrite_header.sw_if_index,
- &src, src_address_length);
- ASSERT(sai != 0);
- src_adjp = ip_get_adjacency(lgm->lm4, sai[0]);
- ASSERT(src_adjp->if_address_index == add_adj->if_address_index);
+ &src, src_address_length);
+ ASSERT (sai != 0);
+ src_adjp = ip_get_adjacency (lgm->lm4, sai[0]);
+ ASSERT (src_adjp->if_address_index == add_adj->if_address_index);
}
/* if a delete, check if there are elements left in the src fib */
if (!is_add)
{
- src_fib = pool_elt_at_index(lgm->ip4_src_fibs,
- dst_adjp->rewrite_header.sw_if_index);
+ src_fib = pool_elt_at_index (lgm->ip4_src_fibs,
+ dst_adjp->rewrite_header.sw_if_index);
if (!src_fib)
- return 0;
+ return 0;
/* if there's nothing left */
- if (ip4_fib_is_empty(src_fib))
- {
- /* remove the src fib .. */
- pool_put(lgm->ip4_src_fibs, src_fib);
-
- /* .. and remove dst route */
- memset(&a, 0, sizeof(a));
- a.flags = IP4_ROUTE_FLAG_TABLE_ID;
- a.table_index_or_table_id = table_id; /* vrf */
- a.adj_index = ~0;
- a.dst_address_length = dst_address_length;
- a.dst_address = dst;
- a.flags |= IP4_ROUTE_FLAG_DEL;
-
- ip4_add_del_route (lgm->im4, &a);
- }
+ if (ip4_fib_is_empty (src_fib))
+ {
+ /* remove the src fib .. */
+ pool_put (lgm->ip4_src_fibs, src_fib);
+
+ /* .. and remove dst route */
+ memset (&a, 0, sizeof (a));
+ a.flags = IP4_ROUTE_FLAG_TABLE_ID;
+ a.table_index_or_table_id = table_id; /* vrf */
+ a.adj_index = ~0;
+ a.dst_address_length = dst_address_length;
+ a.dst_address = dst;
+ a.flags |= IP4_ROUTE_FLAG_DEL;
+
+ ip4_add_del_route (lgm->im4, &a);
+ }
}
return 0;
@@ -352,42 +353,42 @@ ip4_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
static void *
ip4_sd_fib_get_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id)
+ ip_prefix_t * src_prefix, u32 table_id)
{
- uword * p;
- ip4_address_t dst = ip_prefix_v4(dst_prefix), src;
- u32 dst_address_length = ip_prefix_len(dst_prefix), src_address_length = 0;
- ip_adjacency_t * dst_adj;
+ uword *p;
+ ip4_address_t dst = ip_prefix_v4 (dst_prefix), src;
+ u32 dst_address_length = ip_prefix_len (dst_prefix), src_address_length = 0;
+ ip_adjacency_t *dst_adj;
if (src_prefix)
{
- src = ip_prefix_v4(src_prefix);
- src_address_length = ip_prefix_len(src_prefix);
+ src = ip_prefix_v4 (src_prefix);
+ src_address_length = ip_prefix_len (src_prefix);
}
else
- memset(&src, 0, sizeof(src));
+ memset (&src, 0, sizeof (src));
/* lookup dst adj */
p = ip4_get_route (lgm->im4, table_id, 0, dst.as_u8, dst_address_length);
if (p == 0)
- return p;
+ return p;
dst_adj = ip_get_adjacency (lgm->lm4, p[0]);
return ip4_sd_get_src_route (lgm, dst_adj->rewrite_header.sw_if_index, &src,
- src_address_length);
+ src_address_length);
}
static u32
ip6_sd_get_src_route (lisp_gpe_main_t * lgm, u32 src_fib_index,
- ip6_address_t * src, u32 address_length)
+ ip6_address_t * src, u32 address_length)
{
int rv;
- BVT(clib_bihash_kv) kv, value;
- ip6_src_fib_t * fib = pool_elt_at_index (lgm->ip6_src_fibs, src_fib_index);
+ BVT (clib_bihash_kv) kv, value;
+ ip6_src_fib_t *fib = pool_elt_at_index (lgm->ip6_src_fibs, src_fib_index);
- ip6_address_t * mask;
+ ip6_address_t *mask;
- ASSERT(address_length <= 128);
+ ASSERT (address_length <= 128);
mask = &fib->fib_masks[address_length];
@@ -395,7 +396,7 @@ ip6_sd_get_src_route (lisp_gpe_main_t * lgm, u32 src_fib_index,
kv.key[1] = src->as_u64[1] & mask->as_u64[1];
kv.key[2] = address_length;
- rv = BV(clib_bihash_search_inline_2)(&fib->ip6_lookup_table, &kv, &value);
+ rv = BV (clib_bihash_search_inline_2) (&fib->ip6_lookup_table, &kv, &value);
if (rv == 0)
return value.value;
@@ -406,28 +407,31 @@ static void
compute_prefix_lengths_in_search_order (ip6_src_fib_t * fib)
{
int i;
- vec_reset_length(fib->prefix_lengths_in_search_order);
+ vec_reset_length (fib->prefix_lengths_in_search_order);
/* Note: bitmap reversed so this is in fact a longest prefix match */
+
+ /* *INDENT-OFF* */
clib_bitmap_foreach(i, fib->non_empty_dst_address_length_bitmap, ({
int dst_address_length = 128 - i;
vec_add1 (fib->prefix_lengths_in_search_order, dst_address_length);
}));
+ /* *INDENT-ON* */
}
/* Rewrite of ip6_add_del_route() because it uses im6 to find the fib */
static void
ip6_sd_fib_add_del_src_route (lisp_gpe_main_t * lgm,
- ip6_add_del_route_args_t * a)
+ ip6_add_del_route_args_t * a)
{
- ip_lookup_main_t * lm = lgm->lm6;
- ip6_src_fib_t * fib;
+ ip_lookup_main_t *lm = lgm->lm6;
+ ip6_src_fib_t *fib;
ip6_address_t dst_address;
u32 dst_address_length, adj_index;
uword is_del;
u32 old_adj_index = ~0;
- BVT(clib_bihash_kv) kv, value;
+ BVT (clib_bihash_kv) kv, value;
- vlib_smp_unsafe_warning();
+ vlib_smp_unsafe_warning ();
is_del = (a->flags & IP6_ROUTE_FLAG_DEL) != 0;
@@ -441,7 +445,7 @@ ip6_sd_fib_add_del_src_route (lisp_gpe_main_t * lgm,
dst_address = a->dst_address;
dst_address_length = a->dst_address_length;
- fib = pool_elt_at_index(lgm->ip6_src_fibs, a->table_index_or_table_id);
+ fib = pool_elt_at_index (lgm->ip6_src_fibs, a->table_index_or_table_id);
ASSERT (dst_address_length < ARRAY_LEN (fib->fib_masks));
ip6_address_mask (&dst_address, &fib->fib_masks[dst_address_length]);
@@ -449,22 +453,22 @@ ip6_sd_fib_add_del_src_route (lisp_gpe_main_t * lgm,
/* refcount accounting */
if (is_del)
{
- ASSERT(fib->dst_address_length_refcounts[dst_address_length] > 0);
+ ASSERT (fib->dst_address_length_refcounts[dst_address_length] > 0);
if (--fib->dst_address_length_refcounts[dst_address_length] == 0)
- {
- fib->non_empty_dst_address_length_bitmap = clib_bitmap_set (
- fib->non_empty_dst_address_length_bitmap,
- 128 - dst_address_length, 0);
- compute_prefix_lengths_in_search_order (fib);
- }
+ {
+ fib->non_empty_dst_address_length_bitmap =
+ clib_bitmap_set (fib->non_empty_dst_address_length_bitmap,
+ 128 - dst_address_length, 0);
+ compute_prefix_lengths_in_search_order (fib);
+ }
}
else
{
fib->dst_address_length_refcounts[dst_address_length]++;
fib->non_empty_dst_address_length_bitmap =
- clib_bitmap_set (fib->non_empty_dst_address_length_bitmap,
- 128 - dst_address_length, 1);
+ clib_bitmap_set (fib->non_empty_dst_address_length_bitmap,
+ 128 - dst_address_length, 1);
compute_prefix_lengths_in_search_order (fib);
}
@@ -472,36 +476,35 @@ ip6_sd_fib_add_del_src_route (lisp_gpe_main_t * lgm,
kv.key[1] = dst_address.as_u64[1];
kv.key[2] = dst_address_length;
- if (BV(clib_bihash_search)(&fib->ip6_lookup_table, &kv, &value) == 0)
+ if (BV (clib_bihash_search) (&fib->ip6_lookup_table, &kv, &value) == 0)
old_adj_index = value.value;
if (is_del)
- BV(clib_bihash_add_del) (&fib->ip6_lookup_table, &kv, 0 /* is_add */);
+ BV (clib_bihash_add_del) (&fib->ip6_lookup_table, &kv, 0 /* is_add */ );
else
{
/* Make sure adj index is valid. */
if (CLIB_DEBUG > 0)
- (void) ip_get_adjacency (lm, adj_index);
+ (void) ip_get_adjacency (lm, adj_index);
kv.value = adj_index;
- BV(clib_bihash_add_del) (&fib->ip6_lookup_table, &kv, 1 /* is_add */);
+ BV (clib_bihash_add_del) (&fib->ip6_lookup_table, &kv, 1 /* is_add */ );
}
/* Avoid spurious reference count increments */
if (old_adj_index == adj_index
&& !(a->flags & IP6_ROUTE_FLAG_KEEP_OLD_ADJACENCY))
{
- ip_adjacency_t * adj = ip_get_adjacency (lm, adj_index);
+ ip_adjacency_t *adj = ip_get_adjacency (lm, adj_index);
if (adj->share_count > 0)
- adj->share_count --;
+ adj->share_count--;
}
/* Delete old adjacency index if present and changed. */
{
- if (! (a->flags & IP6_ROUTE_FLAG_KEEP_OLD_ADJACENCY)
- && old_adj_index != ~0
- && old_adj_index != adj_index)
+ if (!(a->flags & IP6_ROUTE_FLAG_KEEP_OLD_ADJACENCY)
+ && old_adj_index != ~0 && old_adj_index != adj_index)
ip_del_adjacency (lm, old_adj_index);
}
}
@@ -519,11 +522,11 @@ ip6_src_fib_init (ip6_src_fib_t * fib)
i1 = i % 32;
for (j = 0; j < i0; j++)
- fib->fib_masks[i].as_u32[j] = ~0;
+ fib->fib_masks[i].as_u32[j] = ~0;
if (i1)
- fib->fib_masks[i].as_u32[i0] = clib_host_to_net_u32 (
- pow2_mask (i1) << (32 - i1));
+ fib->fib_masks[i].as_u32[i0] =
+ clib_host_to_net_u32 (pow2_mask (i1) << (32 - i1));
}
if (fib->lookup_table_nbuckets == 0)
@@ -534,31 +537,30 @@ ip6_src_fib_init (ip6_src_fib_t * fib)
if (fib->lookup_table_size == 0)
fib->lookup_table_size = IP6_FIB_DEFAULT_HASH_MEMORY_SIZE;
- BV(clib_bihash_init) (&fib->ip6_lookup_table, "ip6 lookup table",
- fib->lookup_table_nbuckets,
- fib->lookup_table_size);
+ BV (clib_bihash_init) (&fib->ip6_lookup_table, "ip6 lookup table",
+ fib->lookup_table_nbuckets, fib->lookup_table_size);
}
static int
ip6_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id,
- ip_adjacency_t * add_adj, u8 is_add)
+ ip_prefix_t * src_prefix, u32 table_id,
+ ip_adjacency_t * add_adj, u8 is_add)
{
u32 adj_index;
ip6_add_del_route_args_t a;
- ip_adjacency_t * dst_adjp, dst_adj;
- ip6_address_t dst = ip_prefix_v6(dst_prefix), src;
- u32 dst_address_length = ip_prefix_len(dst_prefix), src_address_length = 0;
- ip6_src_fib_t * src_fib;
+ ip_adjacency_t *dst_adjp, dst_adj;
+ ip6_address_t dst = ip_prefix_v6 (dst_prefix), src;
+ u32 dst_address_length = ip_prefix_len (dst_prefix), src_address_length = 0;
+ ip6_src_fib_t *src_fib;
if (src_prefix)
{
- src = ip_prefix_v6(src_prefix);
- src_address_length = ip_prefix_len(src_prefix);
+ src = ip_prefix_v6 (src_prefix);
+ src_address_length = ip_prefix_len (src_prefix);
}
else
- memset(&src, 0, sizeof(src));
+ memset (&src, 0, sizeof (src));
/* lookup dst adj and create it if it doesn't exist */
adj_index = ip6_get_route (lgm->im6, table_id, 0, &dst, dst_address_length);
@@ -567,70 +569,71 @@ ip6_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
{
/* insert dst prefix to ip6 fib, if it's not in yet */
if (adj_index == 0)
- {
- /* allocate and init src ip6 fib */
- pool_get(lgm->ip6_src_fibs, src_fib);
- memset(src_fib, 0, sizeof(src_fib[0]));
- ip6_src_fib_init (src_fib);
-
- memset(&dst_adj, 0, sizeof(dst_adj));
-
- /* reuse rewrite header to store pointer to src fib */
- dst_adj.rewrite_header.sw_if_index = src_fib - lgm->ip6_src_fibs;
-
- /* dst adj should point to lisp gpe ip lookup */
- dst_adj.lookup_next_index = lgm->ip6_lookup_next_lgpe_ip6_lookup;
-
- /* explicit_fib_index is used in IP6 FIB lookup, don't reuse it */
- dst_adj.explicit_fib_index = ~0;
- dst_adj.n_adj = 1;
-
- /* make sure we have different signatures for adj in different tables
- * but with the same lookup_next_index and for adj in the same table
- * but associated to different destinations */
- dst_adj.if_address_index = table_id;
- dst_adj.indirect.next_hop.ip6 = dst;
-
- memset(&a, 0, sizeof(a));
- a.flags = IP6_ROUTE_FLAG_TABLE_ID;
- a.table_index_or_table_id = table_id; /* vrf */
- a.adj_index = ~0;
- a.dst_address_length = dst_address_length;
- a.dst_address = dst;
- a.flags |= IP6_ROUTE_FLAG_ADD;
- a.add_adj = &dst_adj;
- a.n_add_adj = 1;
-
- ip6_add_del_route (lgm->im6, &a);
-
- /* lookup dst adj to obtain the adj index */
- adj_index = ip6_get_route (lgm->im6, table_id, 0, &dst,
- dst_address_length);
-
- /* make sure insertion succeeded */
- if (CLIB_DEBUG)
- {
- ASSERT(adj_index != 0);
- dst_adjp = ip_get_adjacency (lgm->lm6, adj_index);
- ASSERT(dst_adjp->rewrite_header.sw_if_index
- == dst_adj.rewrite_header.sw_if_index);
- }
- }
+ {
+ /* allocate and init src ip6 fib */
+ pool_get (lgm->ip6_src_fibs, src_fib);
+ memset (src_fib, 0, sizeof (src_fib[0]));
+ ip6_src_fib_init (src_fib);
+
+ memset (&dst_adj, 0, sizeof (dst_adj));
+
+ /* reuse rewrite header to store pointer to src fib */
+ dst_adj.rewrite_header.sw_if_index = src_fib - lgm->ip6_src_fibs;
+
+ /* dst adj should point to lisp gpe ip lookup */
+ dst_adj.lookup_next_index = lgm->ip6_lookup_next_lgpe_ip6_lookup;
+
+ /* explicit_fib_index is used in IP6 FIB lookup, don't reuse it */
+ dst_adj.explicit_fib_index = ~0;
+ dst_adj.n_adj = 1;
+
+ /* make sure we have different signatures for adj in different tables
+ * but with the same lookup_next_index and for adj in the same table
+ * but associated to different destinations */
+ dst_adj.if_address_index = table_id;
+ dst_adj.indirect.next_hop.ip6 = dst;
+
+ memset (&a, 0, sizeof (a));
+ a.flags = IP6_ROUTE_FLAG_TABLE_ID;
+ a.table_index_or_table_id = table_id; /* vrf */
+ a.adj_index = ~0;
+ a.dst_address_length = dst_address_length;
+ a.dst_address = dst;
+ a.flags |= IP6_ROUTE_FLAG_ADD;
+ a.add_adj = &dst_adj;
+ a.n_add_adj = 1;
+
+ ip6_add_del_route (lgm->im6, &a);
+
+ /* lookup dst adj to obtain the adj index */
+ adj_index = ip6_get_route (lgm->im6, table_id, 0, &dst,
+ dst_address_length);
+
+ /* make sure insertion succeeded */
+ if (CLIB_DEBUG)
+ {
+ ASSERT (adj_index != 0);
+ dst_adjp = ip_get_adjacency (lgm->lm6, adj_index);
+ ASSERT (dst_adjp->rewrite_header.sw_if_index
+ == dst_adj.rewrite_header.sw_if_index);
+ }
+ }
}
else
{
if (adj_index == 0)
- {
- clib_warning("Trying to delete inexistent dst route for %U. Aborting",
- format_ip_prefix, dst_prefix);
- return -1;
- }
+ {
+ clib_warning
+ ("Trying to delete inexistent dst route for %U. Aborting",
+ format_ip_prefix, dst_prefix);
+ return -1;
+ }
}
dst_adjp = ip_get_adjacency (lgm->lm6, adj_index);
/* add/del src prefix to src fib */
- memset(&a, 0, sizeof(a));
+ memset (&a, 0, sizeof (a));
a.flags = IP6_ROUTE_FLAG_TABLE_ID;
a.table_index_or_table_id = dst_adjp->rewrite_header.sw_if_index;
a.adj_index = ~0;
@@ -646,40 +649,40 @@ ip6_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
if (CLIB_DEBUG && is_add)
{
u32 sai;
- ip_adjacency_t * src_adjp;
+ ip_adjacency_t *src_adjp;
sai = ip6_sd_get_src_route (lgm, dst_adjp->rewrite_header.sw_if_index,
- &src, src_address_length);
- ASSERT(sai != 0);
- src_adjp = ip_get_adjacency(lgm->lm6, sai);
- ASSERT(src_adjp->if_address_index == add_adj->if_address_index);
+ &src, src_address_length);
+ ASSERT (sai != 0);
+ src_adjp = ip_get_adjacency (lgm->lm6, sai);
+ ASSERT (src_adjp->if_address_index == add_adj->if_address_index);
}
/* if a delete, check if there are elements left in the src fib */
if (!is_add)
{
- src_fib = pool_elt_at_index(lgm->ip6_src_fibs,
- dst_adjp->rewrite_header.sw_if_index);
+ src_fib = pool_elt_at_index (lgm->ip6_src_fibs,
+ dst_adjp->rewrite_header.sw_if_index);
if (!src_fib)
- return 0;
+ return 0;
/* if there's nothing left */
- if (clib_bitmap_count_set_bits (
- src_fib->non_empty_dst_address_length_bitmap) == 0)
- {
- /* remove src fib .. */
- pool_put(lgm->ip6_src_fibs, src_fib);
-
- /* .. and remove dst route */
- memset(&a, 0, sizeof(a));
- a.flags = IP6_ROUTE_FLAG_TABLE_ID;
- a.table_index_or_table_id = table_id; /* vrf */
- a.adj_index = ~0;
- a.dst_address_length = dst_address_length;
- a.dst_address = dst;
- a.flags |= IP6_ROUTE_FLAG_DEL;
-
- ip6_add_del_route (lgm->im6, &a);
- }
+ if (clib_bitmap_count_set_bits
+ (src_fib->non_empty_dst_address_length_bitmap) == 0)
+ {
+ /* remove src fib .. */
+ pool_put (lgm->ip6_src_fibs, src_fib);
+
+ /* .. and remove dst route */
+ memset (&a, 0, sizeof (a));
+ a.flags = IP6_ROUTE_FLAG_TABLE_ID;
+ a.table_index_or_table_id = table_id; /* vrf */
+ a.adj_index = ~0;
+ a.dst_address_length = dst_address_length;
+ a.dst_address = dst;
+ a.flags |= IP6_ROUTE_FLAG_DEL;
+
+ ip6_add_del_route (lgm->im6, &a);
+ }
}
return 0;
@@ -687,52 +690,53 @@ ip6_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
static u32
ip6_sd_fib_get_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id)
+ ip_prefix_t * src_prefix, u32 table_id)
{
u32 adj_index;
- ip6_address_t dst = ip_prefix_v6(dst_prefix), src;
- u32 dst_address_length = ip_prefix_len(dst_prefix), src_address_length = 0;
- ip_adjacency_t * dst_adj;
+ ip6_address_t dst = ip_prefix_v6 (dst_prefix), src;
+ u32 dst_address_length = ip_prefix_len (dst_prefix), src_address_length = 0;
+ ip_adjacency_t *dst_adj;
if (src_prefix)
{
- src = ip_prefix_v6(src_prefix);
- src_address_length = ip_prefix_len(src_prefix);
+ src = ip_prefix_v6 (src_prefix);
+ src_address_length = ip_prefix_len (src_prefix);
}
else
- memset(&src, 0, sizeof(src));
+ memset (&src, 0, sizeof (src));
/* lookup dst adj */
adj_index = ip6_get_route (lgm->im6, table_id, 0, &dst, dst_address_length);
if (adj_index == 0)
- return adj_index;
+ return adj_index;
dst_adj = ip_get_adjacency (lgm->lm6, adj_index);
return ip6_sd_get_src_route (lgm, dst_adj->rewrite_header.sw_if_index, &src,
- src_address_length);
+ src_address_length);
}
int
ip_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id,
- ip_adjacency_t * add_adj, u8 is_add)
+ ip_prefix_t * src_prefix, u32 table_id,
+ ip_adjacency_t * add_adj, u8 is_add)
{
- return (
- ip_prefix_version(dst_prefix) == IP4 ?
- ip4_sd_fib_add_del_route : ip6_sd_fib_add_del_route) (lgm, dst_prefix,
- src_prefix,
- table_id, add_adj,
- is_add);
+ return (ip_prefix_version (dst_prefix) == IP4 ?
+ ip4_sd_fib_add_del_route : ip6_sd_fib_add_del_route) (lgm,
+ dst_prefix,
+ src_prefix,
+ table_id,
+ add_adj,
+ is_add);
}
u32
ip_sd_fib_get_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id)
+ ip_prefix_t * src_prefix, u32 table_id)
{
- if (ip_prefix_version(dst_prefix) == IP4)
+ if (ip_prefix_version (dst_prefix) == IP4)
{
- u32 * adj_index = ip4_sd_fib_get_route (lgm, dst_prefix, src_prefix,
- table_id);
+ u32 *adj_index = ip4_sd_fib_get_route (lgm, dst_prefix, src_prefix,
+ table_id);
return (adj_index == 0) ? 0 : adj_index[0];
}
else
@@ -741,15 +745,15 @@ ip_sd_fib_get_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
always_inline void
ip4_src_fib_lookup_one (lisp_gpe_main_t * lgm, u32 src_fib_index0,
- ip4_address_t * addr0, u32 * src_adj_index0)
+ ip4_address_t * addr0, u32 * src_adj_index0)
{
ip4_fib_mtrie_leaf_t leaf0, leaf1;
- ip4_fib_mtrie_t * mtrie0;
+ ip4_fib_mtrie_t *mtrie0;
/* if default route not hit in ip4 lookup */
- if (PREDICT_TRUE(src_fib_index0 != (u32 ) ~0))
+ if (PREDICT_TRUE (src_fib_index0 != (u32) ~ 0))
{
- mtrie0 = &vec_elt_at_index(lgm->ip4_src_fibs, src_fib_index0)->mtrie;
+ mtrie0 = &vec_elt_at_index (lgm->ip4_src_fibs, src_fib_index0)->mtrie;
leaf0 = leaf1 = IP4_FIB_MTRIE_LEAF_ROOT;
leaf0 = ip4_fib_mtrie_lookup_step (mtrie0, leaf0, addr0, 0);
@@ -759,7 +763,7 @@ ip4_src_fib_lookup_one (lisp_gpe_main_t * lgm, u32 src_fib_index0,
/* Handle default route. */
leaf0 = (leaf0 == IP4_FIB_MTRIE_LEAF_EMPTY) ?
- mtrie0->default_leaf : leaf0;
+ mtrie0->default_leaf : leaf0;
src_adj_index0[0] = ip4_fib_mtrie_leaf_get_adj_index (leaf0);
}
else
@@ -768,18 +772,19 @@ ip4_src_fib_lookup_one (lisp_gpe_main_t * lgm, u32 src_fib_index0,
always_inline void
ip4_src_fib_lookup_two (lisp_gpe_main_t * lgm, u32 src_fib_index0,
- u32 src_fib_index1, ip4_address_t * addr0,
- ip4_address_t * addr1, u32 * src_adj_index0,
- u32 * src_adj_index1)
+ u32 src_fib_index1, ip4_address_t * addr0,
+ ip4_address_t * addr1, u32 * src_adj_index0,
+ u32 * src_adj_index1)
{
ip4_fib_mtrie_leaf_t leaf0, leaf1;
- ip4_fib_mtrie_t * mtrie0, * mtrie1;
+ ip4_fib_mtrie_t *mtrie0, *mtrie1;
/* if default route not hit in ip4 lookup */
- if (PREDICT_TRUE(src_fib_index0 != (u32 ) ~0 && src_fib_index1 != (u32 ) ~0))
+ if (PREDICT_TRUE
+ (src_fib_index0 != (u32) ~ 0 && src_fib_index1 != (u32) ~ 0))
{
- mtrie0 = &vec_elt_at_index(lgm->ip4_src_fibs, src_fib_index0)->mtrie;
- mtrie1 = &vec_elt_at_index(lgm->ip4_src_fibs, src_fib_index1)->mtrie;
+ mtrie0 = &vec_elt_at_index (lgm->ip4_src_fibs, src_fib_index0)->mtrie;
+ mtrie1 = &vec_elt_at_index (lgm->ip4_src_fibs, src_fib_index1)->mtrie;
leaf0 = leaf1 = IP4_FIB_MTRIE_LEAF_ROOT;
@@ -797,9 +802,9 @@ ip4_src_fib_lookup_two (lisp_gpe_main_t * lgm, u32 src_fib_index0,
/* Handle default route. */
leaf0 = (leaf0 == IP4_FIB_MTRIE_LEAF_EMPTY) ?
- mtrie0->default_leaf : leaf0;
+ mtrie0->default_leaf : leaf0;
leaf1 = (leaf1 == IP4_FIB_MTRIE_LEAF_EMPTY) ?
- mtrie1->default_leaf : leaf1;
+ mtrie1->default_leaf : leaf1;
src_adj_index0[0] = ip4_fib_mtrie_leaf_get_adj_index (leaf0);
src_adj_index1[0] = ip4_fib_mtrie_leaf_get_adj_index (leaf1);
}
@@ -812,10 +817,10 @@ ip4_src_fib_lookup_two (lisp_gpe_main_t * lgm, u32 src_fib_index0,
always_inline uword
lgpe_ip4_lookup (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+ vlib_frame_t * from_frame)
{
- u32 n_left_from, next_index, * from, * to_next;
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ u32 n_left_from, next_index, *from, *to_next;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -826,200 +831,201 @@ lgpe_ip4_lookup (vlib_main_t * vm, vlib_node_runtime_t * node,
{
u32 n_left_to_next;
- vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- ip4_header_t * ip0, * ip1;
- u32 dst_adj_index0, src_adj_index0, src_fib_index0;
- u32 dst_adj_index1, src_adj_index1, src_fib_index1;
- ip_adjacency_t * dst_adj0, * src_adj0, * dst_adj1, * src_adj1;
- u32 next0, next1;
-
- next0 = next1 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t * p2, * p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
-
- vlib_prefetch_buffer_header (p2, LOAD);
- vlib_prefetch_buffer_header (p3, LOAD);
-
- CLIB_PREFETCH (p2->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- CLIB_PREFETCH (p3->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- }
-
- bi0 = from[0];
- bi1 = from[1];
- to_next[0] = bi0;
- to_next[1] = bi1;
- from += 2;
- to_next += 2;
- n_left_to_next -= 2;
- n_left_from -= 2;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
-
- ip0 = vlib_buffer_get_current (b0);
- ip1 = vlib_buffer_get_current (b1);
-
- /* dst lookup was done by ip4 lookup */
- dst_adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
- dst_adj_index1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX];
-
- dst_adj0 = ip_get_adjacency (lgm->lm4, dst_adj_index0);
- dst_adj1 = ip_get_adjacency (lgm->lm4, dst_adj_index1);
-
- src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
- src_fib_index1 = dst_adj1->rewrite_header.sw_if_index;
-
- ip4_src_fib_lookup_two (lgm, src_fib_index0, src_fib_index1,
- &ip0->src_address, &ip1->src_address,
- &src_adj_index0, &src_adj_index1);
-
- /* if a source fib exists */
- if (PREDICT_TRUE((u32) ~0 != src_adj_index0
- && (u32) ~0 != src_adj_index1))
- {
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
- vnet_buffer(b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
-
- src_adj0 = ip_get_adjacency (lgm->lm4, src_adj_index0);
- src_adj1 = ip_get_adjacency (lgm->lm4, src_adj_index1);
-
- next0 = src_adj0->explicit_fib_index;
- next1 = src_adj1->explicit_fib_index;
-
- /* prepare buffer for lisp-gpe output node */
- vnet_buffer (b0)->sw_if_index[VLIB_TX] =
- src_adj0->rewrite_header.sw_if_index;
- vnet_buffer (b1)->sw_if_index[VLIB_TX] =
- src_adj1->rewrite_header.sw_if_index;
-
- /* if multipath: saved_lookup_next_index is reused to store
- * nb of sub-tunnels. If greater than 1, multipath is on.
- * Note that flow hash should be 0 after ipx lookup! */
- if (PREDICT_TRUE(src_adj0->saved_lookup_next_index > 1))
- vnet_buffer (b0)->ip.flow_hash = ip4_compute_flow_hash (
- ip0, IP_FLOW_HASH_DEFAULT);
-
- if (PREDICT_TRUE(src_adj1->saved_lookup_next_index > 1))
- vnet_buffer (b1)->ip.flow_hash = ip4_compute_flow_hash (
- ip1, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- if ((u32) ~0 != src_adj_index0)
- {
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
- src_adj0 = ip_get_adjacency (lgm->lm4, src_adj_index0);
- next0 = src_adj0->explicit_fib_index;
- vnet_buffer (b0)->sw_if_index[VLIB_TX] =
- src_adj0->rewrite_header.sw_if_index;
-
- if (PREDICT_TRUE(src_adj0->saved_lookup_next_index > 1))
- vnet_buffer (b0)->ip.flow_hash = ip4_compute_flow_hash (
- ip0, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
- }
-
- if ((u32) ~0 != src_adj_index1)
- {
- vnet_buffer(b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
- src_adj1 = ip_get_adjacency (lgm->lm4, src_adj_index1);
- next1 = src_adj1->explicit_fib_index;
- vnet_buffer (b1)->sw_if_index[VLIB_TX] =
- src_adj1->rewrite_header.sw_if_index;
- if (PREDICT_TRUE(src_adj1->saved_lookup_next_index > 1))
- vnet_buffer (b1)->ip.flow_hash = ip4_compute_flow_hash (
- ip1, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- next1 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
- }
- }
-
- /* mark the packets for CP lookup if needed*/
- if (PREDICT_FALSE(LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
- vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
- if (PREDICT_FALSE(LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next1))
- vnet_buffer (b1)->lisp.overlay_afi = LISP_AFI_IP;
-
- vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
- n_left_to_next, bi0, bi1, next0,
- next1);
- }
+ {
+ u32 bi0, bi1;
+ vlib_buffer_t *b0, *b1;
+ ip4_header_t *ip0, *ip1;
+ u32 dst_adj_index0, src_adj_index0, src_fib_index0;
+ u32 dst_adj_index1, src_adj_index1, src_fib_index1;
+ ip_adjacency_t *dst_adj0, *src_adj0, *dst_adj1, *src_adj1;
+ u32 next0, next1;
+
+ next0 = next1 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+
+ /* Prefetch next iteration. */
+ {
+ vlib_buffer_t *p2, *p3;
+
+ p2 = vlib_get_buffer (vm, from[2]);
+ p3 = vlib_get_buffer (vm, from[3]);
+
+ vlib_prefetch_buffer_header (p2, LOAD);
+ vlib_prefetch_buffer_header (p3, LOAD);
+
+ CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ }
+
+ bi0 = from[0];
+ bi1 = from[1];
+ to_next[0] = bi0;
+ to_next[1] = bi1;
+ from += 2;
+ to_next += 2;
+ n_left_to_next -= 2;
+ n_left_from -= 2;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+
+ ip0 = vlib_buffer_get_current (b0);
+ ip1 = vlib_buffer_get_current (b1);
+
+ /* dst lookup was done by ip4 lookup */
+ dst_adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
+ dst_adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
+
+ dst_adj0 = ip_get_adjacency (lgm->lm4, dst_adj_index0);
+ dst_adj1 = ip_get_adjacency (lgm->lm4, dst_adj_index1);
+
+ src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
+ src_fib_index1 = dst_adj1->rewrite_header.sw_if_index;
+
+ ip4_src_fib_lookup_two (lgm, src_fib_index0, src_fib_index1,
+ &ip0->src_address, &ip1->src_address,
+ &src_adj_index0, &src_adj_index1);
+
+ /* if a source fib exists */
+ if (PREDICT_TRUE ((u32) ~ 0 != src_adj_index0
+ && (u32) ~ 0 != src_adj_index1))
+ {
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
+ vnet_buffer (b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
+
+ src_adj0 = ip_get_adjacency (lgm->lm4, src_adj_index0);
+ src_adj1 = ip_get_adjacency (lgm->lm4, src_adj_index1);
+
+ next0 = src_adj0->explicit_fib_index;
+ next1 = src_adj1->explicit_fib_index;
+
+ /* prepare buffer for lisp-gpe output node */
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] =
+ src_adj0->rewrite_header.sw_if_index;
+ vnet_buffer (b1)->sw_if_index[VLIB_TX] =
+ src_adj1->rewrite_header.sw_if_index;
+
+ /* if multipath: saved_lookup_next_index is reused to store
+ * nb of sub-tunnels. If greater than 1, multipath is on.
+ * Note that flow hash should be 0 after ipx lookup! */
+ if (PREDICT_TRUE (src_adj0->saved_lookup_next_index > 1))
+ vnet_buffer (b0)->ip.flow_hash =
+ ip4_compute_flow_hash (ip0, IP_FLOW_HASH_DEFAULT);
+
+ if (PREDICT_TRUE (src_adj1->saved_lookup_next_index > 1))
+ vnet_buffer (b1)->ip.flow_hash =
+ ip4_compute_flow_hash (ip1, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ if ((u32) ~ 0 != src_adj_index0)
+ {
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
+ src_adj0 = ip_get_adjacency (lgm->lm4, src_adj_index0);
+ next0 = src_adj0->explicit_fib_index;
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] =
+ src_adj0->rewrite_header.sw_if_index;
+
+ if (PREDICT_TRUE (src_adj0->saved_lookup_next_index > 1))
+ vnet_buffer (b0)->ip.flow_hash =
+ ip4_compute_flow_hash (ip0, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ }
+
+ if ((u32) ~ 0 != src_adj_index1)
+ {
+ vnet_buffer (b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
+ src_adj1 = ip_get_adjacency (lgm->lm4, src_adj_index1);
+ next1 = src_adj1->explicit_fib_index;
+ vnet_buffer (b1)->sw_if_index[VLIB_TX] =
+ src_adj1->rewrite_header.sw_if_index;
+ if (PREDICT_TRUE (src_adj1->saved_lookup_next_index > 1))
+ vnet_buffer (b1)->ip.flow_hash =
+ ip4_compute_flow_hash (ip1, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ next1 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ }
+ }
+
+ /* mark the packets for CP lookup if needed */
+ if (PREDICT_FALSE (LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
+ if (PREDICT_FALSE (LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next1))
+ vnet_buffer (b1)->lisp.overlay_afi = LISP_AFI_IP;
+
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
+ }
while (n_left_from > 0 && n_left_to_next > 0)
- {
- vlib_buffer_t * b0;
- ip4_header_t * ip0;
- u32 bi0, dst_adj_index0, src_adj_index0, src_fib_index0;
- u32 next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
- ip_adjacency_t * dst_adj0, * src_adj0;
-
- bi0 = from[0];
- to_next[0] = bi0;
- from += 1;
- to_next += 1;
- n_left_from -= 1;
- n_left_to_next -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
- ip0 = vlib_buffer_get_current (b0);
-
- /* dst lookup was done by ip4 lookup */
- dst_adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
- dst_adj0 = ip_get_adjacency (lgm->lm4, dst_adj_index0);
- src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
-
- /* do src lookup */
- ip4_src_fib_lookup_one (lgm, src_fib_index0, &ip0->src_address,
- &src_adj_index0);
-
- /* if a source fib exists */
- if (PREDICT_TRUE((u32) ~0 != src_adj_index0))
- {
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
- src_adj0 = ip_get_adjacency (lgm->lm4, src_adj_index0);
- next0 = src_adj0->explicit_fib_index;
-
- /* prepare packet for lisp-gpe output node */
- vnet_buffer (b0)->sw_if_index[VLIB_TX] =
- src_adj0->rewrite_header.sw_if_index;
-
- /* if multipath: saved_lookup_next_index is reused to store
- * nb of sub-tunnels. If greater than 1, multipath is on */
- if (PREDICT_TRUE(src_adj0->saved_lookup_next_index > 1))
- vnet_buffer (b0)->ip.flow_hash = ip4_compute_flow_hash (
- ip0, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
- }
-
- if (PREDICT_FALSE(LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
- vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
-
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
- n_left_to_next, bi0, next0);
- }
+ {
+ vlib_buffer_t *b0;
+ ip4_header_t *ip0;
+ u32 bi0, dst_adj_index0, src_adj_index0, src_fib_index0;
+ u32 next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ ip_adjacency_t *dst_adj0, *src_adj0;
+
+ bi0 = from[0];
+ to_next[0] = bi0;
+ from += 1;
+ to_next += 1;
+ n_left_from -= 1;
+ n_left_to_next -= 1;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ ip0 = vlib_buffer_get_current (b0);
+
+ /* dst lookup was done by ip4 lookup */
+ dst_adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
+ dst_adj0 = ip_get_adjacency (lgm->lm4, dst_adj_index0);
+ src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
+
+ /* do src lookup */
+ ip4_src_fib_lookup_one (lgm, src_fib_index0, &ip0->src_address,
+ &src_adj_index0);
+
+ /* if a source fib exists */
+ if (PREDICT_TRUE ((u32) ~ 0 != src_adj_index0))
+ {
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
+ src_adj0 = ip_get_adjacency (lgm->lm4, src_adj_index0);
+ next0 = src_adj0->explicit_fib_index;
+
+ /* prepare packet for lisp-gpe output node */
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] =
+ src_adj0->rewrite_header.sw_if_index;
+
+ /* if multipath: saved_lookup_next_index is reused to store
+ * nb of sub-tunnels. If greater than 1, multipath is on */
+ if (PREDICT_TRUE (src_adj0->saved_lookup_next_index > 1))
+ vnet_buffer (b0)->ip.flow_hash =
+ ip4_compute_flow_hash (ip0, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ }
+
+ if (PREDICT_FALSE (LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
+
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
+ }
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
return from_frame->n_vectors;
}
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (lgpe_ip4_lookup_node) = {
.function = lgpe_ip4_lookup,
.name = "lgpe-ip4-lookup",
@@ -1034,24 +1040,25 @@ VLIB_REGISTER_NODE (lgpe_ip4_lookup_node) = {
#undef _
},
};
+/* *INDENT-ON* */
static u32
ip6_src_fib_lookup (lisp_gpe_main_t * lgm, u32 src_fib_index,
- ip6_address_t * src)
+ ip6_address_t * src)
{
int i, len;
int rv;
- BVT(clib_bihash_kv) kv, value;
- ip6_src_fib_t * fib = pool_elt_at_index (lgm->ip6_src_fibs, src_fib_index);
+ BVT (clib_bihash_kv) kv, value;
+ ip6_src_fib_t *fib = pool_elt_at_index (lgm->ip6_src_fibs, src_fib_index);
len = vec_len (fib->prefix_lengths_in_search_order);
for (i = 0; i < len; i++)
{
int dst_address_length = fib->prefix_lengths_in_search_order[i];
- ip6_address_t * mask;
+ ip6_address_t *mask;
- ASSERT(dst_address_length >= 0 && dst_address_length <= 128);
+ ASSERT (dst_address_length >= 0 && dst_address_length <= 128);
mask = &fib->fib_masks[dst_address_length];
@@ -1059,9 +1066,11 @@ ip6_src_fib_lookup (lisp_gpe_main_t * lgm, u32 src_fib_index,
kv.key[1] = src->as_u64[1] & mask->as_u64[1];
kv.key[2] = dst_address_length;
- rv = BV(clib_bihash_search_inline_2)(&fib->ip6_lookup_table, &kv, &value);
+ rv =
+ BV (clib_bihash_search_inline_2) (&fib->ip6_lookup_table, &kv,
+ &value);
if (rv == 0)
- return value.value;
+ return value.value;
}
return 0;
@@ -1069,10 +1078,10 @@ ip6_src_fib_lookup (lisp_gpe_main_t * lgm, u32 src_fib_index,
always_inline void
ip6_src_fib_lookup_one (lisp_gpe_main_t * lgm, u32 src_fib_index0,
- ip6_address_t * addr0, u32 * src_adj_index0)
+ ip6_address_t * addr0, u32 * src_adj_index0)
{
/* if default route not hit in ip6 lookup */
- if (PREDICT_TRUE(src_fib_index0 != (u32 ) ~0))
+ if (PREDICT_TRUE (src_fib_index0 != (u32) ~ 0))
src_adj_index0[0] = ip6_src_fib_lookup (lgm, src_fib_index0, addr0);
else
src_adj_index0[0] = ~0;
@@ -1080,15 +1089,16 @@ ip6_src_fib_lookup_one (lisp_gpe_main_t * lgm, u32 src_fib_index0,
always_inline void
ip6_src_fib_lookup_two (lisp_gpe_main_t * lgm, u32 src_fib_index0,
- u32 src_fib_index1, ip6_address_t * addr0,
- ip6_address_t * addr1, u32 * src_adj_index0,
- u32 * src_adj_index1)
+ u32 src_fib_index1, ip6_address_t * addr0,
+ ip6_address_t * addr1, u32 * src_adj_index0,
+ u32 * src_adj_index1)
{
/* if default route not hit in ip6 lookup */
- if (PREDICT_TRUE(src_fib_index0 != (u32 ) ~0 && src_fib_index1 != (u32 ) ~0))
+ if (PREDICT_TRUE
+ (src_fib_index0 != (u32) ~ 0 && src_fib_index1 != (u32) ~ 0))
{
- src_adj_index0[0] = ip6_src_fib_lookup(lgm, src_fib_index0, addr0);
- src_adj_index1[0] = ip6_src_fib_lookup(lgm, src_fib_index1, addr1);
+ src_adj_index0[0] = ip6_src_fib_lookup (lgm, src_fib_index0, addr0);
+ src_adj_index1[0] = ip6_src_fib_lookup (lgm, src_fib_index1, addr1);
}
else
{
@@ -1099,10 +1109,10 @@ ip6_src_fib_lookup_two (lisp_gpe_main_t * lgm, u32 src_fib_index0,
always_inline uword
lgpe_ip6_lookup (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * from_frame)
+ vlib_frame_t * from_frame)
{
- u32 n_left_from, next_index, * from, * to_next;
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ u32 n_left_from, next_index, *from, *to_next;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -1113,202 +1123,203 @@ lgpe_ip6_lookup (vlib_main_t * vm, vlib_node_runtime_t * node,
{
u32 n_left_to_next;
- vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
+ vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 bi0, bi1;
- vlib_buffer_t * b0, * b1;
- ip6_header_t * ip0, * ip1;
- u32 dst_adj_index0, src_adj_index0, src_fib_index0, dst_adj_index1,
- src_adj_index1, src_fib_index1;
- ip_adjacency_t * dst_adj0, * src_adj0, * dst_adj1, * src_adj1;
- u32 next0, next1;
-
- next0 = next1 = LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t * p2, * p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
-
- vlib_prefetch_buffer_header (p2, LOAD);
- vlib_prefetch_buffer_header (p3, LOAD);
-
- CLIB_PREFETCH (p2->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- CLIB_PREFETCH (p3->data, 2*CLIB_CACHE_LINE_BYTES, LOAD);
- }
-
- bi0 = from[0];
- bi1 = from[1];
- to_next[0] = bi0;
- to_next[1] = bi1;
- from += 2;
- to_next += 2;
- n_left_to_next -= 2;
- n_left_from -= 2;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
-
- ip0 = vlib_buffer_get_current (b0);
- ip1 = vlib_buffer_get_current (b1);
-
- /* dst lookup was done by ip6 lookup */
- dst_adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
- dst_adj_index1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX];
-
- dst_adj0 = ip_get_adjacency (lgm->lm6, dst_adj_index0);
- dst_adj1 = ip_get_adjacency (lgm->lm6, dst_adj_index1);
-
- src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
- src_fib_index1 = dst_adj1->rewrite_header.sw_if_index;
-
- ip6_src_fib_lookup_two (lgm, src_fib_index0, src_fib_index1,
- &ip0->src_address, &ip1->src_address,
- &src_adj_index0, &src_adj_index1);
-
- /* if a source fib exists */
- if (PREDICT_TRUE((u32) ~0 != src_adj_index0
- && (u32) ~0 != src_adj_index1))
- {
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
- vnet_buffer(b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
-
- src_adj0 = ip_get_adjacency (lgm->lm6, src_adj_index0);
- src_adj1 = ip_get_adjacency (lgm->lm6, src_adj_index1);
-
- next0 = src_adj0->explicit_fib_index;
- next1 = src_adj1->explicit_fib_index;
-
- /* prepare buffer for lisp-gpe output node */
- vnet_buffer (b0)->sw_if_index[VLIB_TX] =
- src_adj0->rewrite_header.sw_if_index;
- vnet_buffer (b1)->sw_if_index[VLIB_TX] =
- src_adj1->rewrite_header.sw_if_index;
-
- /* if multipath: saved_lookup_next_index is reused to store
- * nb of sub-tunnels. If greater than 1, multipath is on.
- * Note that flow hash should be 0 after ipx lookup! */
- if (PREDICT_TRUE(src_adj0->saved_lookup_next_index > 1))
- vnet_buffer (b0)->ip.flow_hash = ip6_compute_flow_hash (
- ip0, IP_FLOW_HASH_DEFAULT);
-
- if (PREDICT_TRUE(src_adj1->saved_lookup_next_index > 1))
- vnet_buffer (b1)->ip.flow_hash = ip6_compute_flow_hash (
- ip1, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- if (src_adj_index0 != (u32) ~0)
- {
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
- src_adj0 = ip_get_adjacency (lgm->lm6, src_adj_index0);
- next0 = src_adj0->explicit_fib_index;
- vnet_buffer (b0)->sw_if_index[VLIB_TX] =
- src_adj0->rewrite_header.sw_if_index;
-
- if (PREDICT_TRUE(src_adj0->saved_lookup_next_index > 1))
- vnet_buffer (b0)->ip.flow_hash = ip6_compute_flow_hash (
- ip0, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
- }
-
- if (src_adj_index1 != (u32) ~0)
- {
- vnet_buffer(b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
- src_adj1 = ip_get_adjacency (lgm->lm6, src_adj_index1);
- next1 = src_adj1->explicit_fib_index;
- vnet_buffer (b1)->sw_if_index[VLIB_TX] =
- src_adj1->rewrite_header.sw_if_index;
-
- if (PREDICT_TRUE(src_adj1->saved_lookup_next_index > 1))
- vnet_buffer (b1)->ip.flow_hash = ip6_compute_flow_hash (
- ip1, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- next1 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
- }
- }
-
- /* mark the packets for CP lookup if needed*/
- if (PREDICT_FALSE(LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
- vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
- if (PREDICT_FALSE(LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next1))
- vnet_buffer (b1)->lisp.overlay_afi = LISP_AFI_IP;
-
- vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next,
- n_left_to_next, bi0, bi1, next0,
- next1);
- }
+ {
+ u32 bi0, bi1;
+ vlib_buffer_t *b0, *b1;
+ ip6_header_t *ip0, *ip1;
+ u32 dst_adj_index0, src_adj_index0, src_fib_index0, dst_adj_index1,
+ src_adj_index1, src_fib_index1;
+ ip_adjacency_t *dst_adj0, *src_adj0, *dst_adj1, *src_adj1;
+ u32 next0, next1;
+
+ next0 = next1 = LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
+
+ /* Prefetch next iteration. */
+ {
+ vlib_buffer_t *p2, *p3;
+
+ p2 = vlib_get_buffer (vm, from[2]);
+ p3 = vlib_get_buffer (vm, from[3]);
+
+ vlib_prefetch_buffer_header (p2, LOAD);
+ vlib_prefetch_buffer_header (p3, LOAD);
+
+ CLIB_PREFETCH (p2->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ CLIB_PREFETCH (p3->data, 2 * CLIB_CACHE_LINE_BYTES, LOAD);
+ }
+
+ bi0 = from[0];
+ bi1 = from[1];
+ to_next[0] = bi0;
+ to_next[1] = bi1;
+ from += 2;
+ to_next += 2;
+ n_left_to_next -= 2;
+ n_left_from -= 2;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ b1 = vlib_get_buffer (vm, bi1);
+
+ ip0 = vlib_buffer_get_current (b0);
+ ip1 = vlib_buffer_get_current (b1);
+
+ /* dst lookup was done by ip6 lookup */
+ dst_adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
+ dst_adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX];
+
+ dst_adj0 = ip_get_adjacency (lgm->lm6, dst_adj_index0);
+ dst_adj1 = ip_get_adjacency (lgm->lm6, dst_adj_index1);
+
+ src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
+ src_fib_index1 = dst_adj1->rewrite_header.sw_if_index;
+
+ ip6_src_fib_lookup_two (lgm, src_fib_index0, src_fib_index1,
+ &ip0->src_address, &ip1->src_address,
+ &src_adj_index0, &src_adj_index1);
+
+ /* if a source fib exists */
+ if (PREDICT_TRUE ((u32) ~ 0 != src_adj_index0
+ && (u32) ~ 0 != src_adj_index1))
+ {
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
+ vnet_buffer (b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
+
+ src_adj0 = ip_get_adjacency (lgm->lm6, src_adj_index0);
+ src_adj1 = ip_get_adjacency (lgm->lm6, src_adj_index1);
+
+ next0 = src_adj0->explicit_fib_index;
+ next1 = src_adj1->explicit_fib_index;
+
+ /* prepare buffer for lisp-gpe output node */
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] =
+ src_adj0->rewrite_header.sw_if_index;
+ vnet_buffer (b1)->sw_if_index[VLIB_TX] =
+ src_adj1->rewrite_header.sw_if_index;
+
+ /* if multipath: saved_lookup_next_index is reused to store
+ * nb of sub-tunnels. If greater than 1, multipath is on.
+ * Note that flow hash should be 0 after ipx lookup! */
+ if (PREDICT_TRUE (src_adj0->saved_lookup_next_index > 1))
+ vnet_buffer (b0)->ip.flow_hash =
+ ip6_compute_flow_hash (ip0, IP_FLOW_HASH_DEFAULT);
+
+ if (PREDICT_TRUE (src_adj1->saved_lookup_next_index > 1))
+ vnet_buffer (b1)->ip.flow_hash =
+ ip6_compute_flow_hash (ip1, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ if (src_adj_index0 != (u32) ~ 0)
+ {
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
+ src_adj0 = ip_get_adjacency (lgm->lm6, src_adj_index0);
+ next0 = src_adj0->explicit_fib_index;
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] =
+ src_adj0->rewrite_header.sw_if_index;
+
+ if (PREDICT_TRUE (src_adj0->saved_lookup_next_index > 1))
+ vnet_buffer (b0)->ip.flow_hash =
+ ip6_compute_flow_hash (ip0, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ }
+
+ if (src_adj_index1 != (u32) ~ 0)
+ {
+ vnet_buffer (b1)->ip.adj_index[VLIB_TX] = src_adj_index1;
+ src_adj1 = ip_get_adjacency (lgm->lm6, src_adj_index1);
+ next1 = src_adj1->explicit_fib_index;
+ vnet_buffer (b1)->sw_if_index[VLIB_TX] =
+ src_adj1->rewrite_header.sw_if_index;
+
+ if (PREDICT_TRUE (src_adj1->saved_lookup_next_index > 1))
+ vnet_buffer (b1)->ip.flow_hash =
+ ip6_compute_flow_hash (ip1, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ next1 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ }
+ }
+
+ /* mark the packets for CP lookup if needed */
+ if (PREDICT_FALSE (LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
+ if (PREDICT_FALSE (LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next1))
+ vnet_buffer (b1)->lisp.overlay_afi = LISP_AFI_IP;
+
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
+ }
while (n_left_from > 0 && n_left_to_next > 0)
- {
- vlib_buffer_t * b0;
- ip6_header_t * ip0;
- u32 bi0, dst_adj_index0, src_adj_index0, src_fib_index0;
- u32 next0 = LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
- ip_adjacency_t * dst_adj0, * src_adj0;
-
- bi0 = from[0];
- to_next[0] = bi0;
- from += 1;
- to_next += 1;
- n_left_from -= 1;
- n_left_to_next -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
- ip0 = vlib_buffer_get_current (b0);
-
- /* dst lookup was done by ip6 lookup */
- dst_adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX];
- dst_adj0 = ip_get_adjacency (lgm->lm6, dst_adj_index0);
- src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
-
- /* do src lookup */
- ip6_src_fib_lookup_one (lgm, src_fib_index0, &ip0->src_address,
- &src_adj_index0);
-
- /* if a source fib exists */
- if (PREDICT_TRUE(src_adj_index0 != (u32 ) ~0))
- {
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
- src_adj0 = ip_get_adjacency (lgm->lm6, src_adj_index0);
- next0 = src_adj0->explicit_fib_index;
-
- /* prepare packet for lisp-gpe output node */
- vnet_buffer (b0)->sw_if_index[VLIB_TX] =
- src_adj0->rewrite_header.sw_if_index;
-
- /* if multipath: saved_lookup_next_index is reused to store
- * nb of sub-tunnels. If greater than 1, multipath is on */
- if (PREDICT_TRUE(src_adj0->saved_lookup_next_index > 1))
- vnet_buffer (b0)->ip.flow_hash = ip6_compute_flow_hash (
- ip0, IP_FLOW_HASH_DEFAULT);
- }
- else
- {
- next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
- }
-
- /* mark the packets for CP lookup if needed*/
- if (PREDICT_FALSE(LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
- vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
-
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next,
- n_left_to_next, bi0, next0);
- }
+ {
+ vlib_buffer_t *b0;
+ ip6_header_t *ip0;
+ u32 bi0, dst_adj_index0, src_adj_index0, src_fib_index0;
+ u32 next0 = LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ ip_adjacency_t *dst_adj0, *src_adj0;
+
+ bi0 = from[0];
+ to_next[0] = bi0;
+ from += 1;
+ to_next += 1;
+ n_left_from -= 1;
+ n_left_to_next -= 1;
+
+ b0 = vlib_get_buffer (vm, bi0);
+ ip0 = vlib_buffer_get_current (b0);
+
+ /* dst lookup was done by ip6 lookup */
+ dst_adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
+ dst_adj0 = ip_get_adjacency (lgm->lm6, dst_adj_index0);
+ src_fib_index0 = dst_adj0->rewrite_header.sw_if_index;
+
+ /* do src lookup */
+ ip6_src_fib_lookup_one (lgm, src_fib_index0, &ip0->src_address,
+ &src_adj_index0);
+
+ /* if a source fib exists */
+ if (PREDICT_TRUE (src_adj_index0 != (u32) ~ 0))
+ {
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = src_adj_index0;
+ src_adj0 = ip_get_adjacency (lgm->lm6, src_adj_index0);
+ next0 = src_adj0->explicit_fib_index;
+
+ /* prepare packet for lisp-gpe output node */
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] =
+ src_adj0->rewrite_header.sw_if_index;
+
+ /* if multipath: saved_lookup_next_index is reused to store
+ * nb of sub-tunnels. If greater than 1, multipath is on */
+ if (PREDICT_TRUE (src_adj0->saved_lookup_next_index > 1))
+ vnet_buffer (b0)->ip.flow_hash =
+ ip6_compute_flow_hash (ip0, IP_FLOW_HASH_DEFAULT);
+ }
+ else
+ {
+ next0 = LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ }
+
+ /* mark the packets for CP lookup if needed */
+ if (PREDICT_FALSE (LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP == next0))
+ vnet_buffer (b0)->lisp.overlay_afi = LISP_AFI_IP;
+
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
+ }
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
return from_frame->n_vectors;
}
+/* *INDENT-OFF* */
VLIB_REGISTER_NODE (lgpe_ip6_lookup_node) = {
.function = lgpe_ip6_lookup,
.name = "lgpe-ip6-lookup",
@@ -1323,3 +1334,12 @@ VLIB_REGISTER_NODE (lgpe_ip6_lookup_node) = {
#undef _
},
};
+/* *INDENT-ON* */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe.c b/vnet/vnet/lisp-gpe/lisp_gpe.c
index 922788538a3..60358ec8c4a 100644
--- a/vnet/vnet/lisp-gpe/lisp_gpe.c
+++ b/vnet/vnet/lisp-gpe/lisp_gpe.c
@@ -20,19 +20,19 @@ lisp_gpe_main_t lisp_gpe_main;
static int
lisp_gpe_rewrite (lisp_gpe_tunnel_t * t, lisp_gpe_sub_tunnel_t * st,
- locator_pair_t * lp)
+ locator_pair_t * lp)
{
u8 *rw = 0;
- lisp_gpe_header_t * lisp0;
+ lisp_gpe_header_t *lisp0;
int len;
- if (ip_addr_version(&lp->lcl_loc) == IP4)
+ if (ip_addr_version (&lp->lcl_loc) == IP4)
{
- ip4_header_t * ip0;
- ip4_udp_lisp_gpe_header_t * h0;
- len = sizeof(*h0);
+ ip4_header_t *ip0;
+ ip4_udp_lisp_gpe_header_t *h0;
+ len = sizeof (*h0);
- vec_validate_aligned(rw, len - 1, CLIB_CACHE_LINE_BYTES);
+ vec_validate_aligned (rw, len - 1, CLIB_CACHE_LINE_BYTES);
h0 = (ip4_udp_lisp_gpe_header_t *) rw;
@@ -43,8 +43,8 @@ lisp_gpe_rewrite (lisp_gpe_tunnel_t * t, lisp_gpe_sub_tunnel_t * st,
ip0->protocol = IP_PROTOCOL_UDP;
/* we fix up the ip4 header length and checksum after-the-fact */
- ip_address_copy_addr(&ip0->src_address, &lp->lcl_loc);
- ip_address_copy_addr(&ip0->dst_address, &lp->rmt_loc);
+ ip_address_copy_addr (&ip0->src_address, &lp->lcl_loc);
+ ip_address_copy_addr (&ip0->dst_address, &lp->rmt_loc);
ip0->checksum = ip4_header_checksum (ip0);
/* UDP header, randomize src port on something, maybe? */
@@ -56,24 +56,24 @@ lisp_gpe_rewrite (lisp_gpe_tunnel_t * t, lisp_gpe_sub_tunnel_t * st,
}
else
{
- ip6_header_t * ip0;
- ip6_udp_lisp_gpe_header_t * h0;
- len = sizeof(*h0);
+ ip6_header_t *ip0;
+ ip6_udp_lisp_gpe_header_t *h0;
+ len = sizeof (*h0);
- vec_validate_aligned(rw, len - 1, CLIB_CACHE_LINE_BYTES);
+ vec_validate_aligned (rw, len - 1, CLIB_CACHE_LINE_BYTES);
h0 = (ip6_udp_lisp_gpe_header_t *) rw;
/* Fixed portion of the (outer) ip6 header */
ip0 = &h0->ip6;
ip0->ip_version_traffic_class_and_flow_label =
- clib_host_to_net_u32 (0x6 << 28);
+ clib_host_to_net_u32 (0x6 << 28);
ip0->hop_limit = 254;
ip0->protocol = IP_PROTOCOL_UDP;
/* we fix up the ip6 header length after-the-fact */
- ip_address_copy_addr(&ip0->src_address, &lp->lcl_loc);
- ip_address_copy_addr(&ip0->dst_address, &lp->rmt_loc);
+ ip_address_copy_addr (&ip0->src_address, &lp->lcl_loc);
+ ip_address_copy_addr (&ip0->dst_address, &lp->rmt_loc);
/* UDP header, randomize src port on something, maybe? */
h0->udp.src_port = clib_host_to_net_u16 (4341);
@@ -89,19 +89,18 @@ lisp_gpe_rewrite (lisp_gpe_tunnel_t * t, lisp_gpe_sub_tunnel_t * st,
lisp0->next_protocol = t->next_protocol;
lisp0->iid = clib_host_to_net_u32 (t->vni);
- st->is_ip4 = ip_addr_version(&lp->lcl_loc) == IP4;
+ st->is_ip4 = ip_addr_version (&lp->lcl_loc) == IP4;
st->rewrite = rw;
return 0;
}
static int
-weight_cmp (normalized_sub_tunnel_weights_t *a,
- normalized_sub_tunnel_weights_t *b)
+weight_cmp (normalized_sub_tunnel_weights_t * a,
+ normalized_sub_tunnel_weights_t * b)
{
int cmp = a->weight - b->weight;
return (cmp == 0
- ? a->sub_tunnel_index - b->sub_tunnel_index
- : (cmp > 0 ? -1 : 1));
+ ? a->sub_tunnel_index - b->sub_tunnel_index : (cmp > 0 ? -1 : 1));
}
/** Computes sub tunnel load balancing vector.
@@ -112,15 +111,15 @@ compute_sub_tunnels_balancing_vector (lisp_gpe_tunnel_t * t)
{
uword n_sts, i, n_nsts, n_nsts_left;
f64 sum_weight, norm, error, tolerance;
- normalized_sub_tunnel_weights_t * nsts = 0, * stp;
- lisp_gpe_sub_tunnel_t * sts = t->sub_tunnels;
- u32 * st_lbv = 0;
+ normalized_sub_tunnel_weights_t *nsts = 0, *stp;
+ lisp_gpe_sub_tunnel_t *sts = t->sub_tunnels;
+ u32 *st_lbv = 0;
/* Accept 1% error */
tolerance = .01;
n_sts = vec_len (sts);
- vec_validate(nsts, 2 * n_sts - 1);
+ vec_validate (nsts, 2 * n_sts - 1);
sum_weight = 0;
for (i = 0; i < n_sts; i++)
@@ -137,12 +136,12 @@ compute_sub_tunnels_balancing_vector (lisp_gpe_tunnel_t * t)
if (n_sts == 1)
{
nsts[0].weight = 1;
- _vec_len(nsts) = 1;
+ _vec_len (nsts) = 1;
goto build_lbv;
}
/* Sort sub-tunnels by weight */
- qsort (nsts, n_nsts, sizeof(u32), (void * )weight_cmp);
+ qsort (nsts, n_nsts, sizeof (u32), (void *) weight_cmp);
/* Save copies of all next hop weights to avoid being overwritten in loop below. */
for (i = 0; i < n_nsts; i++)
@@ -150,42 +149,42 @@ compute_sub_tunnels_balancing_vector (lisp_gpe_tunnel_t * t)
/* Try larger and larger power of 2 sized blocks until we
find one where traffic flows to within 1% of specified weights. */
- for (n_nsts = max_pow2 (n_sts); ; n_nsts *= 2)
+ for (n_nsts = max_pow2 (n_sts);; n_nsts *= 2)
{
error = 0;
norm = n_nsts / sum_weight;
n_nsts_left = n_nsts;
for (i = 0; i < n_sts; i++)
- {
- f64 nf = nsts[n_sts + i].weight * norm;
- word n = flt_round_nearest (nf);
+ {
+ f64 nf = nsts[n_sts + i].weight * norm;
+ word n = flt_round_nearest (nf);
- n = n > n_nsts_left ? n_nsts_left : n;
- n_nsts_left -= n;
- error += fabs (nf - n);
- nsts[i].weight = n;
- }
+ n = n > n_nsts_left ? n_nsts_left : n;
+ n_nsts_left -= n;
+ error += fabs (nf - n);
+ nsts[i].weight = n;
+ }
nsts[0].weight += n_nsts_left;
/* Less than 5% average error per adjacency with this size adjacency block? */
if (error <= tolerance * n_nsts)
- {
- /* Truncate any next hops with zero weight. */
- _vec_len (nsts) = i;
- break;
- }
+ {
+ /* Truncate any next hops with zero weight. */
+ _vec_len (nsts) = i;
+ break;
+ }
}
- build_lbv:
+build_lbv:
/* build load balancing vector */
vec_foreach (stp, nsts)
- {
- for (i = 0; i < stp[0].weight; i++)
- vec_add1(st_lbv, stp[0].sub_tunnel_index);
- }
+ {
+ for (i = 0; i < stp[0].weight; i++)
+ vec_add1 (st_lbv, stp[0].sub_tunnel_index);
+ }
t->sub_tunnels_lbv = st_lbv;
t->sub_tunnels_lbv_count = n_nsts;
@@ -196,11 +195,11 @@ static void
create_sub_tunnels (lisp_gpe_main_t * lgm, lisp_gpe_tunnel_t * t)
{
lisp_gpe_sub_tunnel_t st;
- locator_pair_t * lp = 0;
+ locator_pair_t *lp = 0;
int i;
/* create sub-tunnels for all locator pairs */
- for (i = 0; i < vec_len(t->locator_pairs); i++)
+ for (i = 0; i < vec_len (t->locator_pairs); i++)
{
lp = &t->locator_pairs[i];
st.locator_pair_index = i;
@@ -209,11 +208,11 @@ create_sub_tunnels (lisp_gpe_main_t * lgm, lisp_gpe_tunnel_t * t)
/* compute rewrite for sub-tunnel */
lisp_gpe_rewrite (t, &st, lp);
- vec_add1(t->sub_tunnels, st);
+ vec_add1 (t->sub_tunnels, st);
}
/* normalize weights and compute sub-tunnel load balancing vector */
- compute_sub_tunnels_balancing_vector(t);
+ compute_sub_tunnels_balancing_vector (t);
}
#define foreach_copy_field \
@@ -224,23 +223,23 @@ _(vni) \
_(action)
static int
-add_del_ip_tunnel (vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u8 is_l2,
- u32 * tun_index_res)
+add_del_ip_tunnel (vnet_lisp_gpe_add_del_fwd_entry_args_t * a, u8 is_l2,
+ u32 * tun_index_res)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
lisp_gpe_tunnel_t *t = 0;
lisp_gpe_tunnel_key_t key;
- lisp_gpe_sub_tunnel_t * stp = 0;
- uword * p;
+ lisp_gpe_sub_tunnel_t *stp = 0;
+ uword *p;
/* prepare tunnel key */
- memset(&key, 0, sizeof(key));
+ memset (&key, 0, sizeof (key));
/* fill in the key's remote eid */
if (!is_l2)
- ip_prefix_copy (&key.rmt.ippref, &gid_address_ippref(&a->rmt_eid));
+ ip_prefix_copy (&key.rmt.ippref, &gid_address_ippref (&a->rmt_eid));
else
- mac_copy (&key.rmt.mac, &gid_address_mac(&a->rmt_eid));
+ mac_copy (&key.rmt.mac, &gid_address_mac (&a->rmt_eid));
key.vni = clib_host_to_net_u32 (a->vni);
@@ -250,10 +249,10 @@ add_del_ip_tunnel (vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u8 is_l2,
{
/* adding a tunnel: tunnel must not already exist */
if (p)
- return VNET_API_ERROR_INVALID_VALUE;
+ return VNET_API_ERROR_INVALID_VALUE;
if (a->decap_next_index >= LISP_GPE_INPUT_N_NEXT)
- return VNET_API_ERROR_INVALID_DECAP_NEXT;
+ return VNET_API_ERROR_INVALID_DECAP_NEXT;
pool_get_aligned (lgm->tunnels, t, CLIB_CACHE_LINE_BYTES);
memset (t, 0, sizeof (*t));
@@ -263,54 +262,54 @@ add_del_ip_tunnel (vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u8 is_l2,
foreach_copy_field;
#undef _
- t->locator_pairs = vec_dup(a->locator_pairs);
+ t->locator_pairs = vec_dup (a->locator_pairs);
/* if vni is non-default */
if (a->vni)
- t->flags = LISP_GPE_FLAGS_I;
+ t->flags = LISP_GPE_FLAGS_I;
/* work in lisp-gpe not legacy mode */
t->flags |= LISP_GPE_FLAGS_P;
/* next proto */
if (!is_l2)
- t->next_protocol = ip_prefix_version(&key.rmt.ippref) == IP4 ?
- LISP_GPE_NEXT_PROTO_IP4 : LISP_GPE_NEXT_PROTO_IP6;
+ t->next_protocol = ip_prefix_version (&key.rmt.ippref) == IP4 ?
+ LISP_GPE_NEXT_PROTO_IP4 : LISP_GPE_NEXT_PROTO_IP6;
else
- t->next_protocol = LISP_GPE_NEXT_PROTO_ETHERNET;
+ t->next_protocol = LISP_GPE_NEXT_PROTO_ETHERNET;
/* build sub-tunnels for lowest priority locator-pairs */
if (!a->is_negative)
- create_sub_tunnels (lgm, t);
+ create_sub_tunnels (lgm, t);
- mhash_set(&lgm->lisp_gpe_tunnel_by_key, &key, t - lgm->tunnels, 0);
+ mhash_set (&lgm->lisp_gpe_tunnel_by_key, &key, t - lgm->tunnels, 0);
/* return tunnel index */
if (tun_index_res)
- tun_index_res[0] = t - lgm->tunnels;
+ tun_index_res[0] = t - lgm->tunnels;
}
else
{
/* deleting a tunnel: tunnel must exist */
if (!p)
- {
- clib_warning("Tunnel for eid %U doesn't exist!", format_gid_address,
- &a->rmt_eid);
- return VNET_API_ERROR_NO_SUCH_ENTRY;
- }
+ {
+ clib_warning ("Tunnel for eid %U doesn't exist!",
+ format_gid_address, &a->rmt_eid);
+ return VNET_API_ERROR_NO_SUCH_ENTRY;
+ }
- t = pool_elt_at_index(lgm->tunnels, p[0]);
+ t = pool_elt_at_index (lgm->tunnels, p[0]);
- mhash_unset(&lgm->lisp_gpe_tunnel_by_key, &key, 0);
+ mhash_unset (&lgm->lisp_gpe_tunnel_by_key, &key, 0);
- vec_foreach(stp, t->sub_tunnels)
+ vec_foreach (stp, t->sub_tunnels)
{
- vec_free(stp->rewrite);
+ vec_free (stp->rewrite);
}
- vec_free(t->sub_tunnels);
- vec_free(t->sub_tunnels_lbv);
- vec_free(t->locator_pairs);
- pool_put(lgm->tunnels, t);
+ vec_free (t->sub_tunnels);
+ vec_free (t->sub_tunnels_lbv);
+ vec_free (t->locator_pairs);
+ pool_put (lgm->tunnels, t);
}
return 0;
@@ -318,17 +317,17 @@ add_del_ip_tunnel (vnet_lisp_gpe_add_del_fwd_entry_args_t *a, u8 is_l2,
static int
build_ip_adjacency (lisp_gpe_main_t * lgm, ip_adjacency_t * adj, u32 table_id,
- u32 vni, u32 tun_index, u32 n_sub_tun, u8 is_negative,
- u8 action, u8 ip_ver)
+ u32 vni, u32 tun_index, u32 n_sub_tun, u8 is_negative,
+ u8 action, u8 ip_ver)
{
- uword * lookup_next_index, * lgpe_sw_if_index, * lnip;
+ uword *lookup_next_index, *lgpe_sw_if_index, *lnip;
- memset(adj, 0, sizeof(adj[0]));
+ memset (adj, 0, sizeof (adj[0]));
adj->n_adj = 1;
/* fill in lookup_next_index with a 'legal' value to avoid problems */
adj->lookup_next_index = (ip_ver == IP4) ?
- lgm->ip4_lookup_next_lgpe_ip4_lookup :
- lgm->ip6_lookup_next_lgpe_ip6_lookup;
+ lgm->ip4_lookup_next_lgpe_ip4_lookup :
+ lgm->ip6_lookup_next_lgpe_ip6_lookup;
/* positive mapping */
if (!is_negative)
@@ -336,14 +335,14 @@ build_ip_adjacency (lisp_gpe_main_t * lgm, ip_adjacency_t * adj, u32 table_id,
/* send packets that hit this adj to lisp-gpe interface output node in
* requested vrf. */
lnip = (ip_ver == IP4) ?
- lgm->lgpe_ip4_lookup_next_index_by_table_id :
- lgm->lgpe_ip6_lookup_next_index_by_table_id;
- lookup_next_index = hash_get(lnip, table_id);
- lgpe_sw_if_index = hash_get(lgm->l3_ifaces.sw_if_index_by_vni, vni);
+ lgm->lgpe_ip4_lookup_next_index_by_table_id :
+ lgm->lgpe_ip6_lookup_next_index_by_table_id;
+ lookup_next_index = hash_get (lnip, table_id);
+ lgpe_sw_if_index = hash_get (lgm->l3_ifaces.sw_if_index_by_vni, vni);
/* the assumption is that the interface must've been created before
* programming the dp */
- ASSERT(lookup_next_index != 0 && lgpe_sw_if_index != 0);
+ ASSERT (lookup_next_index != 0 && lgpe_sw_if_index != 0);
/* hijack explicit fib index to store lisp interface node index,
* if_address_index for the tunnel index and saved lookup next index
@@ -361,68 +360,68 @@ build_ip_adjacency (lisp_gpe_main_t * lgm, ip_adjacency_t * adj, u32 table_id,
adj->if_address_index = tun_index;
switch (action)
- {
- case LISP_NO_ACTION:
- /* TODO update timers? */
- case LISP_FORWARD_NATIVE:
- /* TODO check if route/next-hop for eid exists in fib and add
- * more specific for the eid with the next-hop found */
- case LISP_SEND_MAP_REQUEST:
- /* insert tunnel that always sends map-request */
- adj->explicit_fib_index = (ip_ver == IP4) ?
- LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP:
- LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
- break;
- case LISP_DROP:
- /* for drop fwd entries, just add route, no need to add encap tunnel */
- adj->explicit_fib_index = (ip_ver == IP4 ?
- LGPE_IP4_LOOKUP_NEXT_DROP : LGPE_IP6_LOOKUP_NEXT_DROP);
- break;
- default:
- return -1;
- }
+ {
+ case LISP_NO_ACTION:
+ /* TODO update timers? */
+ case LISP_FORWARD_NATIVE:
+ /* TODO check if route/next-hop for eid exists in fib and add
+ * more specific for the eid with the next-hop found */
+ case LISP_SEND_MAP_REQUEST:
+ /* insert tunnel that always sends map-request */
+ adj->explicit_fib_index = (ip_ver == IP4) ?
+ LGPE_IP4_LOOKUP_NEXT_LISP_CP_LOOKUP :
+ LGPE_IP6_LOOKUP_NEXT_LISP_CP_LOOKUP;
+ break;
+ case LISP_DROP:
+ /* for drop fwd entries, just add route, no need to add encap tunnel */
+ adj->explicit_fib_index = (ip_ver == IP4 ?
+ LGPE_IP4_LOOKUP_NEXT_DROP :
+ LGPE_IP6_LOOKUP_NEXT_DROP);
+ break;
+ default:
+ return -1;
+ }
}
return 0;
}
static int
add_del_ip_fwd_entry (lisp_gpe_main_t * lgm,
- vnet_lisp_gpe_add_del_fwd_entry_args_t * a)
+ vnet_lisp_gpe_add_del_fwd_entry_args_t * a)
{
- ip_adjacency_t adj, * adjp;
- lisp_gpe_tunnel_t * t;
+ ip_adjacency_t adj, *adjp;
+ lisp_gpe_tunnel_t *t;
u32 rv, tun_index = ~0, n_sub_tuns = 0;
- ip_prefix_t * rmt_pref, * lcl_pref;
+ ip_prefix_t *rmt_pref, *lcl_pref;
u8 ip_ver;
- rmt_pref = &gid_address_ippref(&a->rmt_eid);
- lcl_pref = &gid_address_ippref(&a->lcl_eid);
- ip_ver = ip_prefix_version(rmt_pref);
+ rmt_pref = &gid_address_ippref (&a->rmt_eid);
+ lcl_pref = &gid_address_ippref (&a->lcl_eid);
+ ip_ver = ip_prefix_version (rmt_pref);
/* add/del tunnel to tunnels pool and prepares rewrite */
if (0 != a->locator_pairs)
{
- rv = add_del_ip_tunnel (a, 0 /* is_l2 */, &tun_index);
+ rv = add_del_ip_tunnel (a, 0 /* is_l2 */ , &tun_index);
if (rv)
- {
- clib_warning ("failed to build tunnel!");
- return rv;
- }
+ {
+ clib_warning ("failed to build tunnel!");
+ return rv;
+ }
if (a->is_add)
- {
- t = pool_elt_at_index(lgm->tunnels, tun_index);
- n_sub_tuns = t->sub_tunnels_lbv_count;
- }
+ {
+ t = pool_elt_at_index (lgm->tunnels, tun_index);
+ n_sub_tuns = t->sub_tunnels_lbv_count;
+ }
}
/* setup adjacency for eid */
rv = build_ip_adjacency (lgm, &adj, a->table_id, a->vni, tun_index,
- n_sub_tuns, a->is_negative, a->action,
- ip_ver);
+ n_sub_tuns, a->is_negative, a->action, ip_ver);
/* add/delete route for eid */
rv |= ip_sd_fib_add_del_route (lgm, rmt_pref, lcl_pref, a->table_id, &adj,
- a->is_add);
+ a->is_add);
if (rv)
{
@@ -435,43 +434,43 @@ add_del_ip_fwd_entry (lisp_gpe_main_t * lgm,
{
u32 adj_index;
adj_index = ip_sd_fib_get_route (lgm, rmt_pref, lcl_pref, a->table_id);
- ASSERT(adj_index != 0);
+ ASSERT (adj_index != 0);
adjp = ip_get_adjacency ((ip_ver == IP4) ? lgm->lm4 : lgm->lm6,
- adj_index);
+ adj_index);
- ASSERT(adjp != 0 && adjp->if_address_index == tun_index);
+ ASSERT (adjp != 0 && adjp->if_address_index == tun_index);
}
return rv;
}
static void
-make_mac_fib_key (BVT(clib_bihash_kv) *kv, u16 bd_index, u8 src_mac[6],
- u8 dst_mac[6])
+make_mac_fib_key (BVT (clib_bihash_kv) * kv, u16 bd_index, u8 src_mac[6],
+ u8 dst_mac[6])
{
- kv->key[0] = (((u64) bd_index) << 48) | mac_to_u64(dst_mac);
- kv->key[1] = mac_to_u64(src_mac);
+ kv->key[0] = (((u64) bd_index) << 48) | mac_to_u64 (dst_mac);
+ kv->key[1] = mac_to_u64 (src_mac);
kv->key[2] = 0;
}
u32
lisp_l2_fib_lookup (lisp_gpe_main_t * lgm, u16 bd_index, u8 src_mac[6],
- u8 dst_mac[6])
+ u8 dst_mac[6])
{
int rv;
- BVT(clib_bihash_kv) kv, value;
+ BVT (clib_bihash_kv) kv, value;
- make_mac_fib_key(&kv, bd_index, src_mac, dst_mac);
- rv = BV(clib_bihash_search_inline_2) (&lgm->l2_fib, &kv, &value);
+ make_mac_fib_key (&kv, bd_index, src_mac, dst_mac);
+ rv = BV (clib_bihash_search_inline_2) (&lgm->l2_fib, &kv, &value);
/* no match, try with src 0, catch all for dst */
if (rv != 0)
{
kv.key[1] = 0;
- rv = BV(clib_bihash_search_inline_2) (&lgm->l2_fib, &kv, &value);
+ rv = BV (clib_bihash_search_inline_2) (&lgm->l2_fib, &kv, &value);
if (rv == 0)
- return value.value;
+ return value.value;
}
return ~0;
@@ -479,22 +478,22 @@ lisp_l2_fib_lookup (lisp_gpe_main_t * lgm, u16 bd_index, u8 src_mac[6],
u32
lisp_l2_fib_add_del_entry (lisp_gpe_main_t * lgm, u16 bd_index, u8 src_mac[6],
- u8 dst_mac[6], u32 val, u8 is_add)
+ u8 dst_mac[6], u32 val, u8 is_add)
{
- BVT(clib_bihash_kv) kv, value;
+ BVT (clib_bihash_kv) kv, value;
u32 old_val = ~0;
- make_mac_fib_key(&kv, bd_index, src_mac, dst_mac);
+ make_mac_fib_key (&kv, bd_index, src_mac, dst_mac);
- if (BV(clib_bihash_search) (&lgm->l2_fib, &kv, &value) == 0)
+ if (BV (clib_bihash_search) (&lgm->l2_fib, &kv, &value) == 0)
old_val = value.value;
if (!is_add)
- BV(clib_bihash_add_del) (&lgm->l2_fib, &kv, 0 /* is_add */);
+ BV (clib_bihash_add_del) (&lgm->l2_fib, &kv, 0 /* is_add */ );
else
{
kv.value = val;
- BV(clib_bihash_add_del) (&lgm->l2_fib, &kv, 1 /* is_add */);
+ BV (clib_bihash_add_del) (&lgm->l2_fib, &kv, 1 /* is_add */ );
}
return old_val;
}
@@ -502,45 +501,45 @@ lisp_l2_fib_add_del_entry (lisp_gpe_main_t * lgm, u16 bd_index, u8 src_mac[6],
static void
l2_fib_init (lisp_gpe_main_t * lgm)
{
- BV(clib_bihash_init) (&lgm->l2_fib, "l2 fib",
- 1 << max_log2 (L2_FIB_DEFAULT_HASH_NUM_BUCKETS),
- L2_FIB_DEFAULT_HASH_MEMORY_SIZE);
+ BV (clib_bihash_init) (&lgm->l2_fib, "l2 fib",
+ 1 << max_log2 (L2_FIB_DEFAULT_HASH_NUM_BUCKETS),
+ L2_FIB_DEFAULT_HASH_MEMORY_SIZE);
}
static int
add_del_l2_fwd_entry (lisp_gpe_main_t * lgm,
- vnet_lisp_gpe_add_del_fwd_entry_args_t * a)
+ vnet_lisp_gpe_add_del_fwd_entry_args_t * a)
{
int rv;
u32 tun_index;
- bd_main_t * bdm = &bd_main;
- uword * bd_indexp;
+ bd_main_t *bdm = &bd_main;
+ uword *bd_indexp;
/* create tunnel */
- rv = add_del_ip_tunnel (a, 1 /* is_l2 */, &tun_index);
+ rv = add_del_ip_tunnel (a, 1 /* is_l2 */ , &tun_index);
if (rv)
return rv;
- bd_indexp = hash_get(bdm->bd_index_by_bd_id, a->bd_id);
+ bd_indexp = hash_get (bdm->bd_index_by_bd_id, a->bd_id);
if (!bd_indexp)
{
- clib_warning("bridge domain %d doesn't exist", a->bd_id);
+ clib_warning ("bridge domain %d doesn't exist", a->bd_id);
return -1;
}
/* add entry to l2 lisp fib */
- lisp_l2_fib_add_del_entry (lgm, bd_indexp[0], gid_address_mac(&a->lcl_eid),
- gid_address_mac(&a->rmt_eid), tun_index,
- a->is_add);
+ lisp_l2_fib_add_del_entry (lgm, bd_indexp[0], gid_address_mac (&a->lcl_eid),
+ gid_address_mac (&a->rmt_eid), tun_index,
+ a->is_add);
return 0;
}
int
vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
- u32 * hw_if_indexp)
+ u32 * hw_if_indexp)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
u8 type;
if (vnet_lisp_gpe_enable_disable_status () == 0)
@@ -549,7 +548,7 @@ vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
return VNET_API_ERROR_LISP_DISABLED;
}
- type = gid_address_type(&a->rmt_eid);
+ type = gid_address_type (&a->rmt_eid);
switch (type)
{
case GID_ADDR_IP_PREFIX:
@@ -557,147 +556,145 @@ vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
case GID_ADDR_MAC:
return add_del_l2_fwd_entry (lgm, a);
default:
- clib_warning("Forwarding entries for type %d not supported!", type);
+ clib_warning ("Forwarding entries for type %d not supported!", type);
return -1;
}
}
static clib_error_t *
lisp_gpe_add_del_fwd_entry_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
- unformat_input_t _line_input, * line_input = &_line_input;
+ unformat_input_t _line_input, *line_input = &_line_input;
u8 is_add = 1;
ip_address_t lloc, rloc;
- clib_error_t * error = 0;
- gid_address_t _reid, * reid = &_reid, _leid, * leid = &_leid;
+ clib_error_t *error = 0;
+ gid_address_t _reid, *reid = &_reid, _leid, *leid = &_leid;
u8 reid_set = 0, leid_set = 0, is_negative = 0, vrf_set = 0, vni_set = 0;
u32 vni, vrf, action = ~0, p, w;
- locator_pair_t pair, * pairs = 0;
+ locator_pair_t pair, *pairs = 0;
int rv;
/* Get a line of input. */
- if (! unformat_user (input, unformat_line_input, line_input))
+ if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "del"))
- is_add = 0;
+ is_add = 0;
else if (unformat (line_input, "add"))
- is_add = 1;
- else if (unformat (line_input, "leid %U",
- unformat_gid_address, leid))
- {
- leid_set = 1;
- }
- else if (unformat (line_input, "reid %U",
- unformat_gid_address, reid))
- {
- reid_set = 1;
- }
+ is_add = 1;
+ else if (unformat (line_input, "leid %U", unformat_gid_address, leid))
+ {
+ leid_set = 1;
+ }
+ else if (unformat (line_input, "reid %U", unformat_gid_address, reid))
+ {
+ reid_set = 1;
+ }
else if (unformat (line_input, "vni %u", &vni))
- {
- gid_address_vni (leid) = vni;
- gid_address_vni (reid) = vni;
- vni_set = 1;
- }
+ {
+ gid_address_vni (leid) = vni;
+ gid_address_vni (reid) = vni;
+ vni_set = 1;
+ }
else if (unformat (line_input, "vrf %u", &vrf))
- {
- vrf_set = 1;
- }
+ {
+ vrf_set = 1;
+ }
else if (unformat (line_input, "negative action %U",
- unformat_negative_mapping_action, &action))
- {
- is_negative = 1;
- }
+ unformat_negative_mapping_action, &action))
+ {
+ is_negative = 1;
+ }
else if (unformat (line_input, "loc-pair %U %U p %d w %d",
- unformat_ip_address, &lloc,
- unformat_ip_address, &rloc, &p, &w))
- {
- pair.lcl_loc = lloc;
- pair.rmt_loc = rloc;
- pair.priority = p;
- pair.weight = w;
- vec_add1(pairs, pair);
- }
+ unformat_ip_address, &lloc,
+ unformat_ip_address, &rloc, &p, &w))
+ {
+ pair.lcl_loc = lloc;
+ pair.rmt_loc = rloc;
+ pair.priority = p;
+ pair.weight = w;
+ vec_add1 (pairs, pair);
+ }
else
- {
- error = unformat_parse_error (line_input);
- goto done;
- }
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
}
unformat_free (line_input);
if (!vni_set || !vrf_set)
{
- error = clib_error_return(0, "vni and vrf must be set!");
+ error = clib_error_return (0, "vni and vrf must be set!");
goto done;
}
if (!reid_set)
{
- error = clib_error_return(0, "remote eid must be set!");
+ error = clib_error_return (0, "remote eid must be set!");
goto done;
}
if (is_negative)
{
if (~0 == action)
- {
- error = clib_error_return(0, "no action set for negative tunnel!");
- goto done;
- }
+ {
+ error = clib_error_return (0, "no action set for negative tunnel!");
+ goto done;
+ }
}
else
{
if (vec_len (pairs) == 0)
- {
- error = clib_error_return (0, "expected ip4/ip6 locators.");
- goto done;
- }
+ {
+ error = clib_error_return (0, "expected ip4/ip6 locators.");
+ goto done;
+ }
}
-
-
if (!leid_set)
{
/* if leid not set, make sure it's the same AFI like reid */
- gid_address_type(leid) = gid_address_type(reid);
+ gid_address_type (leid) = gid_address_type (reid);
if (GID_ADDR_IP_PREFIX == gid_address_type (reid))
- gid_address_ip_version(leid) = gid_address_ip_version(reid);
+ gid_address_ip_version (leid) = gid_address_ip_version (reid);
}
/* add fwd entry */
- vnet_lisp_gpe_add_del_fwd_entry_args_t _a, * a = &_a;
- memset (a, 0, sizeof(a[0]));
+ vnet_lisp_gpe_add_del_fwd_entry_args_t _a, *a = &_a;
+ memset (a, 0, sizeof (a[0]));
a->is_add = is_add;
a->vni = vni;
a->table_id = vrf;
- gid_address_copy(&a->lcl_eid, leid);
- gid_address_copy(&a->rmt_eid, reid);
+ gid_address_copy (&a->lcl_eid, leid);
+ gid_address_copy (&a->rmt_eid, reid);
a->locator_pairs = pairs;
rv = vnet_lisp_gpe_add_del_fwd_entry (a, 0);
if (0 != rv)
{
- error = clib_error_return(0, "failed to %s gpe tunnel!",
- is_add ? "add" : "delete");
+ error = clib_error_return (0, "failed to %s gpe tunnel!",
+ is_add ? "add" : "delete");
}
- done:
- vec_free(pairs);
+done:
+ vec_free (pairs);
return error;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (lisp_gpe_add_del_fwd_entry_command, static) = {
.path = "lisp gpe tunnel",
.short_help = "lisp gpe tunnel add/del vni <vni> vrf <vrf> [leid <leid>]"
"reid <reid> [lloc <sloc> rloc <rloc>] [negative action <action>]",
.function = lisp_gpe_add_del_fwd_entry_command_fn,
};
+/* *INDENT-ON* */
static u8 *
format_decap_next (u8 * s, va_list * args)
@@ -721,70 +718,77 @@ format_decap_next (u8 * s, va_list * args)
u8 *
format_lisp_gpe_tunnel (u8 * s, va_list * args)
{
- lisp_gpe_tunnel_t * t = va_arg (*args, lisp_gpe_tunnel_t *);
- lisp_gpe_main_t * lgm = vnet_lisp_gpe_get_main();
- locator_pair_t * lp = 0;
- normalized_sub_tunnel_weights_t * nstw;
-
- s = format (s, "tunnel %d vni %d (0x%x)\n", t - lgm->tunnels, t->vni, t->vni);
- s = format (s, " fibs: encap %d, decap %d decap next %U\n",
- t->encap_fib_index, t->decap_fib_index, format_decap_next,
- t->decap_next_index);
- s = format (s, " lisp ver %d ", (t->ver_res>>6));
+ lisp_gpe_tunnel_t *t = va_arg (*args, lisp_gpe_tunnel_t *);
+ lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
+ locator_pair_t *lp = 0;
+ normalized_sub_tunnel_weights_t *nstw;
+
+ s =
+ format (s, "tunnel %d vni %d (0x%x)\n", t - lgm->tunnels, t->vni, t->vni);
+ s =
+ format (s, " fibs: encap %d, decap %d decap next %U\n",
+ t->encap_fib_index, t->decap_fib_index, format_decap_next,
+ t->decap_next_index);
+ s = format (s, " lisp ver %d ", (t->ver_res >> 6));
#define _(n,v) if (t->flags & v) s = format (s, "%s-bit ", #n);
foreach_lisp_gpe_flag_bit;
#undef _
s = format (s, "next_protocol %d ver_res %x res %x\n",
- t->next_protocol, t->ver_res, t->res);
+ t->next_protocol, t->ver_res, t->res);
s = format (s, " locator-pairs:\n");
- vec_foreach(lp, t->locator_pairs)
- {
- s = format (s, " local: %U remote: %U weight %d\n",
- format_ip_address, &lp->lcl_loc, format_ip_address,
- &lp->rmt_loc, lp->weight);
- }
+ vec_foreach (lp, t->locator_pairs)
+ {
+ s = format (s, " local: %U remote: %U weight %d\n",
+ format_ip_address, &lp->lcl_loc, format_ip_address,
+ &lp->rmt_loc, lp->weight);
+ }
s = format (s, " active sub-tunnels:\n");
- vec_foreach(nstw, t->norm_sub_tunnel_weights)
- {
- lp = vec_elt_at_index(t->locator_pairs, nstw->sub_tunnel_index);
- s = format (s, " local: %U remote: %U weight %d\n", format_ip_address,
- &lp->lcl_loc, format_ip_address, &lp->rmt_loc, nstw->weight);
- }
+ vec_foreach (nstw, t->norm_sub_tunnel_weights)
+ {
+ lp = vec_elt_at_index (t->locator_pairs, nstw->sub_tunnel_index);
+ s = format (s, " local: %U remote: %U weight %d\n", format_ip_address,
+ &lp->lcl_loc, format_ip_address, &lp->rmt_loc, nstw->weight);
+ }
return s;
}
static clib_error_t *
show_lisp_gpe_tunnel_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
- lisp_gpe_tunnel_t * t;
-
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
+ lisp_gpe_tunnel_t *t;
+
if (pool_elts (lgm->tunnels) == 0)
vlib_cli_output (vm, "No lisp-gpe tunnels configured...");
+ /* *INDENT-OFF* */
pool_foreach (t, lgm->tunnels,
({
vlib_cli_output (vm, "%U", format_lisp_gpe_tunnel, t);
}));
-
+ /* *INDENT-ON* */
+
return 0;
}
-VLIB_CLI_COMMAND (show_lisp_gpe_tunnel_command, static) = {
- .path = "show lisp gpe tunnel",
- .function = show_lisp_gpe_tunnel_command_fn,
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_lisp_gpe_tunnel_command, static) =
+{
+ .path = "show lisp gpe tunnel",
+ .function = show_lisp_gpe_tunnel_command_fn,
};
+/* *INDENT-ON* */
u8
-vnet_lisp_gpe_enable_disable_status(void)
+vnet_lisp_gpe_enable_disable_status (void)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
return lgm->is_en;
}
@@ -792,94 +796,106 @@ vnet_lisp_gpe_enable_disable_status(void)
clib_error_t *
vnet_lisp_gpe_enable_disable (vnet_lisp_gpe_enable_disable_args_t * a)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
- vnet_main_t * vnm = lgm->vnet_main;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
+ vnet_main_t *vnm = lgm->vnet_main;
if (a->is_en)
{
/* add lgpe_ip4_lookup as possible next_node for ip4 lookup */
if (lgm->ip4_lookup_next_lgpe_ip4_lookup == ~0)
- {
- lgm->ip4_lookup_next_lgpe_ip4_lookup = vlib_node_add_next (
- vnm->vlib_main, ip4_lookup_node.index,
- lgpe_ip4_lookup_node.index);
- }
+ {
+ lgm->ip4_lookup_next_lgpe_ip4_lookup =
+ vlib_node_add_next (vnm->vlib_main, ip4_lookup_node.index,
+ lgpe_ip4_lookup_node.index);
+ }
/* add lgpe_ip6_lookup as possible next_node for ip6 lookup */
if (lgm->ip6_lookup_next_lgpe_ip6_lookup == ~0)
- {
- lgm->ip6_lookup_next_lgpe_ip6_lookup = vlib_node_add_next (
- vnm->vlib_main, ip6_lookup_node.index,
- lgpe_ip6_lookup_node.index);
- }
+ {
+ lgm->ip6_lookup_next_lgpe_ip6_lookup =
+ vlib_node_add_next (vnm->vlib_main, ip6_lookup_node.index,
+ lgpe_ip6_lookup_node.index);
+ }
else
- {
- /* ask cp to re-add ifaces and defaults */
- }
+ {
+ /* ask cp to re-add ifaces and defaults */
+ }
lgm->is_en = 1;
}
else
{
- CLIB_UNUSED(uword * val);
- hash_pair_t * p;
- u32 * dp_tables = 0, * dp_table;
- lisp_gpe_tunnel_key_t * tunnels = 0, * tunnel;
- vnet_lisp_gpe_add_del_fwd_entry_args_t _at, * at = &_at;
- vnet_lisp_gpe_add_del_iface_args_t _ai, * ai= &_ai;
+ CLIB_UNUSED (uword * val);
+ hash_pair_t *p;
+ u32 *dp_tables = 0, *dp_table;
+ lisp_gpe_tunnel_key_t *tunnels = 0, *tunnel;
+ vnet_lisp_gpe_add_del_fwd_entry_args_t _at, *at = &_at;
+ vnet_lisp_gpe_add_del_iface_args_t _ai, *ai = &_ai;
/* remove all tunnels */
+
+ /* *INDENT-OFF* */
mhash_foreach(tunnel, val, &lgm->lisp_gpe_tunnel_by_key, ({
vec_add1(tunnels, tunnel[0]);
}));
+ /* *INDENT-ON* */
- vec_foreach(tunnel, tunnels)
+ vec_foreach (tunnel, tunnels)
{
- memset(at, 0, sizeof(at[0]));
- at->is_add = 0;
- if (tunnel->rmt.type == GID_ADDR_IP_PREFIX)
- {
- gid_address_type(&at->rmt_eid) = GID_ADDR_IP_PREFIX;
- ip_prefix_copy(&gid_address_ippref(&at->rmt_eid), &tunnel->rmt.ippref);
- }
- else
- {
- gid_address_type(&at->rmt_eid) = GID_ADDR_MAC;
- mac_copy(&gid_address_mac(&at->rmt_eid), &tunnel->rmt.mac);
- }
- vnet_lisp_gpe_add_del_fwd_entry (at, 0);
+ memset (at, 0, sizeof (at[0]));
+ at->is_add = 0;
+ if (tunnel->rmt.type == GID_ADDR_IP_PREFIX)
+ {
+ gid_address_type (&at->rmt_eid) = GID_ADDR_IP_PREFIX;
+ ip_prefix_copy (&gid_address_ippref (&at->rmt_eid),
+ &tunnel->rmt.ippref);
+ }
+ else
+ {
+ gid_address_type (&at->rmt_eid) = GID_ADDR_MAC;
+ mac_copy (&gid_address_mac (&at->rmt_eid), &tunnel->rmt.mac);
+ }
+ vnet_lisp_gpe_add_del_fwd_entry (at, 0);
}
- vec_free(tunnels);
+ vec_free (tunnels);
/* disable all l3 ifaces */
+
+ /* *INDENT-OFF* */
hash_foreach_pair(p, lgm->l3_ifaces.hw_if_index_by_dp_table, ({
vec_add1(dp_tables, p->key);
}));
+ /* *INDENT-ON* */
- vec_foreach(dp_table, dp_tables) {
- ai->is_add = 0;
- ai->table_id = dp_table[0];
- ai->is_l2 = 0;
+ vec_foreach (dp_table, dp_tables)
+ {
+ ai->is_add = 0;
+ ai->table_id = dp_table[0];
+ ai->is_l2 = 0;
- /* disables interface and removes defaults */
- vnet_lisp_gpe_add_del_iface(ai, 0);
+ /* disables interface and removes defaults */
+ vnet_lisp_gpe_add_del_iface (ai, 0);
}
/* disable all l2 ifaces */
- _vec_len(dp_tables) = 0;
+ _vec_len (dp_tables) = 0;
+
+ /* *INDENT-OFF* */
hash_foreach_pair(p, lgm->l2_ifaces.hw_if_index_by_dp_table, ({
vec_add1(dp_tables, p->key);
}));
+ /* *INDENT-ON* */
- vec_foreach(dp_table, dp_tables) {
- ai->is_add = 0;
- ai->bd_id = dp_table[0];
- ai->is_l2 = 1;
+ vec_foreach (dp_table, dp_tables)
+ {
+ ai->is_add = 0;
+ ai->bd_id = dp_table[0];
+ ai->is_l2 = 1;
- /* disables interface and removes defaults */
- vnet_lisp_gpe_add_del_iface(ai, 0);
+ /* disables interface and removes defaults */
+ vnet_lisp_gpe_add_del_iface (ai, 0);
}
- vec_free(dp_tables);
+ vec_free (dp_tables);
lgm->is_en = 0;
}
@@ -887,81 +903,90 @@ vnet_lisp_gpe_enable_disable (vnet_lisp_gpe_enable_disable_args_t * a)
}
static clib_error_t *
-lisp_gpe_enable_disable_command_fn (vlib_main_t * vm, unformat_input_t * input,
- vlib_cli_command_t * cmd)
+lisp_gpe_enable_disable_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
- unformat_input_t _line_input, * line_input = &_line_input;
+ unformat_input_t _line_input, *line_input = &_line_input;
u8 is_en = 1;
- vnet_lisp_gpe_enable_disable_args_t _a, * a = &_a;
+ vnet_lisp_gpe_enable_disable_args_t _a, *a = &_a;
/* Get a line of input. */
- if (! unformat_user (input, unformat_line_input, line_input))
+ if (!unformat_user (input, unformat_line_input, line_input))
return 0;
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (line_input, "enable"))
- is_en = 1;
+ is_en = 1;
else if (unformat (line_input, "disable"))
- is_en = 0;
+ is_en = 0;
else
- {
- return clib_error_return (0, "parse error: '%U'",
- format_unformat_error, line_input);
- }
+ {
+ return clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+ }
}
a->is_en = is_en;
return vnet_lisp_gpe_enable_disable (a);
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (enable_disable_lisp_gpe_command, static) = {
.path = "lisp gpe",
.short_help = "lisp gpe [enable|disable]",
.function = lisp_gpe_enable_disable_command_fn,
};
+/* *INDENT-ON* */
static clib_error_t *
lisp_show_iface_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
- hash_pair_t * p;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
+ hash_pair_t *p;
vlib_cli_output (vm, "%=10s%=12s", "vrf", "hw_if_index");
+
+ /* *INDENT-OFF* */
hash_foreach_pair (p, lgm->l3_ifaces.hw_if_index_by_dp_table, ({
vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
}));
+ /* *INDENT-ON* */
if (0 != lgm->l2_ifaces.hw_if_index_by_dp_table)
{
vlib_cli_output (vm, "%=10s%=12s", "bd_id", "hw_if_index");
+ /* *INDENT-OFF* */
hash_foreach_pair (p, lgm->l2_ifaces.hw_if_index_by_dp_table, ({
vlib_cli_output (vm, "%=10d%=10d", p->key, p->value[0]);
}));
+ /* *INDENT-ON* */
}
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (lisp_show_iface_command) = {
.path = "show lisp gpe interface",
.short_help = "show lisp gpe interface",
.function = lisp_show_iface_command_fn,
};
-
+/* *INDENT-ON* */
u8 *
format_vnet_lisp_gpe_status (u8 * s, va_list * args)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
return format (s, "%s", lgm->is_en ? "enabled" : "disabled");
}
clib_error_t *
-lisp_gpe_init (vlib_main_t *vm)
+lisp_gpe_init (vlib_main_t * vm)
{
- lisp_gpe_main_t * lgm = &lisp_gpe_main;
- clib_error_t * error = 0;
+ lisp_gpe_main_t *lgm = &lisp_gpe_main;
+ clib_error_t *error = 0;
if ((error = vlib_call_init_function (vm, ip_main_init)))
return error;
@@ -969,7 +994,7 @@ lisp_gpe_init (vlib_main_t *vm)
if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
return error;
- lgm->vnet_main = vnet_get_main();
+ lgm->vnet_main = vnet_get_main ();
lgm->vlib_main = vm;
lgm->im4 = &ip4_main;
lgm->im6 = &ip6_main;
@@ -978,16 +1003,24 @@ lisp_gpe_init (vlib_main_t *vm)
lgm->ip4_lookup_next_lgpe_ip4_lookup = ~0;
lgm->ip6_lookup_next_lgpe_ip6_lookup = ~0;
- mhash_init (&lgm->lisp_gpe_tunnel_by_key, sizeof(uword),
- sizeof(lisp_gpe_tunnel_key_t));
+ mhash_init (&lgm->lisp_gpe_tunnel_by_key, sizeof (uword),
+ sizeof (lisp_gpe_tunnel_key_t));
l2_fib_init (lgm);
- udp_register_dst_port (vm, UDP_DST_PORT_lisp_gpe,
- lisp_gpe_ip4_input_node.index, 1 /* is_ip4 */);
+ udp_register_dst_port (vm, UDP_DST_PORT_lisp_gpe,
+ lisp_gpe_ip4_input_node.index, 1 /* is_ip4 */ );
udp_register_dst_port (vm, UDP_DST_PORT_lisp_gpe6,
- lisp_gpe_ip6_input_node.index, 0 /* is_ip4 */);
+ lisp_gpe_ip6_input_node.index, 0 /* is_ip4 */ );
return 0;
}
-VLIB_INIT_FUNCTION(lisp_gpe_init);
+VLIB_INIT_FUNCTION (lisp_gpe_init);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe.h b/vnet/vnet/lisp-gpe/lisp_gpe.h
index 145b5d493e5..28acab651c4 100644
--- a/vnet/vnet/lisp-gpe/lisp_gpe.h
+++ b/vnet/vnet/lisp-gpe/lisp_gpe.h
@@ -28,17 +28,21 @@
#include <vnet/lisp-gpe/lisp_gpe_packet.h>
/* encap headers */
+/* *INDENT-OFF* */
typedef CLIB_PACKED (struct {
ip4_header_t ip4; /* 20 bytes */
udp_header_t udp; /* 8 bytes */
lisp_gpe_header_t lisp; /* 8 bytes */
}) ip4_udp_lisp_gpe_header_t;
+/* *INDENT-ON* */
+/* *INDENT-OFF* */
typedef CLIB_PACKED (struct {
ip6_header_t ip6; /* 40 bytes */
udp_header_t udp; /* 8 bytes */
lisp_gpe_header_t lisp; /* 8 bytes */
}) ip6_udp_lisp_gpe_header_t;
+/* *INDENT-ON* */
typedef struct
{
@@ -57,7 +61,7 @@ typedef struct
typedef struct lisp_gpe_sub_tunnel
{
/* Rewrite string. $$$$ embed vnet_rewrite header */
- u8 * rewrite;
+ u8 *rewrite;
u32 parent_index;
u32 locator_pair_index;
u8 weight;
@@ -73,20 +77,20 @@ typedef struct nomalized_sub_tunnel
typedef struct
{
/* tunnel src and dst addresses */
- locator_pair_t * locator_pairs;
+ locator_pair_t *locator_pairs;
/* locator-pairs with best priority become sub-tunnels */
- lisp_gpe_sub_tunnel_t * sub_tunnels;
+ lisp_gpe_sub_tunnel_t *sub_tunnels;
/* sub-tunnels load balancing vector: contains list of sub-tunnel
* indexes replicated according to weight */
- u32 * sub_tunnels_lbv;
+ u32 *sub_tunnels_lbv;
/* number of entries in load balancing vector */
u32 sub_tunnels_lbv_count;
/* normalized sub tunnel weights */
- normalized_sub_tunnel_weights_t * norm_sub_tunnel_weights;
+ normalized_sub_tunnel_weights_t *norm_sub_tunnel_weights;
/* decap next index */
u32 decap_next_index;
@@ -95,8 +99,8 @@ typedef struct
ip_address_t src, dst;
/* FIB indices */
- u32 encap_fib_index; /* tunnel partner lookup here */
- u32 decap_fib_index; /* inner IP lookup here */
+ u32 encap_fib_index; /* tunnel partner lookup here */
+ u32 decap_fib_index; /* inner IP lookup here */
/* vnet intfc hw/sw_if_index */
u32 hw_if_index;
@@ -119,14 +123,16 @@ _(IP4_INPUT, "ip4-input") \
_(IP6_INPUT, "ip6-input") \
_(L2_INPUT, "l2-input")
-typedef enum {
+typedef enum
+{
#define _(s,n) LISP_GPE_INPUT_NEXT_##s,
foreach_lisp_gpe_ip_input_next
#undef _
- LISP_GPE_INPUT_N_NEXT,
+ LISP_GPE_INPUT_N_NEXT,
} lisp_gpe_input_next_t;
-typedef enum {
+typedef enum
+{
#define lisp_gpe_error(n,s) LISP_GPE_ERROR_##n,
#include <vnet/lisp-gpe/lisp_gpe_error.def>
#undef lisp_gpe_error
@@ -140,11 +146,11 @@ typedef ip4_fib_t ip4_src_fib_t;
typedef struct ip6_src_fib
{
- BVT(clib_bihash) ip6_lookup_table;
+ BVT (clib_bihash) ip6_lookup_table;
/* bitmap/vector of mask widths to search */
- uword * non_empty_dst_address_length_bitmap;
- u8 * prefix_lengths_in_search_order;
+ uword *non_empty_dst_address_length_bitmap;
+ u8 *prefix_lengths_in_search_order;
ip6_address_t fib_masks[129];
i32 dst_address_length_refcounts[129];
@@ -156,23 +162,23 @@ typedef struct ip6_src_fib
typedef struct tunnel_lookup
{
/* Lookup lisp-gpe interfaces by dp table (eg. vrf/bridge index) */
- uword * hw_if_index_by_dp_table;
+ uword *hw_if_index_by_dp_table;
/* lookup decap tunnel termination sw_if_index by vni and vice versa */
- uword * sw_if_index_by_vni;
- uword * vni_by_sw_if_index;
+ uword *sw_if_index_by_vni;
+ uword *vni_by_sw_if_index;
} tunnel_lookup_t;
typedef struct lisp_gpe_main
{
/* pool of encap tunnel instances */
- lisp_gpe_tunnel_t * tunnels;
+ lisp_gpe_tunnel_t *tunnels;
/* lookup tunnel by key */
mhash_t lisp_gpe_tunnel_by_key;
/* Free vlib hw_if_indices */
- u32 * free_tunnel_hw_if_indices;
+ u32 *free_tunnel_hw_if_indices;
u8 is_en;
@@ -180,14 +186,14 @@ typedef struct lisp_gpe_main
* ================== */
/* Pool of src fibs that are paired with dst fibs */
- ip4_src_fib_t * ip4_src_fibs;
- ip6_src_fib_t * ip6_src_fibs;
+ ip4_src_fib_t *ip4_src_fibs;
+ ip6_src_fib_t *ip6_src_fibs;
tunnel_lookup_t l3_ifaces;
/* Lookup lgpe_ipX_lookup_next by vrf */
- uword * lgpe_ip4_lookup_next_index_by_table_id;
- uword * lgpe_ip6_lookup_next_index_by_table_id;
+ uword *lgpe_ip4_lookup_next_index_by_table_id;
+ uword *lgpe_ip6_lookup_next_index_by_table_id;
/* next node indexes that point ip4/6 lookup to lisp gpe ip lookup */
u32 ip4_lookup_next_lgpe_ip4_lookup;
@@ -197,23 +203,24 @@ typedef struct lisp_gpe_main
* ================== */
/* l2 lisp fib */
- BVT(clib_bihash) l2_fib;
+ BVT (clib_bihash) l2_fib;
tunnel_lookup_t l2_ifaces;
/* convenience */
- vlib_main_t * vlib_main;
- vnet_main_t * vnet_main;
- ip4_main_t * im4;
- ip6_main_t * im6;
- ip_lookup_main_t * lm4;
- ip_lookup_main_t * lm6;
+ vlib_main_t *vlib_main;
+ vnet_main_t *vnet_main;
+ ip4_main_t *im4;
+ ip6_main_t *im6;
+ ip_lookup_main_t *lm4;
+ ip_lookup_main_t *lm6;
} lisp_gpe_main_t;
lisp_gpe_main_t lisp_gpe_main;
always_inline lisp_gpe_main_t *
-vnet_lisp_gpe_get_main() {
+vnet_lisp_gpe_get_main ()
+{
return &lisp_gpe_main;
}
@@ -222,8 +229,7 @@ extern vlib_node_registration_t lgpe_ip6_lookup_node;
extern vlib_node_registration_t lisp_gpe_ip4_input_node;
extern vlib_node_registration_t lisp_gpe_ip6_input_node;
-u8 *
-format_lisp_gpe_header_with_length (u8 * s, va_list * args);
+u8 *format_lisp_gpe_header_with_length (u8 * s, va_list * args);
typedef struct
{
@@ -240,13 +246,12 @@ typedef struct
u32 dp_table;
};
u8 is_l2;
- u32 vni; /* host byte order */
+ u32 vni; /* host byte order */
} vnet_lisp_gpe_add_del_iface_args_t;
-u8
-vnet_lisp_gpe_enable_disable_status(void);
+u8 vnet_lisp_gpe_enable_disable_status (void);
int
-vnet_lisp_gpe_add_del_iface (vnet_lisp_gpe_add_del_iface_args_t *a,
+vnet_lisp_gpe_add_del_iface (vnet_lisp_gpe_add_del_iface_args_t * a,
u32 * hw_if_indexp);
typedef struct
@@ -254,8 +259,8 @@ typedef struct
u8 is_en;
} vnet_lisp_gpe_enable_disable_args_t;
-clib_error_t *
-vnet_lisp_gpe_enable_disable (vnet_lisp_gpe_enable_disable_args_t *a);
+clib_error_t
+ * vnet_lisp_gpe_enable_disable (vnet_lisp_gpe_enable_disable_args_t * a);
typedef struct
{
@@ -270,13 +275,13 @@ typedef struct
gid_address_t rmt_eid;
/* vector of locator pairs */
- locator_pair_t * locator_pairs;
+ locator_pair_t *locator_pairs;
/* FIB indices to lookup remote locator at encap and inner IP at decap */
u32 encap_fib_index;
u32 decap_fib_index;
- u32 decap_next_index; /* TODO is this really needed? */
+ u32 decap_next_index; /* TODO is this really needed? */
/* VNI/tenant id in HOST byte order */
u32 vni;
@@ -293,16 +298,16 @@ typedef struct
} vnet_lisp_gpe_add_del_fwd_entry_args_t;
int
-vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t *a,
+vnet_lisp_gpe_add_del_fwd_entry (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
u32 * hw_if_indexp);
int
ip_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id,
- ip_adjacency_t * add_adj, u8 is_add);
+ ip_prefix_t * src_prefix, u32 table_id,
+ ip_adjacency_t * add_adj, u8 is_add);
u32
ip_sd_fib_get_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
- ip_prefix_t * src_prefix, u32 table_id);
+ ip_prefix_t * src_prefix, u32 table_id);
#define foreach_lgpe_ip4_lookup_next \
_(DROP, "error-drop") \
@@ -313,7 +318,7 @@ typedef enum lgpe_ip4_lookup_next
#define _(sym,str) LGPE_IP4_LOOKUP_NEXT_##sym,
foreach_lgpe_ip4_lookup_next
#undef _
- LGPE_IP4_LOOKUP_N_NEXT,
+ LGPE_IP4_LOOKUP_N_NEXT,
} lgpe_ip4_lookup_next_t;
#define foreach_lgpe_ip6_lookup_next \
@@ -325,16 +330,24 @@ typedef enum lgpe_ip6_lookup_next
#define _(sym,str) LGPE_IP6_LOOKUP_NEXT_##sym,
foreach_lgpe_ip6_lookup_next
#undef _
- LGPE_IP6_LOOKUP_N_NEXT,
+ LGPE_IP6_LOOKUP_N_NEXT,
} lgpe_ip6_lookup_next_t;
-u8 * format_vnet_lisp_gpe_status (u8 * s, va_list * args);
+u8 *format_vnet_lisp_gpe_status (u8 * s, va_list * args);
#define L2_FIB_DEFAULT_HASH_NUM_BUCKETS (64 * 1024)
#define L2_FIB_DEFAULT_HASH_MEMORY_SIZE (32<<20)
u32
lisp_l2_fib_lookup (lisp_gpe_main_t * lgm, u16 bd_index, u8 src_mac[8],
- u8 dst_mac[8]);
+ u8 dst_mac[8]);
#endif /* included_vnet_lisp_gpe_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe_packet.h b/vnet/vnet/lisp-gpe/lisp_gpe_packet.h
index 360157b700c..352cc5d3b0e 100644
--- a/vnet/vnet/lisp-gpe/lisp_gpe_packet.h
+++ b/vnet/vnet/lisp-gpe/lisp_gpe_packet.h
@@ -90,8 +90,9 @@
* 0x3 : Ethernet
* 0x4: Network Service Header
*/
-
-typedef struct {
+
+typedef struct
+{
u8 flags;
u8 ver_res;
u8 res;
@@ -108,9 +109,10 @@ _(I, 0x08) \
_(P, 0x04) \
_(O, 0x01)
-typedef enum {
+typedef enum
+{
#define _(n,v) LISP_GPE_FLAGS_##n = v,
-foreach_lisp_gpe_flag_bit
+ foreach_lisp_gpe_flag_bit
#undef _
} vnet_lisp_gpe_flag_bit_t;
@@ -131,3 +133,11 @@ typedef enum
} lisp_gpe_next_protocol_e;
#endif /* included_lisp_gpe_packet_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */