FD.io VPP  v18.04-17-g3a0d853
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.

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

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")
 };
 

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_next (sw_if_index0, &next0, b0);

 

Nodes are free to drop or otherwise redirect packets. Packets which "pass" should be enqueued via the next0 arc computed by vnet_feature_next.

Definition in file registration.c.

Function Documentation

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

Definition at line 84 of file registration.c.

+ Here is the caller 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 118 of file registration.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: