88 (s,
"SR-REPLICATE: next %s ip6 src %U dst %U len %u\n" 89 " rx-fib-id %d tx-fib-id %d\n%U",
99 #define foreach_sr_replicate_error \ 100 _(REPLICATED, "sr packets replicated") \ 101 _(NO_BUFFERS, "error allocating buffers for replicas") \ 102 _(NO_REPLICAS, "no replicas were needed") \ 103 _(NO_BUFFER_DROPS, "sr no buffer drops") 110 #define _(sym,str) SR_REPLICATE_ERROR_##sym, 120 #define _(sym,string) string, 146 u32 n_left_from, *from, *to_next;
148 int pkts_replicated = 0;
150 int no_buffer_drops = 0;
161 while (n_left_from > 0)
167 while (n_left_from > 0 && n_left_to_next > 0)
171 struct rte_mbuf *orig_mb0 = 0, *hdr_mb0 = 0, *clone0 = 0;
172 struct rte_mbuf **hdr_vec = 0, **rte_mbuf_vec = 0;
177 int num_replicas = 0;
195 - (
i16) orig_mb0->pkt_len;
197 u16 new_data_len0 = (
u16) ((
i16) orig_mb0->data_len + delta0);
198 u16 new_pkt_len0 = (
u16) ((
i16) orig_mb0->pkt_len + delta0);
200 orig_mb0->data_len = new_data_len0;
201 orig_mb0->pkt_len = new_pkt_len0;
217 b0->
error = node->
errors[SR_REPLICATE_ERROR_NO_REPLICAS];
224 for (i = 0; i < num_replicas; i++)
228 if (i < (num_replicas - 1))
230 clone0 = rte_pktmbuf_clone
239 b0->
error = node->
errors[SR_REPLICATE_ERROR_NO_BUFFERS];
243 rte_pktmbuf_free (rte_mbuf_vec[i]);
249 rte_pktmbuf_free (hdr_vec[i]);
261 for (i = 0; i < num_replicas; i++)
268 hdr_mb0 = hdr_vec[
i];
269 clone0 = rte_mbuf_vec[
i];
272 hdr_mb0->pkt_len = hdr_mb0->data_len +
279 memcpy (hdr_b0->
data, ip0, sizeof (*ip0));
292 hdr_ip0->payload_length =
293 clib_host_to_net_u16 (hdr_mb0->data_len);
295 hdr_sr0->
protocol = hdr_ip0->protocol;
296 hdr_ip0->protocol = 43;
305 hdr_mb0->next = clone0;
312 (uint16_t) (hdr_mb0->data_len + clone0->pkt_len);
313 hdr_mb0->nb_segs = (uint8_t) (clone0->nb_segs + 1);
316 hdr_mb0->port = clone0->port;
317 hdr_mb0->vlan_tci = clone0->vlan_tci;
318 hdr_mb0->vlan_tci_outer = clone0->vlan_tci_outer;
319 hdr_mb0->tx_offload = clone0->tx_offload;
320 hdr_mb0->hash = clone0->hash;
322 hdr_mb0->ol_flags = clone0->ol_flags;
324 __rte_mbuf_sanity_check (hdr_mb0, 1);
328 to_next[0] = hdr_bi0;
332 if (n_left_to_next == 0)
336 to_next, n_left_to_next);
354 memcpy (tr->
src.
as_u8, hdr_ip0->src_address.as_u8,
356 memcpy (tr->
dst.
as_u8, hdr_ip0->dst_address.as_u8,
358 if (hdr_ip0->payload_length)
359 tr->
length = clib_net_to_host_u16
360 (hdr_ip0->payload_length);
364 memcpy (tr->
sr, hdr_sr0, sizeof (tr->
sr));
373 SR_REPLICATE_ERROR_REPLICATED,
377 SR_REPLICATE_ERROR_NO_BUFFER_DROPS,
386 .name =
"sr-replicate",
387 .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.
static ip6_fib_t * ip6_fib_get(fib_node_index_t 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.
#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.
#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
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.