91 (s,
"SR-REPLICATE: next %s ip6 src %U dst %U len %u\n" 92 " rx-fib-id %d tx-fib-id %d\n%U",
102 #define foreach_sr_replicate_error \ 103 _(REPLICATED, "sr packets replicated") \ 104 _(NO_BUFFERS, "error allocating buffers for replicas") \ 105 _(NO_REPLICAS, "no replicas were needed") \ 106 _(NO_BUFFER_DROPS, "sr no buffer drops") 113 #define _(sym,str) SR_REPLICATE_ERROR_##sym, 123 #define _(sym,string) string, 149 u32 n_left_from, *from, *to_next;
151 int pkts_replicated = 0;
153 int no_buffer_drops = 0;
164 while (n_left_from > 0)
170 while (n_left_from > 0 && n_left_to_next > 0)
174 struct rte_mbuf *orig_mb0 = 0, *hdr_mb0 = 0, *clone0 = 0;
175 struct rte_mbuf **hdr_vec = 0, **rte_mbuf_vec = 0;
180 int num_replicas = 0;
198 - (
i16) orig_mb0->pkt_len;
200 u16 new_data_len0 = (
u16) ((
i16) orig_mb0->data_len + delta0);
201 u16 new_pkt_len0 = (
u16) ((
i16) orig_mb0->pkt_len + delta0);
203 orig_mb0->data_len = new_data_len0;
204 orig_mb0->pkt_len = new_pkt_len0;
220 b0->
error = node->
errors[SR_REPLICATE_ERROR_NO_REPLICAS];
227 for (i = 0; i < num_replicas; i++)
231 if (i < (num_replicas - 1))
233 clone0 = rte_pktmbuf_clone
242 b0->
error = node->
errors[SR_REPLICATE_ERROR_NO_BUFFERS];
246 rte_pktmbuf_free (rte_mbuf_vec[i]);
252 rte_pktmbuf_free (hdr_vec[i]);
264 for (i = 0; i < num_replicas; i++)
271 hdr_mb0 = hdr_vec[
i];
272 clone0 = rte_mbuf_vec[
i];
275 hdr_mb0->pkt_len = hdr_mb0->data_len +
282 memcpy (hdr_b0->
data, ip0, sizeof (*ip0));
295 hdr_ip0->payload_length =
296 clib_host_to_net_u16 (hdr_mb0->data_len);
298 hdr_sr0->
protocol = hdr_ip0->protocol;
299 hdr_ip0->protocol = 43;
308 hdr_mb0->next = clone0;
315 (
uint16_t) (hdr_mb0->data_len + clone0->pkt_len);
316 hdr_mb0->nb_segs = (
uint8_t) (clone0->nb_segs + 1);
319 hdr_mb0->port = clone0->port;
320 hdr_mb0->vlan_tci = clone0->vlan_tci;
321 hdr_mb0->vlan_tci_outer = clone0->vlan_tci_outer;
322 hdr_mb0->tx_offload = clone0->tx_offload;
323 hdr_mb0->hash = clone0->hash;
325 hdr_mb0->ol_flags = clone0->ol_flags;
327 __rte_mbuf_sanity_check (hdr_mb0, 1);
331 to_next[0] = hdr_bi0;
335 if (n_left_to_next == 0)
339 to_next, n_left_to_next);
357 memcpy (tr->
src.
as_u8, hdr_ip0->src_address.as_u8,
359 memcpy (tr->
dst.
as_u8, hdr_ip0->dst_address.as_u8,
361 if (hdr_ip0->payload_length)
362 tr->
length = clib_net_to_host_u16
363 (hdr_ip0->payload_length);
367 memcpy (tr->
sr, hdr_sr0, sizeof (tr->
sr));
376 SR_REPLICATE_ERROR_REPLICATED,
380 SR_REPLICATE_ERROR_NO_BUFFER_DROPS,
389 .name =
"sr-replicate",
390 .vector_size =
sizeof (
u32),
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
clib_error_t * sr_replicate_init(vlib_main_t *vm)
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
#define rte_mbuf_from_vlib_buffer(x)
u32 tx_fib_index
TX Fib index.
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vlib_buffer_main_t * buffer_main
u32 rx_fib_index
RX Fib index.
static uword sr_replicate_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Single loop packet replicator.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static void vlib_buffer_init_for_free_list(vlib_buffer_t *_dst, vlib_buffer_free_list_t *fl)
vnet_main_t * vnet_get_main(void)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define VLIB_INIT_FUNCTION(x)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
ip6_fib_t * find_ip6_fib_by_table_index_or_id(ip6_main_t *im, u32 table_index_or_id, u32 flags)
Get or create an IPv6 fib.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Information to display in packet trace.
static u32 vlib_get_buffer_index(vlib_main_t *vm, void *p)
Translate buffer pointer into buffer index.
#define VLIB_BUFFER_NEXT_PRESENT
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
unsigned short int uint16_t
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static u8 * format_sr_replicate_trace(u8 *s, va_list *args)
packet trace format function.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
u8 * rewrite
The actual ip6 SR header.
struct rte_mempool ** pktmbuf_pools
#define vec_free(V)
Free vector's memory (no header).
static char * sr_replicate_error_strings[]
Error strings for SR replicate.
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
u32 * tunnel_indices
vector to SR tunnel index
void sr_fix_hmac(ip6_sr_main_t *sm, ip6_header_t *ip, ip6_sr_header_t *sr)
Use passed HMAC key in ip6_sr_header_t in OpenSSL HMAC routines.
#define VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX
ip6_address_t first_hop
First hop, to save 1 elt in the segment list.
u32 next_buffer
Next buffer for this linked-list of buffers.
ip6_sr_tunnel_t * tunnels
pool of tunnel instances, sr entry only
#define VLIB_BUFFER_IS_TRACED
#define IP6_ROUTE_FLAG_FIB_INDEX
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
u32 total_length_not_including_first_buffer
Only valid for first buffer in chain.
format_function_t format_ip6_sr_header
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip6_sr_policy_t * policies
policy pool
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
sr_replicate_error_t
Struct for SR replicate errors.
#define foreach_sr_replicate_error
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
#define vlib_buffer_from_rte_mbuf(x)
sr_replicate_main_t sr_replicate_main
static vlib_buffer_free_list_t * vlib_buffer_get_free_list(vlib_main_t *vm, u32 free_list_index)
vlib_node_registration_t sr_replicate_node
(constructor) VLIB_REGISTER_NODE (sr_replicate_node)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
sr_replicate_next_t
Defines next-nodes for packet processing.