t->tunnel_index, t->vni, t->next_index, t->error);
}
-always_inline u32
-buf_fib_index (vlib_buffer_t * b, u32 is_ip4)
-{
- u32 sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_TX];
- if (sw_if_index != (u32) ~ 0)
- return sw_if_index;
-
- u32 *fib_index_by_sw_if_index = is_ip4 ?
- ip4_main.fib_index_by_sw_if_index : ip6_main.fib_index_by_sw_if_index;
- sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
-
- return vec_elt (fib_index_by_sw_if_index, sw_if_index);
-}
-
typedef vxlan4_tunnel_key_t last_tunnel_cache4;
static const vxlan_decap_info_t decap_not_found = {
};
if (PREDICT_TRUE
- (key4.key[0] == cache->key[0] || key4.key[1] == cache->key[1]))
+ (key4.key[0] == cache->key[0] && key4.key[1] == cache->key[1]))
{
/* cache hit */
vxlan_decap_info_t di = {.as_u64 = cache->value };
u32 thread_index = vlib_get_thread_index ();
if (is_ip4)
- memset (&last4, 0xff, sizeof last4);
+ clib_memset (&last4, 0xff, sizeof last4);
else
- memset (&last6, 0xff, sizeof last6);
+ clib_memset (&last6, 0xff, sizeof last6);
u32 *from = vlib_frame_vector_args (from_frame);
u32 n_left_from = from_frame->n_vectors;
vlib_buffer_advance (b[0], sizeof *vxlan0);
vlib_buffer_advance (b[1], sizeof *vxlan1);
- u32 fi0 = buf_fib_index (b[0], is_ip4);
- u32 fi1 = buf_fib_index (b[1], is_ip4);
+ u32 fi0 = vlib_buffer_get_ip_fib_index (b[0], is_ip4);
+ u32 fi1 = vlib_buffer_get_ip_fib_index (b[1], is_ip4);
vxlan_decap_info_t di0 = is_ip4 ?
vxlan4_find_tunnel (vxm, &last4, fi0, ip4_0, vxlan0, &stats_if0) :
/* pop (ip, udp, vxlan) */
vlib_buffer_advance (b[0], sizeof (*vxlan0));
- u32 fi0 = buf_fib_index (b[0], is_ip4);
+ u32 fi0 = vlib_buffer_get_ip_fib_index (b[0], is_ip4);
vxlan_decap_info_t di0 = is_ip4 ?
vxlan4_find_tunnel (vxm, &last4, fi0, ip4_0, vxlan0, &stats_if0) :
IP_VXLAN_BYPASS_NEXT_DROP,
IP_VXLAN_BYPASS_NEXT_VXLAN,
IP_VXLAN_BYPASS_N_NEXT,
-} ip_vxan_bypass_next_t;
+} ip_vxlan_bypass_next_t;
always_inline uword
ip_vxlan_bypass_inline (vlib_main_t * vm,
u32 *from, *to_next, n_left_from, n_left_to_next, next_index;
vlib_node_runtime_t *error_node =
vlib_node_get_runtime (vm, ip4_input_node.index);
- ip4_address_t addr4; /* last IPv4 address matching a local VTEP address */
- ip6_address_t addr6; /* last IPv6 address matching a local VTEP address */
+ vtep4_key_t last_vtep4; /* last IPv4 address / fib index
+ matching a local VTEP address */
+ vtep6_key_t last_vtep6; /* last IPv6 address / fib index
+ matching a local VTEP address */
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
ip4_forward_next_trace (vm, node, frame, VLIB_TX);
if (is_ip4)
- addr4.data_u32 = ~0;
+ vtep4_key_init (&last_vtep4);
else
- ip6_address_set_zero (&addr6);
+ vtep6_key_init (&last_vtep6);
while (n_left_from > 0)
{
/* Validate DIP against VTEPs */
if (is_ip4)
{
- if (addr4.as_u32 != ip40->dst_address.as_u32)
- {
- if (!hash_get (vxm->vtep4, ip40->dst_address.as_u32))
- goto exit0; /* no local VTEP for VXLAN packet */
- addr4 = ip40->dst_address;
- }
+ if (!vtep4_check (&vxm->vtep_table, b0, ip40, &last_vtep4))
+ goto exit0; /* no local VTEP for VXLAN packet */
}
else
{
- if (!ip6_address_is_equal (&addr6, &ip60->dst_address))
- {
- if (!hash_get_mem (vxm->vtep6, &ip60->dst_address))
- goto exit0; /* no local VTEP for VXLAN packet */
- addr6 = ip60->dst_address;
- }
+ if (!vtep6_check (&vxm->vtep_table, b0, ip60, &last_vtep6))
+ goto exit0; /* no local VTEP for VXLAN packet */
}
flags0 = b0->flags;
/* Validate DIP against VTEPs */
if (is_ip4)
{
- if (addr4.as_u32 != ip41->dst_address.as_u32)
- {
- if (!hash_get (vxm->vtep4, ip41->dst_address.as_u32))
- goto exit1; /* no local VTEP for VXLAN packet */
- addr4 = ip41->dst_address;
- }
+ if (!vtep4_check (&vxm->vtep_table, b1, ip41, &last_vtep4))
+ goto exit1; /* no local VTEP for VXLAN packet */
}
else
{
- if (!ip6_address_is_equal (&addr6, &ip61->dst_address))
- {
- if (!hash_get_mem (vxm->vtep6, &ip61->dst_address))
- goto exit1; /* no local VTEP for VXLAN packet */
- addr6 = ip61->dst_address;
- }
+ if (!vtep6_check (&vxm->vtep_table, b1, ip61, &last_vtep6))
+ goto exit1; /* no local VTEP for VXLAN packet */
}
flags1 = b1->flags;
/* Validate DIP against VTEPs */
if (is_ip4)
{
- if (addr4.as_u32 != ip40->dst_address.as_u32)
- {
- if (!hash_get (vxm->vtep4, ip40->dst_address.as_u32))
- goto exit; /* no local VTEP for VXLAN packet */
- addr4 = ip40->dst_address;
- }
+ if (!vtep4_check (&vxm->vtep_table, b0, ip40, &last_vtep4))
+ goto exit; /* no local VTEP for VXLAN packet */
}
else
{
- if (!ip6_address_is_equal (&addr6, &ip60->dst_address))
- {
- if (!hash_get_mem (vxm->vtep6, &ip60->dst_address))
- goto exit; /* no local VTEP for VXLAN packet */
- addr6 = ip60->dst_address;
- }
+ if (!vtep6_check (&vxm->vtep_table, b0, ip60, &last_vtep6))
+ goto exit; /* no local VTEP for VXLAN packet */
}
flags0 = b0->flags;