return format (s, "gtpu_tunnel%d", dev_instance);
}
-static uword
-dummy_interface_tx (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
-{
- clib_warning ("you shouldn't be here, leaking buffers...");
- return frame->n_vectors;
-}
-
static clib_error_t *
gtpu_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
{
.name = "GTPU",
.format_device_name = format_gtpu_name,
.format_tx_trace = format_gtpu_encap_trace,
- .tx_function = dummy_interface_tx,
.admin_up_down_function = gtpu_interface_admin_up_down,
};
/* *INDENT-ON* */
hi = vnet_get_hw_interface (vnm, hw_if_index);
}
+ /* Set gtpu tunnel output node */
+ u32 encap_index = !is_ip6 ?
+ gtpu4_encap_node.index : gtpu6_encap_node.index;
+ vnet_set_interface_output_node (vnm, hw_if_index, encap_index);
+
t->hw_if_index = hw_if_index;
t->sw_if_index = sw_if_index = hi->sw_if_index;
fib_node_init (&t->node, gtm->fib_node_type);
fib_prefix_t tun_dst_pfx;
- u32 encap_index = !is_ip6 ?
- gtpu4_encap_node.index : gtpu6_encap_node.index;
vnet_flood_class_t flood_class = VNET_FLOOD_CLASS_TUNNEL_NORMAL;
fib_prefix_from_ip46_addr (&t->dst, &tun_dst_pfx);
flood_class = VNET_FLOOD_CLASS_TUNNEL_MASTER;
}
- /* Set gtpu tunnel output node */
- hi->output_node_index = encap_index;
-
vnet_get_sw_interface (vnet_get_main (), sw_if_index)->flood_class =
flood_class;
}
return format (s, "geneve_tunnel%d", dev_instance);
}
-static uword
-dummy_interface_tx (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
-{
- clib_warning ("you shouldn't be here, leaking buffers...");
- return frame->n_vectors;
-}
-
static clib_error_t *
geneve_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
{
.name = "GENEVE",
.format_device_name = format_geneve_name,
.format_tx_trace = format_geneve_encap_trace,
- .tx_function = dummy_interface_tx,
.admin_up_down_function = geneve_interface_admin_up_down,
};
/* *INDENT-ON* */
hi = vnet_get_hw_interface (vnm, hw_if_index);
}
+ /* Set geneve tunnel output node */
+ u32 encap_index = !is_ip6 ?
+ geneve4_encap_node.index : geneve6_encap_node.index;
+ vnet_set_interface_output_node (vnm, hw_if_index, encap_index);
+
t->hw_if_index = hw_if_index;
t->sw_if_index = sw_if_index = hi->sw_if_index;
fib_node_init (&t->node, FIB_NODE_TYPE_GENEVE_TUNNEL);
fib_prefix_t tun_remote_pfx;
- u32 encap_index = !is_ip6 ?
- geneve4_encap_node.index : geneve6_encap_node.index;
vnet_flood_class_t flood_class = VNET_FLOOD_CLASS_TUNNEL_NORMAL;
fib_prefix_from_ip46_addr (&t->remote, &tun_remote_pfx);
flood_class = VNET_FLOOD_CLASS_TUNNEL_MASTER;
}
- /* Set geneve tunnel output node */
- hi->output_node_index = encap_index;
-
vnet_get_sw_interface (vnet_get_main (), sw_if_index)->flood_class =
flood_class;
}
hw->max_l3_packet_bytes[VLIB_RX] = ~0;
hw->max_l3_packet_bytes[VLIB_TX] = ~0;
+ if (dev_class->tx_function == 0)
+ goto no_output_nodes; /* No output/tx nodes to create */
+
tx_node_name = (char *) format (0, "%v-tx", hw->name);
output_node_name = (char *) format (0, "%v-output", hw->name);
setup_output_node (vm, hw->output_node_index, hw_class);
setup_tx_node (vm, hw->tx_node_index, dev_class);
+no_output_nodes:
/* Call all up/down callbacks with zero flags when interface is created. */
vnet_sw_interface_set_flags_helper (vnm, hw->sw_if_index, /* flags */ 0,
VNET_INTERFACE_SET_FLAGS_HELPER_IS_CREATE);
vnet_interface_main_t *im = &vnm->interface_main;
vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
vlib_main_t *vm = vnm->vlib_main;
-
+ vnet_device_class_t *dev_class = vnet_get_device_class (vnm,
+ hw->dev_class_index);
/* If it is up, mark it down. */
if (hw->flags != 0)
vnet_hw_interface_set_flags (vnm, hw_if_index, /* flags */ 0);
/* Delete software interface corresponding to hardware interface. */
vnet_delete_sw_interface (vnm, hw->sw_if_index);
- {
- vnet_hw_interface_nodes_t *dn;
+ if (dev_class->tx_function)
+ {
+ /* Put output/tx nodes into recycle pool */
+ vnet_hw_interface_nodes_t *dn;
- /* *INDENT-OFF* */
- foreach_vlib_main ({
- vnet_interface_output_runtime_t *rt =
- vlib_node_get_runtime_data (this_vlib_main, hw->output_node_index);
-
- /* Mark node runtime as deleted so output node (if called)
- * will drop packets. */
- rt->is_deleted = 1;
- });
- /* *INDENT-ON* */
+ /* *INDENT-OFF* */
+ foreach_vlib_main
+ ({
+ vnet_interface_output_runtime_t *rt =
+ vlib_node_get_runtime_data (this_vlib_main, hw->output_node_index);
+
+ /* Mark node runtime as deleted so output node (if called)
+ * will drop packets. */
+ rt->is_deleted = 1;
+ });
+ /* *INDENT-ON* */
- vlib_node_rename (vm, hw->output_node_index,
- "interface-%d-output-deleted", hw_if_index);
- vlib_node_rename (vm, hw->tx_node_index, "interface-%d-tx-deleted",
- hw_if_index);
- vec_add2 (im->deleted_hw_interface_nodes, dn, 1);
- dn->tx_node_index = hw->tx_node_index;
- dn->output_node_index = hw->output_node_index;
- }
+ vlib_node_rename (vm, hw->output_node_index,
+ "interface-%d-output-deleted", hw_if_index);
+ vlib_node_rename (vm, hw->tx_node_index, "interface-%d-tx-deleted",
+ hw_if_index);
+ vec_add2 (im->deleted_hw_interface_nodes, dn, 1);
+ dn->tx_node_index = hw->tx_node_index;
+ dn->output_node_index = hw->output_node_index;
+ }
hash_unset_mem (im->hw_interface_by_name, hw->name);
vec_free (hw->name);
/* Software index for this hardware interface. */
u32 sw_if_index;
+ /* Next index in interface-output node for this interface
+ used by node function vnet_per_buffer_interface_output() */
+ u32 output_node_next_index;
+
/* Maximum transmit rate for this interface in bits/sec. */
f64 max_rate_bits_per_sec;
u32 dev_instance,
u32 hw_class_index, u32 hw_instance);
+/**
+ * Set interface output node - for interface registered without its output/tx
+ * nodes created because its VNET_DEVICE_CLASS did not specify any tx_function.
+ * This is typically the case for tunnel interfaces.
+ */
+void vnet_set_interface_output_node (vnet_main_t * vnm,
+ u32 hw_if_index, u32 node_index);
+
/* Creates a software interface given template. */
clib_error_t *vnet_create_sw_interface (vnet_main_t * vnm,
vnet_sw_interface_t * template,
vnet_buffer (b1)->sw_if_index
[VLIB_TX]);
- next0 = hi0->hw_if_index;
- next1 = hi1->hw_if_index;
+ next0 = hi0->output_node_next_index;
+ next1 = hi1->output_node_next_index;
vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
n_left_to_next, bi0, bi1, next0,
vnet_buffer (b0)->sw_if_index
[VLIB_TX]);
- next0 = hi0->hw_if_index;
+ next0 = hi0->output_node_next_index;
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);
vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
u32 next_index;
- next_index = vlib_node_add_next_with_slot
- (vnm->vlib_main, vnet_per_buffer_interface_output_node.index,
- hi->output_node_index,
- /* next_index */ hw_if_index);
+ if (hi->output_node_index == 0)
+ return 0;
- ASSERT (next_index == hw_if_index);
+ next_index = vlib_node_add_next
+ (vnm->vlib_main, vnet_per_buffer_interface_output_node.index,
+ hi->output_node_index);
+ hi->output_node_next_index = next_index;
return 0;
}
VNET_HW_INTERFACE_ADD_DEL_FUNCTION
(vnet_per_buffer_interface_output_hw_interface_add_del);
+void
+vnet_set_interface_output_node (vnet_main_t * vnm,
+ u32 hw_if_index, u32 node_index)
+{
+ ASSERT (node_index);
+ vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
+ u32 next_index = vlib_node_add_next
+ (vnm->vlib_main, vnet_per_buffer_interface_output_node.index, node_index);
+ hi->output_node_next_index = next_index;
+ hi->output_node_index = node_index;
+}
+
static clib_error_t *
pcap_drop_trace_command_fn (vlib_main_t * vm,
unformat_input_t * input,
return format (s, "vxlan_gpe_tunnel%d", dev_instance);
}
-static uword
-dummy_interface_tx (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
-{
- clib_warning ("you shouldn't be here, leaking buffers...");
- return frame->n_vectors;
-}
-
/**
* @brief CLI function for VXLAN GPE admin up/down
*
.name = "VXLAN_GPE",
.format_device_name = format_vxlan_gpe_name,
.format_tx_trace = format_vxlan_gpe_encap_trace,
- .tx_function = dummy_interface_tx,
.admin_up_down_function = vxlan_gpe_interface_admin_up_down,
};
/* *INDENT-ON* */
(vnm, vxlan_gpe_device_class.index, t - ngm->tunnels,
vxlan_gpe_hw_class.index, t - ngm->tunnels);
hi = vnet_get_hw_interface (vnm, hw_if_index);
- hi->output_node_index = vxlan_gpe_encap_node.index;
}
+ /* Set vxlan-gpe tunnel output node */
+ u32 encap_index = vxlan_gpe_encap_node.index;
+ vnet_set_interface_output_node (vnm, hw_if_index, encap_index);
+
t->hw_if_index = hw_if_index;
t->sw_if_index = sw_if_index = hi->sw_if_index;
vec_validate_init_empty (ngm->tunnel_index_by_sw_if_index, sw_if_index,
VNET_SW_INTERFACE_FLAG_ADMIN_UP);
fib_node_init (&t->node, FIB_NODE_TYPE_VXLAN_GPE_TUNNEL);
fib_prefix_t tun_remote_pfx;
- u32 encap_index = vxlan_gpe_encap_node.index;
vnet_flood_class_t flood_class = VNET_FLOOD_CLASS_TUNNEL_NORMAL;
fib_prefix_from_ip46_addr (&t->remote, &tun_remote_pfx);
flood_class = VNET_FLOOD_CLASS_TUNNEL_MASTER;
}
- /* Set vxlan tunnel output node */
- hi->output_node_index = encap_index;
-
vnet_get_sw_interface (vnet_get_main (), sw_if_index)->flood_class =
flood_class;
}
return format (s, "vxlan_tunnel%d", dev_instance);
}
-static uword dummy_interface_tx (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
-{
- clib_warning ("you shouldn't be here, leaking buffers...");
- return frame->n_vectors;
-}
-
static clib_error_t *
vxlan_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
{
.name = "VXLAN",
.format_device_name = format_vxlan_name,
.format_tx_trace = format_vxlan_encap_trace,
- .tx_function = dummy_interface_tx,
.admin_up_down_function = vxlan_interface_admin_up_down,
};
(&im->sw_if_counters[VNET_INTERFACE_COUNTER_DROP], sw_if_index);
vnet_interface_counter_unlock(im);
}
- else
+ else
{
hw_if_index = vnet_register_interface
(vnm, vxlan_device_class.index, t - vxm->tunnels,
vxlan_hw_class.index, t - vxm->tunnels);
hi = vnet_get_hw_interface (vnm, hw_if_index);
}
-
+
+ /* Set vxlan tunnel output node */
+ u32 encap_index = !is_ip6 ?
+ vxlan4_encap_node.index : vxlan6_encap_node.index;
+ vnet_set_interface_output_node (vnm, hw_if_index, encap_index);
+
t->hw_if_index = hw_if_index;
t->sw_if_index = sw_if_index = hi->sw_if_index;
-
+
vec_validate_init_empty (vxm->tunnel_index_by_sw_if_index, sw_if_index, ~0);
vxm->tunnel_index_by_sw_if_index[sw_if_index] = t - vxm->tunnels;
vec_validate (l2im->configs, sw_if_index);
l2im->configs[sw_if_index].feature_bitmap = L2INPUT_FEAT_DROP;
l2im->configs[sw_if_index].bd_index = 0;
-
+
vnet_sw_interface_t * si = vnet_get_sw_interface (vnm, sw_if_index);
si->flags &= ~VNET_SW_INTERFACE_FLAG_HIDDEN;
- vnet_sw_interface_set_flags (vnm, sw_if_index,
+ vnet_sw_interface_set_flags (vnm, sw_if_index,
VNET_SW_INTERFACE_FLAG_ADMIN_UP);
fib_node_init(&t->node, FIB_NODE_TYPE_VXLAN_TUNNEL);
fib_prefix_t tun_dst_pfx;
- u32 encap_index = !is_ip6 ?
- vxlan4_encap_node.index : vxlan6_encap_node.index;
vnet_flood_class_t flood_class = VNET_FLOOD_CLASS_TUNNEL_NORMAL;
fib_prefix_from_ip46_addr(&t->dst, &tun_dst_pfx);
flood_class = VNET_FLOOD_CLASS_TUNNEL_MASTER;
}
- /* Set vxlan tunnel output node */
- hi->output_node_index = encap_index;
-
vnet_get_sw_interface (vnet_get_main(), sw_if_index)->flood_class = flood_class;
}
else