X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fdpo%2Fdpo.c;h=df78456bf60d098987b9ad8eefbe4f8f1b6e5f59;hb=8feeaff56fa9a4fbdfc06131f28a1060ffd9645d;hp=bd18b66bfd55f10817c1cea81165547cdd20688b;hpb=43161a873375ddf156cf6fbe8764bfc206b38fa0;p=vpp.git diff --git a/src/vnet/dpo/dpo.c b/src/vnet/dpo/dpo.c index bd18b66bfd5..df78456bf60 100644 --- a/src/vnet/dpo/dpo.c +++ b/src/vnet/dpo/dpo.c @@ -18,7 +18,7 @@ * applied to packets are they are switched through VPP. * * The DPO is a base class that is specialised by other objects to provide - * concreate actions + * concrete actions * * The VLIB graph nodes are graph of types, the DPO graph is a graph of instances. */ @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include /** * Array of char* names for the DPO types and protos @@ -75,7 +78,7 @@ static const char* const * const ** dpo_nodes; * the third dimension in dpo_nodes is lost, hence, the edge index from each * node MUST be the same. * Including both the child and parent protocol is required to support the - * case where it changes as the grapth is traversed, most notablly when an + * case where it changes as the graph is traversed, most notably when an * MPLS label is popped. * * Note that this array is child type specific, not child instance specific. @@ -83,7 +86,7 @@ static const char* const * const ** dpo_nodes; static u32 ****dpo_edges; /** - * @brief The DPO type value that can be assigend to the next dynamic + * @brief The DPO type value that can be assigned to the next dynamic * type registration. */ static dpo_type_t dpo_dynamic = DPO_LAST; @@ -120,6 +123,7 @@ dpo_proto_to_link (dpo_proto_t dp) case DPO_PROTO_IP4: return (VNET_LINK_IP4); case DPO_PROTO_MPLS: + case DPO_PROTO_BIER: return (VNET_LINK_MPLS); case DPO_PROTO_ETHERNET: return (VNET_LINK_ETHERNET); @@ -149,20 +153,22 @@ format_dpo_id (u8 * s, va_list * args) if (NULL != dpo_vfts[dpo->dpoi_type].dv_format) { - return (format(s, "%U", - dpo_vfts[dpo->dpoi_type].dv_format, - dpo->dpoi_index, - indent)); + s = format(s, "%U", + dpo_vfts[dpo->dpoi_type].dv_format, + dpo->dpoi_index, + indent); } - - switch (dpo->dpoi_type) + else { - case DPO_FIRST: - s = format(s, "unset"); - break; - default: - s = format(s, "unknown"); - break; + switch (dpo->dpoi_type) + { + case DPO_FIRST: + s = format(s, "unset"); + break; + default: + s = format(s, "unknown"); + break; + } } return (s); } @@ -299,6 +305,18 @@ dpo_default_get_next_node (const dpo_id_t *dpo) return (node_indices); } +/** + * A default variant of the make interpose function that just returns + * the original + */ +static void +dpo_default_mk_interpose (const dpo_id_t *original, + const dpo_id_t *parent, + dpo_id_t *clone) +{ + dpo_copy(clone, original); +} + void dpo_register (dpo_type_t type, const dpo_vft_t *vft, @@ -310,6 +328,10 @@ dpo_register (dpo_type_t type, { dpo_vfts[type].dv_get_next_node = dpo_default_get_next_node; } + if (NULL == dpo_vfts[type].dv_mk_interpose) + { + dpo_vfts[type].dv_mk_interpose = dpo_default_mk_interpose; + } vec_validate(dpo_nodes, type); dpo_nodes[type] = nodes; @@ -326,6 +348,17 @@ dpo_register_new_type (const dpo_vft_t *vft, return (type); } +void +dpo_mk_interpose (const dpo_id_t *original, + const dpo_id_t *parent, + dpo_id_t *clone) +{ + if (!dpo_id_is_valid(original)) + return; + + dpo_vfts[original->dpoi_type].dv_mk_interpose(original, parent, clone); +} + void dpo_lock (dpo_id_t *dpo) { @@ -344,6 +377,17 @@ dpo_unlock (dpo_id_t *dpo) dpo_vfts[dpo->dpoi_type].dv_unlock(dpo); } +u32 +dpo_get_urpf(const dpo_id_t *dpo) +{ + if (dpo_id_is_valid(dpo) && + (NULL != dpo_vfts[dpo->dpoi_type].dv_get_urpf)) + { + return (dpo_vfts[dpo->dpoi_type].dv_get_urpf(dpo)); + } + + return (~0); +} static u32 dpo_get_next_node (dpo_type_t child_type, @@ -364,7 +408,7 @@ dpo_get_next_node (dpo_type_t child_type, parent_proto, ~0); /* - * if the edge index has not yet been created for this node to node transistion + * if the edge index has not yet been created for this node to node transition */ if (~0 == dpo_edges[child_type][child_proto][parent_type][parent_proto]) { @@ -417,6 +461,21 @@ dpo_get_next_node (dpo_type_t child_type, return (dpo_edges[child_type][child_proto][parent_type][parent_proto]); } +/** + * @brief return already stacked up next node index for a given + * child_type/child_proto and parent_type/patent_proto. + * The VLIB graph arc used is taken from the parent and child types + * passed. + */ +u32 +dpo_get_next_node_by_type_and_proto (dpo_type_t child_type, + dpo_proto_t child_proto, + dpo_type_t parent_type, + dpo_proto_t parent_proto) +{ + return (dpo_edges[child_type][child_proto][parent_type][parent_proto]); +} + /** * @brief Stack one DPO object on another, and thus establish a child parent * relationship. The VLIB graph arc used is taken from the parent and child types @@ -435,7 +494,7 @@ dpo_stack_i (u32 edge, dpo_copy(&tmp, parent); /* - * get the edge index for the parent to child VLIB graph transisition + * get the edge index for the parent to child VLIB graph transition */ tmp.dpoi_next_node = edge; @@ -506,6 +565,9 @@ dpo_stack_from_node (u32 child_node_index, } } dpo_stack_i(edge, dpo, parent); + + /* should free this local vector to avoid memory leak */ + vec_free(parent_indices); } static clib_error_t * @@ -519,10 +581,13 @@ dpo_module_init (vlib_main_t * vm) classify_dpo_module_init(); lookup_dpo_module_init(); ip_null_dpo_module_init(); + ip6_ll_dpo_module_init(); replicate_module_init(); interface_rx_dpo_module_init(); interface_tx_dpo_module_init(); mpls_disp_dpo_module_init(); + dvr_dpo_module_init(); + l3_proxy_dpo_module_init(); return (NULL); }