int nsim_cross_connect_enable_disable (nsim_main_t * nsm, u32 sw_if_index0, u32 sw_if_index1, int enable_disable) { vnet_sw_interface_t *sw; vnet_hw_interface_t *hw; int rv = 0; if (nsm->is_configured == 0) return VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE; /* Utterly wrong? */ if (pool_is_free_index (nsm->vnet_main->interface_main.sw_interfaces, sw_if_index0)) return VNET_API_ERROR_INVALID_SW_IF_INDEX; if (pool_is_free_index (nsm->vnet_main->interface_main.sw_interfaces, sw_if_index1)) return VNET_API_ERROR_INVALID_SW_IF_INDEX; /* Not a physical port? */ sw = vnet_get_sw_interface (nsm->vnet_main, sw_if_index0); if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE) return VNET_API_ERROR_INVALID_SW_IF_INDEX; sw = vnet_get_sw_interface (nsm->vnet_main, sw_if_index1); if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE) return VNET_API_ERROR_INVALID_SW_IF_INDEX; /* Add graph arcs for the input / wheel scraper node */ hw = vnet_get_hw_interface (nsm->vnet_main, sw_if_index0); nsm->output_next_index0 = vlib_node_add_next (nsm->vlib_main, nsim_input_node.index, hw->output_node_index); hw = vnet_get_hw_interface (nsm->vnet_main, sw_if_index1); nsm->output_next_index1 = vlib_node_add_next (nsm->vlib_main, nsim_input_node.index, hw->output_node_index); nsm->sw_if_index0 = sw_if_index0; nsm->sw_if_index1 = sw_if_index1; vnet_feature_enable_disable ("device-input", "nsim", sw_if_index0, enable_disable, 0, 0); vnet_feature_enable_disable ("device-input", "nsim", sw_if_index1, enable_disable, 0, 0); return rv; }
static clib_error_t * ioam_export_init (vlib_main_t * vm) { ioam_export_main_t *em = &ioam_export_main; clib_error_t *error = 0; u8 *name; u32 node_index = export_node.index; vlib_node_t *ip6_hbyh_node = NULL; em->vlib_main = vm; em->vnet_main = vnet_get_main (); em->set_id = IPFIX_IOAM_EXPORT_ID; ioam_export_reset_next_node (em); name = format (0, "ioam_export_%08x%c", api_version, 0); /* Ask for a correctly-sized block of API message decode slots */ em->msg_id_base = vl_msg_api_get_msg_ids ((char *) name, VL_MSG_FIRST_AVAILABLE); em->unix_time_0 = (u32) time (0); /* Store starting time */ em->vlib_time_0 = vlib_time_now (vm); error = ioam_export_plugin_api_hookup (vm); /* Add our API messages to the global name_crc hash table */ setup_message_id_table (em, &api_main); /* Hook this export node to ip6-hop-by-hop */ ip6_hbyh_node = vlib_get_node_by_name (vm, (u8 *) "ip6-hop-by-hop"); em->my_hbh_slot = vlib_node_add_next (vm, ip6_hbyh_node->index, node_index); vec_free (name); return error; }
int nsim_output_feature_enable_disable (nsim_main_t * nsm, u32 sw_if_index, int enable_disable) { vnet_sw_interface_t *sw; vnet_hw_interface_t *hw; int rv = 0; if (nsm->is_configured == 0) return VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE; /* Utterly wrong? */ if (pool_is_free_index (nsm->vnet_main->interface_main.sw_interfaces, sw_if_index)) return VNET_API_ERROR_INVALID_SW_IF_INDEX; /* Not a physical port? */ sw = vnet_get_sw_interface (nsm->vnet_main, sw_if_index); if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE) return VNET_API_ERROR_INVALID_SW_IF_INDEX; /* Add a graph arc for the input / wheel scraper node */ hw = vnet_get_hw_interface (nsm->vnet_main, sw_if_index); vec_validate_init_empty (nsm->output_next_index_by_sw_if_index, sw_if_index, ~0); /* Note: use the tx node, this pkt has already visited the output node... */ nsm->output_next_index_by_sw_if_index[sw_if_index] = vlib_node_add_next (nsm->vlib_main, nsim_input_node.index, hw->tx_node_index); vnet_feature_enable_disable ("interface-output", "nsim-output-feature", sw_if_index, enable_disable, 0, 0); return rv; }
static u32 add_next (vlib_main_t * vm, vnet_config_main_t * cm, u32 last_node_index, u32 this_node_index) { u32 i, ni = ~0; if (last_node_index != ~0) return vlib_node_add_next (vm, last_node_index, this_node_index); for (i = 0; i < vec_len (cm->start_node_indices); i++) { u32 tmp; tmp = vlib_node_add_next (vm, cm->start_node_indices[i], this_node_index); if (ni == ~0) ni = tmp; /* Start nodes to first must agree on next indices. */ ASSERT (ni == tmp); } return ni; }