X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vnet%2Fvnet%2Fsr%2Fsr_replicate.c;h=37c39442efdfa3e6840e42bae9bedd2379ca98fc;hb=7214cf11e9b9edbc015994cb7f9f5828e02d3791;hp=f5a71a311c44395a9402302e2d1f37829b98cf6a;hpb=06c5ffd625d575e6e76ece9e6c7be9873d147525;p=vpp.git diff --git a/vnet/vnet/sr/sr_replicate.c b/vnet/vnet/sr/sr_replicate.c index f5a71a311c4..37c39442efd 100644 --- a/vnet/vnet/sr/sr_replicate.c +++ b/vnet/vnet/sr/sr_replicate.c @@ -14,6 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/** + * @file + * @brief Functions for replicating packets across SR tunnels. + * + * Leverages rte_pktmbuf_clone() so there is no memcpy for + * invariant parts of the packet. + * + * @note Currently requires DPDK +*/ #if DPDK > 0 /* Cannot run replicate without DPDK */ #include @@ -28,6 +37,10 @@ #include #include +/** + * @brief sr_replicate state. + * +*/ typedef struct { /* convenience */ @@ -37,7 +50,10 @@ typedef struct sr_replicate_main_t sr_replicate_main; - +/** + * @brief Information to display in packet trace. + * +*/ typedef struct { ip6_address_t src, dst; @@ -47,7 +63,13 @@ typedef struct u8 sr[256]; } sr_replicate_trace_t; -/* packet trace format function */ +/** + * @brief packet trace format function. + * + * @param *s u8 used for string output + * @param *args va_list structured input to va_arg to output @ref sr_replicate_trace_t + * @return *s u8 - formatted trace output +*/ static u8 * format_sr_replicate_trace (u8 * s, va_list * args) { @@ -83,6 +105,9 @@ _(NO_BUFFERS, "error allocating buffers for replicas") \ _(NO_REPLICAS, "no replicas were needed") \ _(NO_BUFFER_DROPS, "sr no buffer drops") +/** + * @brief Struct for SR replicate errors + */ typedef enum { #define _(sym,str) SR_REPLICATE_ERROR_##sym, @@ -91,18 +116,32 @@ typedef enum SR_REPLICATE_N_ERROR, } sr_replicate_error_t; +/** + * @brief Error strings for SR replicate + */ static char *sr_replicate_error_strings[] = { #define _(sym,string) string, foreach_sr_replicate_error #undef _ }; +/** + * @brief Defines next-nodes for packet processing. + * +*/ typedef enum { SR_REPLICATE_NEXT_IP6_LOOKUP, SR_REPLICATE_N_NEXT, } sr_replicate_next_t; +/** + * @brief Single loop packet replicator. + * + * @node sr-replicate + * @param vm vlib_main_t + * @return frame->n_vectors uword +*/ static uword sr_replicate_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) @@ -324,7 +363,8 @@ sr_replicate_node_fn (vlib_main_t * vm, (hdr_ip0->payload_length); } tr->next_index = next_index; - memcpy (tr->sr, hdr_sr0, sizeof (tr->sr)); + if (hdr_sr0) + memcpy (tr->sr, hdr_sr0, sizeof (tr->sr)); } }