![]() |
FD.io VPP
v16.12-rc0-217-g241e522
Vector Packet Processing
|
IP Feature Subgraph Ordering. More...
Go to the source code of this file.
Macros | |
#define | foreach_af_cast |
Functions | |
static int | comma_split (u8 *s, u8 **a, u8 **b) |
clib_error_t * | vnet_feature_arc_init (vlib_main_t *vm, vnet_config_main_t *vcm, char **feature_start_nodes, int num_feature_start_nodes, vnet_ip_feature_registration_t *first_reg, char ***in_feature_nodes) |
Initialize a feature graph arc. More... | |
static clib_error_t * | show_ip_features_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) |
Display the set of available ip features. More... | |
void | ip_interface_features_show (vlib_main_t *vm, const char *pname, ip_config_main_t *cm, u32 sw_if_index) |
Display the set of IP features configured on a specific interface. More... | |
static clib_error_t * | show_ip_interface_features_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd) |
Variables | |
static const char * | vnet_cast_names [] = VNET_CAST_NAMES |
static vlib_cli_command_t | show_ip_features_command |
(constructor) VLIB_CLI_COMMAND (show_ip_features_command) More... | |
static vlib_cli_command_t | show_ip_interface_features_command |
(constructor) VLIB_CLI_COMMAND (show_ip_interface_features_command) More... | |
IP Feature Subgraph Ordering.
Dynamically compute IP feature subgraph ordering by performing a topological sort across a set of "feature A before feature B" and "feature C after feature B" constraints.
Use the topological sort result to set up vnet_config_main_t's for use at runtime.
Feature subgraph arcs are simple enough. They start at specific fixed nodes, and end at specific fixed nodes. In between, a per-interface current feature configuration dictates which additional nodes each packet visits. Each so-called feature node can [of course] drop any specific packet.
See ip4_forward.c, ip6_forward.c in this directory to see the current rx-unicast, rx-multicast, and tx feature subgraph arc definitions.
Let's say that we wish to add a new feature to the ip4 unicast feature subgraph arc, which needs to run before ip4-lookup
. In either base code or a plugin,
#include <vnet/ip/ip_feature_registration.h>
and add the new feature as shown:
VNET_IP4_UNICAST_FEATURE_INIT (ip4_lookup, static) =
{
.node_name = "my-ip4-unicast-feature",
.runs_before = ORDER_CONSTRAINTS {"ip4-lookup", 0}
.feature_index = &my_feature_index,
};
Here's the standard coding pattern to enable / disable my-ip4-unicast-feature
on an interface:
ip4_main_t *im = &ip4_main;
ip_lookup_main_t *lm = &im->lookup_main;
ip_config_main_t *rx_cm =
&lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT];
sw_if_index = <interface-handle>
ci = rx_cm->config_index_by_sw_if_index[sw_if_index];
ci = (is_add
? vnet_config_add_feature
: vnet_config_del_feature)
(vm, &rx_cm->config_main,
ci,
my_feature_index,
0 / * &config struct if feature uses private config data * /,
0 / * sizeof config struct if feature uses private config data * /);
rx_cm->config_index_by_sw_if_index[sw_if_index] = ci;
For tx features, add this line after setting
tx_cm->config_index_by_sw_if_index = ci.
This maintains a per-interface "at least one TX feature enabled" bitmap:
vnet_config_update_tx_feature_count (lm, tx_cm, sw_if_index, is_add);
Here's how to obtain the correct next node index in packet processing code, aka in the implementation of my-ip4-unicast-feature
:
ip_lookup_main_t * lm = sm->ip4_lookup_main;
ip_config_main_t * cm = &lm->feature_config_mains[VNET_IP_RX_UNICAST_FEAT];
Call vnet_get_config_data
to set next0, and to advance
b0->current_config_index:
config_data0 = vnet_get_config_data (&cm->config_main,
&b0->current_config_index,
&next0,
0 / * sizeof config data * /);
Nodes are free to drop or otherwise redirect packets. Packets which "pass" should be enqueued via the next0 arc computed by vnet_get_config_data.
Definition in file ip_feature_registration.c.
#define foreach_af_cast |
Definition at line 326 of file ip_feature_registration.c.
Definition at line 117 of file ip_feature_registration.c.
void ip_interface_features_show | ( | vlib_main_t * | vm, |
const char * | pname, | ||
ip_config_main_t * | cm, | ||
u32 | sw_if_index | ||
) |
Display the set of IP features configured on a specific interface.
Definition at line 415 of file ip_feature_registration.c.
|
static |
Display the set of available ip features.
Useful for verifying that expected features are present
Definition at line 339 of file ip_feature_registration.c.
|
static |
clib_error_t* vnet_feature_arc_init | ( | vlib_main_t * | vm, |
vnet_config_main_t * | vcm, | ||
char ** | feature_start_nodes, | ||
int | num_feature_start_nodes, | ||
vnet_ip_feature_registration_t * | first_reg, | ||
char *** | in_feature_nodes | ||
) |
Initialize a feature graph arc.
vm | vlib main structure pointer | |
vcm | vnet config main structure pointer | |
feature_start_nodes | names of start-nodes which use this feature graph arc | |
num_feature_start_nodes | number of start-nodes | |
first_reg | first element in [an attribute((constructor)) function built, or otherwise created] singly-linked list of feature registrations | |
[out] | in_feature_nodes | returned vector of topologically-sorted feature node names, for use in show commands |
Definition at line 151 of file ip_feature_registration.c.
|
static |
(constructor) VLIB_CLI_COMMAND (show_ip_features_command)
Definition at line 404 of file ip_feature_registration.c.
|
static |
(constructor) VLIB_CLI_COMMAND (show_ip_interface_features_command)
Definition at line 521 of file ip_feature_registration.c.
|
static |
Definition at line 114 of file ip_feature_registration.c.