aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/gre/gre.c27
-rw-r--r--src/vnet/gre/interface.c8
-rw-r--r--src/vnet/vxlan/encap.c44
-rw-r--r--src/vnet/vxlan/vxlan.c11
4 files changed, 53 insertions, 37 deletions
diff --git a/src/vnet/gre/gre.c b/src/vnet/gre/gre.c
index a3702920334..75b11017e50 100644
--- a/src/vnet/gre/gre.c
+++ b/src/vnet/gre/gre.c
@@ -383,19 +383,22 @@ gre_interface_tx (vlib_main_t * vm,
adj_index0 = gt0->l2_adj_index;
}
- if (sw_if_index0 == vnet_buffer (b1)->sw_if_index[VLIB_TX])
+ if (sw_if_index1 != vnet_buffer (b1)->sw_if_index[VLIB_TX])
{
- sw_if_index1 = sw_if_index0;
- gt1 = gt0;
- adj_index1 = adj_index0;
- }
- else if (sw_if_index1 != vnet_buffer (b1)->sw_if_index[VLIB_TX])
- {
- sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_TX];
- vnet_hw_interface_t *hi1 =
- vnet_get_sup_hw_interface (vnm, sw_if_index1);
- gt1 = &gm->tunnels[hi1->dev_instance];
- adj_index1 = gt1->l2_adj_index;
+ if (sw_if_index0 == vnet_buffer (b1)->sw_if_index[VLIB_TX])
+ {
+ sw_if_index1 = sw_if_index0;
+ gt1 = gt0;
+ adj_index1 = adj_index0;
+ }
+ else
+ {
+ sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_TX];
+ vnet_hw_interface_t *hi1 =
+ vnet_get_sup_hw_interface (vnm, sw_if_index1);
+ gt1 = &gm->tunnels[hi1->dev_instance];
+ adj_index1 = gt1->l2_adj_index;
+ }
}
vnet_buffer (b0)->ip.adj_index[VLIB_TX] = adj_index0;
diff --git a/src/vnet/gre/interface.c b/src/vnet/gre/interface.c
index 97c4f1643d9..5b165c858d3 100644
--- a/src/vnet/gre/interface.c
+++ b/src/vnet/gre/interface.c
@@ -309,9 +309,11 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
else
{
/* Default MAC address (d00b:eed0:0000 + sw_if_index) */
- u8 address[6] = { 0xd0, 0x0b, 0xee, 0xd0, (u8) t_idx >> 8, (u8) t_idx };
- error = ethernet_register_interface (vnm, gre_device_class.index, t_idx,
- address, &hw_if_index, 0);
+ u8 address[6] =
+ { 0xd0, 0x0b, 0xee, 0xd0, (u8) (t_idx >> 8), (u8) t_idx };
+ error =
+ ethernet_register_interface (vnm, gre_device_class.index, t_idx,
+ address, &hw_if_index, 0);
if (error)
{
clib_error_report (error);
diff --git a/src/vnet/vxlan/encap.c b/src/vnet/vxlan/encap.c
index 062e338d960..c5522bc81b2 100644
--- a/src/vnet/vxlan/encap.c
+++ b/src/vnet/vxlan/encap.c
@@ -69,14 +69,15 @@ vxlan_encap_inline (vlib_main_t * vm,
vxlan_main_t * vxm = &vxlan_main;
vnet_main_t * vnm = vxm->vnet_main;
vnet_interface_main_t * im = &vnm->interface_main;
- vlib_combined_counter_main_t * tx_counter = im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX;
+ vlib_combined_counter_main_t * tx_counter =
+ im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX;
u32 pkts_encapsulated = 0;
u32 thread_index = vlib_get_thread_index();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
u32 sw_if_index0 = 0, sw_if_index1 = 0;
u32 next0 = 0, next1 = 0;
- vnet_hw_interface_t * hi0, * hi1;
vxlan_tunnel_t * t0 = NULL, * t1 = NULL;
+ index_t dpoi_idx0 = INDEX_INVALID, dpoi_idx1 = INDEX_INVALID;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -138,23 +139,38 @@ vxlan_encap_inline (vlib_main_t * vm,
if (sw_if_index0 != vnet_buffer(b0)->sw_if_index[VLIB_TX])
{
sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_TX];
- hi0 = vnet_get_sup_hw_interface (vnm, sw_if_index0);
+ vnet_hw_interface_t *hi0 =
+ vnet_get_sup_hw_interface (vnm, sw_if_index0);
t0 = &vxm->tunnels[hi0->dev_instance];
- /* Note: change to always set next0 if it may be set to drop */
+ /* Note: change to always set next0 if it may set to drop */
next0 = t0->next_dpo.dpoi_next_node;
+ dpoi_idx0 = t0->next_dpo.dpoi_index;
}
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = t0->next_dpo.dpoi_index;
/* Get next node index and adj index from tunnel next_dpo */
if (sw_if_index1 != vnet_buffer(b1)->sw_if_index[VLIB_TX])
{
- sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_TX];
- hi1 = vnet_get_sup_hw_interface (vnm, sw_if_index1);
- t1 = &vxm->tunnels[hi1->dev_instance];
- /* Note: change to always set next1 if it may be set to drop */
- next1 = t1->next_dpo.dpoi_next_node;
+ if (sw_if_index0 == vnet_buffer(b1)->sw_if_index[VLIB_TX])
+ {
+ sw_if_index1 = sw_if_index0;
+ t1 = t0;
+ next1 = next0;
+ dpoi_idx1 = dpoi_idx0;
+ }
+ else
+ {
+ sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_TX];
+ vnet_hw_interface_t *hi1 =
+ vnet_get_sup_hw_interface (vnm, sw_if_index1);
+ t1 = &vxm->tunnels[hi1->dev_instance];
+ /* Note: change to always set next1 if it may set to drop */
+ next1 = t1->next_dpo.dpoi_next_node;
+ dpoi_idx1 = t1->next_dpo.dpoi_index;
+ }
}
- vnet_buffer(b1)->ip.adj_index[VLIB_TX] = t1->next_dpo.dpoi_index;
+
+ vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpoi_idx0;
+ vnet_buffer(b1)->ip.adj_index[VLIB_TX] = dpoi_idx1;
ASSERT(vec_len(t0->rewrite) == underlay_hdr_len);
ASSERT(vec_len(t1->rewrite) == underlay_hdr_len);
@@ -321,12 +337,14 @@ vxlan_encap_inline (vlib_main_t * vm,
if (sw_if_index0 != vnet_buffer(b0)->sw_if_index[VLIB_TX])
{
sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_TX];
- hi0 = vnet_get_sup_hw_interface (vnm, sw_if_index0);
+ vnet_hw_interface_t *hi0 =
+ vnet_get_sup_hw_interface (vnm, sw_if_index0);
t0 = &vxm->tunnels[hi0->dev_instance];
/* Note: change to always set next0 if it may be set to drop */
next0 = t0->next_dpo.dpoi_next_node;
+ dpoi_idx0 = t0->next_dpo.dpoi_index;
}
- vnet_buffer(b0)->ip.adj_index[VLIB_TX] = t0->next_dpo.dpoi_index;
+ vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpoi_idx0;
ASSERT(vec_len(t0->rewrite) == underlay_hdr_len);
vlib_buffer_advance (b0, -underlay_hdr_len);
diff --git a/src/vnet/vxlan/vxlan.c b/src/vnet/vxlan/vxlan.c
index b34c00d738c..2aec321c8e2 100644
--- a/src/vnet/vxlan/vxlan.c
+++ b/src/vnet/vxlan/vxlan.c
@@ -54,17 +54,10 @@ static u8 * format_decap_next (u8 * s, va_list * args)
u8 * format_vxlan_tunnel (u8 * s, va_list * args)
{
vxlan_tunnel_t * t = va_arg (*args, vxlan_tunnel_t *);
- vxlan_main_t * ngm = &vxlan_main;
- u32 dev_instance;
- u32 user_instance;
-
- dev_instance = t - ngm->tunnels;
- user_instance = t->user_instance;
s = format (s,
"[%d] instance %d src %U dst %U vni %d fib-idx %d sw-if-idx %d ",
- dev_instance,
- user_instance,
+ t->dev_instance, t->user_instance,
format_ip46_address, &t->src, IP46_TYPE_ANY,
format_ip46_address, &t->dst, IP46_TYPE_ANY,
t->vni, t->encap_fib_index, t->sw_if_index);
@@ -563,7 +556,7 @@ int vnet_vxlan_add_del_tunnel
}
vnet_delete_hw_interface (vnm, t->hw_if_index);
- hash_unset (vxlan_main.instance_used, instance);
+ hash_unset (vxm->instance_used, instance);
fib_node_deinit(&t->node);
vec_free (t->rewrite);