87 (s,
"SR-REPLICATE: next %s ip6 src %U dst %U len %u\n" 88 " rx-fib-id %d tx-fib-id %d\n%U",
98 #define foreach_sr_replicate_error \ 99 _(REPLICATED, "sr packets replicated") \ 100 _(NO_BUFFERS, "error allocating buffers for replicas") \ 101 _(NO_REPLICAS, "no replicas were needed") \ 102 _(NO_BUFFER_DROPS, "sr no buffer drops") 109 #define _(sym,str) SR_REPLICATE_ERROR_##sym, 119 #define _(sym,string) string, 145 u32 n_left_from, *from, *to_next;
147 int pkts_replicated = 0;
149 int no_buffer_drops = 0;
160 while (n_left_from > 0)
166 while (n_left_from > 0 && n_left_to_next > 0)
170 struct rte_mbuf *orig_mb0 = 0, *hdr_mb0 = 0, *clone0 = 0;
171 struct rte_mbuf **hdr_vec = 0, **rte_mbuf_vec = 0;
176 int num_replicas = 0;
196 (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
198 ip6_hop_by_hop_ext_t *ext_hdr =
202 len_bytes += ext_hdr_len;
203 next_hdr = ext_hdr->next_hdr;
205 ip_next_hdr = IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS;
214 - (
i16) orig_mb0->pkt_len;
216 u16 new_data_len0 = (
u16) ((
i16) orig_mb0->data_len + delta0);
217 u16 new_pkt_len0 = (
u16) ((
i16) orig_mb0->pkt_len + delta0);
219 orig_mb0->data_len = new_data_len0;
220 orig_mb0->pkt_len = new_pkt_len0;
235 b0->
error = node->
errors[SR_REPLICATE_ERROR_NO_REPLICAS];
242 for (i = 0; i < num_replicas; i++)
245 struct rte_mbuf *clone0i;
251 if (i < (num_replicas - 1))
254 clone0 = rte_pktmbuf_clone
261 while ((clone0->nb_segs >= 1) && (nb_seg < clone0->nb_segs))
272 (clone0i->buf_addr + clone0i->data_off) -
273 (
void *) clone_b0->
data;
283 clone0i = clone0i->next;
295 b0->
error = node->
errors[SR_REPLICATE_ERROR_NO_BUFFERS];
299 rte_pktmbuf_free (rte_mbuf_vec[i]);
305 rte_pktmbuf_free (hdr_vec[i]);
317 for (i = 0; i < num_replicas; i++)
324 hdr_mb0 = hdr_vec[
i];
325 clone0 = rte_mbuf_vec[
i];
328 hdr_mb0->pkt_len = hdr_mb0->data_len +
335 memcpy (hdr_b0->
data, ip0, len_bytes);
343 vnet_buffer (hdr_b0)->l2_classify.opaque_index = 0;
352 hdr_ip0->payload_length = clib_host_to_net_u16 (new_l0);
357 hdr_ip0->protocol = ip_next_hdr;
370 hdr_mb0->next = clone0;
377 (uint16_t) (hdr_mb0->data_len + clone0->pkt_len);
378 hdr_mb0->nb_segs = (uint8_t) (clone0->nb_segs + 1);
381 hdr_mb0->port = clone0->port;
382 hdr_mb0->vlan_tci = clone0->vlan_tci;
383 hdr_mb0->vlan_tci_outer = clone0->vlan_tci_outer;
384 hdr_mb0->tx_offload = clone0->tx_offload;
385 hdr_mb0->hash = clone0->hash;
387 hdr_mb0->ol_flags = clone0->ol_flags & ~(IND_ATTACHED_MBUF);
389 __rte_mbuf_sanity_check (hdr_mb0, 1);
393 to_next[0] = hdr_bi0;
397 if (n_left_to_next == 0)
401 to_next, n_left_to_next);
419 memcpy (tr->
src.
as_u8, hdr_ip0->src_address.as_u8,
421 memcpy (tr->
dst.
as_u8, hdr_ip0->dst_address.as_u8,
423 if (hdr_ip0->payload_length)
424 tr->
length = clib_net_to_host_u16
425 (hdr_ip0->payload_length);
429 memcpy (tr->
sr, hdr_sr0, sizeof (tr->
sr));
438 SR_REPLICATE_ERROR_REPLICATED,
442 SR_REPLICATE_ERROR_NO_BUFFER_DROPS,
451 .name =
"sr-replicate",
452 .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.
#define IPPROTO_IPV6_ROUTE
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)
#define ip6_ext_header_len(p)
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.
#define clib_memcpy(a, b, c)
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.
static void * ip6_next_header(ip6_header_t *i)
#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.
u32 trace_index
Specifies index into trace buffer if VLIB_PACKET_IS_TRACED flag is set.
sr_replicate_next_t
Defines next-nodes for packet processing.