FD.io VPP  v16.12-rc0-308-g931be3a
Vector Packet Processing
registration.c File Reference

Feature Subgraph Ordering. More...

+ Include dependency graph for registration.c:

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_tvnet_feature_arc_init (vlib_main_t *vm, vnet_config_main_t *vcm, char **feature_start_nodes, int num_feature_start_nodes, vnet_feature_registration_t *first_reg, char ***in_feature_nodes)
 Initialize a feature graph arc. More...
 
static clib_error_tshow_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, vnet_feature_config_main_t *cm, u32 sw_if_index)
 Display the set of IP features configured on a specific interface. More...
 
static clib_error_tshow_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...
 

Detailed Description

Feature Subgraph Ordering.

Dynamically compute 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/feature/feature.h>
 

and add the new feature as shown:

 VNET_FEATURE_INIT (ip4_lookup, static) =
 {
   .arch_name = "ip4-unicast",
   .node_name = "my-ip4-unicast-feature",
   .runs_before = VLIB_FEATURES ("ip4-lookup", 0)
 };
 

Here's the standard coding pattern to enable / disable my-ip4-unicast-feature on an interface:

 sw_if_index = <interface-handle>
 vnet_feature_enable_disable ("ip4-unicast", "my-ip4-unicast-feature",
                              sw_if_index, 1 );
 

Here's how to obtain the correct next node index in packet processing code, aka in the implementation of my-ip4-unicast-feature:

 vnet_feature_main_t *fm = 
 vnet_feature_config_main_t * cm = &fm->feature_config_mains[VNET_FEAT_IP4_UNICAST];

 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 registration.c.

Macro Definition Documentation

#define foreach_af_cast
Value:
_(4, VNET_IP_RX_UNICAST_FEAT, "ip4 unicast") \
_(4, VNET_IP_RX_MULTICAST_FEAT, "ip4 multicast") \
_(4, VNET_IP_TX_FEAT, "ip4 output") \
_(6, VNET_IP_RX_UNICAST_FEAT, "ip6 unicast") \
_(6, VNET_IP_RX_MULTICAST_FEAT, "ip6 multicast") \
_(6, VNET_IP_TX_FEAT, "ip6 output")

Definition at line 304 of file registration.c.

Function Documentation

static int comma_split ( u8 s,
u8 **  a,
u8 **  b 
)
static

Definition at line 93 of file registration.c.

+ Here is the caller graph for this function:

void ip_interface_features_show ( vlib_main_t vm,
const char *  pname,
vnet_feature_config_main_t cm,
u32  sw_if_index 
)

Display the set of IP features configured on a specific interface.

Definition at line 393 of file registration.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static clib_error_t* show_ip_features_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Display the set of available ip features.

Useful for verifying that expected features are present

Definition at line 317 of file registration.c.

+ Here is the call graph for this function:

static clib_error_t* show_ip_interface_features_command_fn ( vlib_main_t vm,
unformat_input_t input,
vlib_cli_command_t cmd 
)
static

Definition at line 443 of file registration.c.

+ Here is the call graph for this function:

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_feature_registration_t first_reg,
char ***  in_feature_nodes 
)

Initialize a feature graph arc.

Parameters
vmvlib main structure pointer
vcmvnet config main structure pointer
feature_start_nodesnames of start-nodes which use this feature graph arc
num_feature_start_nodesnumber of start-nodes
first_regfirst element in [an attribute((constructor)) function built, or otherwise created] singly-linked list of feature registrations
[out]in_feature_nodesreturned vector of topologically-sorted feature node names, for use in show commands
Returns
0 on success, otherwise an error message. Errors are fatal since they invariably involve mistyped node-names, or genuinely missing node-names

Definition at line 127 of file registration.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

vlib_cli_command_t show_ip_features_command
static
Initial value:
= {
.path = "show ip features",
.short_help = "show ip features",
}
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.
Definition: registration.c:317

(constructor) VLIB_CLI_COMMAND (show_ip_features_command)

Definition at line 382 of file registration.c.

vlib_cli_command_t show_ip_interface_features_command
static
Initial value:
= {
.path = "show ip interface features",
.short_help = "show ip interface features <interface>",
}
static clib_error_t * show_ip_interface_features_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: registration.c:443

(constructor) VLIB_CLI_COMMAND (show_ip_interface_features_command)

Definition at line 499 of file registration.c.

const char* vnet_cast_names[] = VNET_CAST_NAMES
static

Definition at line 90 of file registration.c.