* 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 <vlib/vlib.h>
#include <vnet/devices/dpdk/dpdk.h>
#include <vnet/dpdk_replication.h>
#include <vnet/ip/ip.h>
+#include <vnet/fib/ip6_fib.h>
#include <vppinfra/hash.h>
#include <vppinfra/error.h>
#include <vppinfra/elog.h>
+/**
+ * @brief sr_replicate state.
+ *
+*/
typedef struct
{
/* convenience */
sr_replicate_main_t sr_replicate_main;
-
+/**
+ * @brief Information to display in packet trace.
+ *
+*/
typedef struct
{
ip6_address_t src, dst;
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)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
sr_replicate_trace_t *t = va_arg (*args, sr_replicate_trace_t *);
- ip6_main_t *im = &ip6_main;
ip6_sr_main_t *sm = &sr_main;
ip6_sr_tunnel_t *tun = pool_elt_at_index (sm->tunnels, t->tunnel_index);
ip6_fib_t *rx_fib, *tx_fib;
- rx_fib = find_ip6_fib_by_table_index_or_id (im, tun->rx_fib_index,
- IP6_ROUTE_FLAG_FIB_INDEX);
-
- tx_fib = find_ip6_fib_by_table_index_or_id (im, tun->tx_fib_index,
- IP6_ROUTE_FLAG_FIB_INDEX);
+ rx_fib = ip6_fib_get (tun->rx_fib_index);
+ tx_fib = ip6_fib_get (tun->tx_fib_index);
s = format
(s, "SR-REPLICATE: next %s ip6 src %U dst %U len %u\n"
_(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,
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)
(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));
}
}