* @return precomputed rewrite string for encapsulation
*/
static inline u8 *
-compute_rewrite_encaps (ip6_address_t * sl)
+compute_rewrite_encaps (ip6_address_t *sl, u8 type)
{
ip6_header_t *iph;
ip6_sr_header_t *srh;
* @return precomputed rewrite string for SRH insertion
*/
static inline u8 *
-compute_rewrite_insert (ip6_address_t * sl)
+compute_rewrite_insert (ip6_address_t *sl, u8 type)
{
ip6_sr_header_t *srh;
ip6_address_t *addrp, *this_address;
(weight != (u32) ~ 0 ? weight : SR_SEGMENT_LIST_WEIGHT_DEFAULT);
segment_list->segments = vec_dup (sl);
+ segment_list->policy_type = sr_policy->type;
segment_list->egress_fib_table =
ip6_fib_index_from_table_id (sr_policy->fib_table);
if (is_encap)
{
- segment_list->rewrite = compute_rewrite_encaps (sl);
+ segment_list->rewrite = compute_rewrite_encaps (sl, sr_policy->type);
segment_list->rewrite_bsid = segment_list->rewrite;
}
else
{
- segment_list->rewrite = compute_rewrite_insert (sl);
+ segment_list->rewrite = compute_rewrite_insert (sl, sr_policy->type);
segment_list->rewrite_bsid = compute_rewrite_bsid (sl);
}
* @return 0 if correct, else error
*/
int
-sr_policy_add (ip6_address_t * bsid, ip6_address_t * segments,
- u32 weight, u8 behavior, u32 fib_table, u8 is_encap,
- u16 plugin, void *ls_plugin_mem)
+sr_policy_add (ip6_address_t *bsid, ip6_address_t *segments, u32 weight,
+ u8 type, u32 fib_table, u8 is_encap, u16 plugin,
+ void *ls_plugin_mem)
{
ip6_sr_main_t *sm = &sr_main;
ip6_sr_policy_t *sr_policy = 0;
pool_get (sm->sr_policies, sr_policy);
clib_memset (sr_policy, 0, sizeof (*sr_policy));
clib_memcpy_fast (&sr_policy->bsid, bsid, sizeof (ip6_address_t));
- sr_policy->type = behavior;
+ sr_policy->type = type;
sr_policy->fib_table = (fib_table != (u32) ~ 0 ? fib_table : 0); //Is default FIB 0 ?
sr_policy->is_encap = is_encap;
ip6_address_t *segments = 0, *this_seg;
u8 operation = 0;
char is_encap = 1;
- char is_spray = 0;
+ u8 type = SR_POLICY_TYPE_DEFAULT;
u16 behavior = 0;
void *ls_plugin_mem = 0;
else if (unformat (input, "insert"))
is_encap = 0;
else if (unformat (input, "spray"))
- is_spray = 1;
+ type = SR_POLICY_TYPE_SPRAY;
else if (!behavior && unformat (input, "behavior"))
{
sr_policy_fn_registration_t *plugin = 0, **vec_plugins = 0;
if (vec_len (segments) == 0)
return clib_error_return (0, "No Segment List specified");
- rv = sr_policy_add (&bsid, segments, weight,
- (is_spray ? SR_POLICY_TYPE_SPRAY :
- SR_POLICY_TYPE_DEFAULT), fib_table, is_encap,
+ rv = sr_policy_add (&bsid, segments, weight, type, fib_table, is_encap,
behavior, ls_plugin_mem);
vec_free (segments);
vlib_cli_output (vm, "\tBehavior: %s",
(sr_policy->is_encap ? "Encapsulation" :
"SRH insertion"));
- vlib_cli_output (vm, "\tType: %s",
- (sr_policy->type ==
- SR_POLICY_TYPE_DEFAULT ? "Default" : "Spray"));
+ switch (sr_policy->type)
+ {
+ case SR_POLICY_TYPE_SPRAY:
+ vlib_cli_output (vm, "\tType: %s", "Spray");
+ break;
+ default:
+ vlib_cli_output (vm, "\tType: %s", "Default");
+ break;
+ }
vlib_cli_output (vm, "\tFIB table: %u",
(sr_policy->fib_table !=
(u32) ~ 0 ? sr_policy->fib_table : 0));
* @brief IPv6 encapsulation processing as per RFC2473
*/
static_always_inline void
-encaps_processing_v6 (vlib_node_runtime_t * node,
- vlib_buffer_t * b0,
- ip6_header_t * ip0, ip6_header_t * ip0_encap)
+encaps_processing_v6 (vlib_node_runtime_t *node, vlib_buffer_t *b0,
+ ip6_header_t *ip0, ip6_header_t *ip0_encap,
+ u8 policy_type)
{
u32 new_l0;
u32 flow_label;
vlib_prefetch_buffer_header (p6, LOAD);
vlib_prefetch_buffer_header (p7, LOAD);
- CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE);
+ clib_prefetch_store (p4->data);
+ clib_prefetch_store (p5->data);
+ clib_prefetch_store (p6->data);
+ clib_prefetch_store (p7->data);
}
to_next[0] = bi0 = from[0];
ip2 = vlib_buffer_get_current (b2);
ip3 = vlib_buffer_get_current (b3);
- encaps_processing_v6 (node, b0, ip0, ip0_encap);
- encaps_processing_v6 (node, b1, ip1, ip1_encap);
- encaps_processing_v6 (node, b2, ip2, ip2_encap);
- encaps_processing_v6 (node, b3, ip3, ip3_encap);
+ encaps_processing_v6 (node, b0, ip0, ip0_encap, sl0->policy_type);
+ encaps_processing_v6 (node, b1, ip1, ip1_encap, sl1->policy_type);
+ encaps_processing_v6 (node, b2, ip2, ip2_encap, sl2->policy_type);
+ encaps_processing_v6 (node, b3, ip3, ip3_encap, sl3->policy_type);
vnet_buffer (b0)->sw_if_index[VLIB_TX] = sl0->egress_fib_table;
vnet_buffer (b1)->sw_if_index[VLIB_TX] = sl1->egress_fib_table;
ip0 = vlib_buffer_get_current (b0);
- encaps_processing_v6 (node, b0, ip0, ip0_encap);
+ encaps_processing_v6 (node, b0, ip0, ip0_encap, sl0->policy_type);
vnet_buffer (b0)->sw_if_index[VLIB_TX] = sl0->egress_fib_table;
vlib_prefetch_buffer_header (p6, LOAD);
vlib_prefetch_buffer_header (p7, LOAD);
- CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE);
+ clib_prefetch_store (p4->data);
+ clib_prefetch_store (p5->data);
+ clib_prefetch_store (p6->data);
+ clib_prefetch_store (p7->data);
}
to_next[0] = bi0 = from[0];
vlib_prefetch_buffer_header (p6, LOAD);
vlib_prefetch_buffer_header (p7, LOAD);
- CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE);
+ clib_prefetch_store (p4->data);
+ clib_prefetch_store (p5->data);
+ clib_prefetch_store (p6->data);
+ clib_prefetch_store (p7->data);
}
to_next[0] = bi0 = from[0];
vlib_prefetch_buffer_header (p6, LOAD);
vlib_prefetch_buffer_header (p7, LOAD);
- CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE);
+ clib_prefetch_store (p4->data);
+ clib_prefetch_store (p5->data);
+ clib_prefetch_store (p6->data);
+ clib_prefetch_store (p7->data);
}
to_next[0] = bi0 = from[0];
vlib_prefetch_buffer_header (p6, LOAD);
vlib_prefetch_buffer_header (p7, LOAD);
- CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE);
+ clib_prefetch_store (p4->data);
+ clib_prefetch_store (p5->data);
+ clib_prefetch_store (p6->data);
+ clib_prefetch_store (p7->data);
}
to_next[0] = bi0 = from[0];
* @brief Function BSID encapsulation
*/
static_always_inline void
-end_bsid_encaps_srh_processing (vlib_node_runtime_t * node,
- vlib_buffer_t * b0,
- ip6_header_t * ip0,
- ip6_sr_header_t * sr0, u32 * next0)
+end_bsid_encaps_srh_processing (vlib_node_runtime_t *node, vlib_buffer_t *b0,
+ ip6_header_t *ip0, ip6_sr_header_t *sr0,
+ u32 *next0, u8 policy_type)
{
ip6_address_t *new_dst0;
vlib_prefetch_buffer_header (p6, LOAD);
vlib_prefetch_buffer_header (p7, LOAD);
- CLIB_PREFETCH (p4->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p5->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p6->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p7->data, CLIB_CACHE_LINE_BYTES, STORE);
+ clib_prefetch_store (p4->data);
+ clib_prefetch_store (p5->data);
+ clib_prefetch_store (p6->data);
+ clib_prefetch_store (p7->data);
}
to_next[0] = bi0 = from[0];
ip6_ext_header_find (vm, b3, ip3_encap, IP_PROTOCOL_IPV6_ROUTE,
NULL);
- end_bsid_encaps_srh_processing (node, b0, ip0_encap, sr0, &next0);
- end_bsid_encaps_srh_processing (node, b1, ip1_encap, sr1, &next1);
- end_bsid_encaps_srh_processing (node, b2, ip2_encap, sr2, &next2);
- end_bsid_encaps_srh_processing (node, b3, ip3_encap, sr3, &next3);
+ end_bsid_encaps_srh_processing (node, b0, ip0_encap, sr0, &next0,
+ sl0->policy_type);
+ end_bsid_encaps_srh_processing (node, b1, ip1_encap, sr1, &next1,
+ sl1->policy_type);
+ end_bsid_encaps_srh_processing (node, b2, ip2_encap, sr2, &next2,
+ sl2->policy_type);
+ end_bsid_encaps_srh_processing (node, b3, ip3_encap, sr3, &next3,
+ sl3->policy_type);
clib_memcpy_fast (((u8 *) ip0_encap) - vec_len (sl0->rewrite),
sl0->rewrite, vec_len (sl0->rewrite));
ip2 = vlib_buffer_get_current (b2);
ip3 = vlib_buffer_get_current (b3);
- encaps_processing_v6 (node, b0, ip0, ip0_encap);
- encaps_processing_v6 (node, b1, ip1, ip1_encap);
- encaps_processing_v6 (node, b2, ip2, ip2_encap);
- encaps_processing_v6 (node, b3, ip3, ip3_encap);
+ encaps_processing_v6 (node, b0, ip0, ip0_encap, sl0->policy_type);
+ encaps_processing_v6 (node, b1, ip1, ip1_encap, sl1->policy_type);
+ encaps_processing_v6 (node, b2, ip2, ip2_encap, sl2->policy_type);
+ encaps_processing_v6 (node, b3, ip3, ip3_encap, sl3->policy_type);
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
{
sr0 =
ip6_ext_header_find (vm, b0, ip0_encap, IP_PROTOCOL_IPV6_ROUTE,
NULL);
- end_bsid_encaps_srh_processing (node, b0, ip0_encap, sr0, &next0);
+ end_bsid_encaps_srh_processing (node, b0, ip0_encap, sr0, &next0,
+ sl0->policy_type);
clib_memcpy_fast (((u8 *) ip0_encap) - vec_len (sl0->rewrite),
sl0->rewrite, vec_len (sl0->rewrite));
ip0 = vlib_buffer_get_current (b0);
- encaps_processing_v6 (node, b0, ip0, ip0_encap);
+ encaps_processing_v6 (node, b0, ip0, ip0_encap, sl0->policy_type);
if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))