diff options
author | shwethab <shwetha.bhandari@gmail.com> | 2017-03-09 16:58:26 +0000 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2017-03-14 12:04:50 +0000 |
commit | e146f13fa0c315c41b8172b5f7bb65dfd612c325 (patch) | |
tree | b41490fdf768018d9422dc92b9e52292fccd7f95 /src/vnet/sr | |
parent | 20e272c8fce5571122ca149526ee8ddf6f43ee3f (diff) |
ioam: ip6 hop by hop ext header and SR header co-existence
1. Fix finding sr extension header
2. Fix for assert checks for space for sr header in packet headroom
3. ioam build warnings
4. Fix for SR header removal in presence of hbh ext header
clib_memcpy with overlapping src/dst was failing
Change-Id: I8576204eb571d1d4725a4e6976e18fe61cd1cd35
Signed-off-by: shwethab <shwetha.bhandari@gmail.com>
Diffstat (limited to 'src/vnet/sr')
-rwxr-xr-x | src/vnet/sr/sr.h | 2 | ||||
-rwxr-xr-x | src/vnet/sr/sr_localsid.c | 24 | ||||
-rwxr-xr-x | src/vnet/sr/sr_policy_rewrite.c | 128 |
3 files changed, 83 insertions, 71 deletions
diff --git a/src/vnet/sr/sr.h b/src/vnet/sr/sr.h index 1545a84f38b..5efeb4dd06a 100755 --- a/src/vnet/sr/sr.h +++ b/src/vnet/sr/sr.h @@ -297,7 +297,7 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, * @return precomputed rewrite string for SRH insertion */ static inline u8 * -ip6_compute_rewrite_string_insert (ip6_address_t * sl) +ip6_sr_compute_rewrite_string_insert (ip6_address_t * sl) { ip6_sr_header_t *srh; ip6_address_t *addrp, *this_address; diff --git a/src/vnet/sr/sr_localsid.c b/src/vnet/sr/sr_localsid.c index 407491ce19f..610bb7ffbea 100755 --- a/src/vnet/sr/sr_localsid.c +++ b/src/vnet/sr/sr_localsid.c @@ -827,6 +827,9 @@ end_psp_srh_processing (vlib_node_runtime_t * node, ip6_sr_localsid_t * ls0, u32 * next0) { u32 new_l0, sr_len; + u64 *copy_dst0, *copy_src0; + u32 copy_len_u64s0 = 0; + int i; if (PREDICT_TRUE (sr0->type == ROUTING_HEADER_TYPE_SR)) { @@ -845,8 +848,25 @@ end_psp_srh_processing (vlib_node_runtime_t * node, vlib_buffer_advance (b0, sr_len); new_l0 = clib_net_to_host_u16 (ip0->payload_length) - sr_len; ip0->payload_length = clib_host_to_net_u16 (new_l0); - clib_memcpy ((void *) ip0 + sr_len, ip0, - (void *) sr0 - (void *) ip0); + copy_src0 = (u64 *) ip0; + copy_dst0 = copy_src0 + (sr0->length + 1); + /* number of 8 octet units to copy + * By default in absence of extension headers it is equal to length of ip6 header + * With extension headers it number of 8 octet units of ext headers preceding + * SR header + */ + copy_len_u64s0 = + (((u8 *) sr0 - (u8 *) ip0) - sizeof (ip6_header_t)) >> 3; + copy_dst0[4 + copy_len_u64s0] = copy_src0[4 + copy_len_u64s0]; + copy_dst0[3 + copy_len_u64s0] = copy_src0[3 + copy_len_u64s0]; + copy_dst0[2 + copy_len_u64s0] = copy_src0[2 + copy_len_u64s0]; + copy_dst0[1 + copy_len_u64s0] = copy_src0[1 + copy_len_u64s0]; + copy_dst0[0 + copy_len_u64s0] = copy_src0[0 + copy_len_u64s0]; + + for (i = copy_len_u64s0 - 1; i >= 0; i--) + { + copy_dst0[i] = copy_src0[i]; + } if (ls0->behavior == SR_BEHAVIOR_X) { diff --git a/src/vnet/sr/sr_policy_rewrite.c b/src/vnet/sr/sr_policy_rewrite.c index 1f8bdca5143..dfdd7950597 100755 --- a/src/vnet/sr/sr_policy_rewrite.c +++ b/src/vnet/sr/sr_policy_rewrite.c @@ -1147,14 +1147,14 @@ sr_policy_rewrite_encaps (vlib_main_t * vm, vlib_node_runtime_t * node, pool_elt_at_index (sm->sid_lists, vnet_buffer (b3)->ip.adj_index[VLIB_TX]); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl1->rewrite) + b1->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl2->rewrite) + b2->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl3->rewrite) + b3->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); + ASSERT (b1->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl1->rewrite)); + ASSERT (b2->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl2->rewrite)); + ASSERT (b3->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl3->rewrite)); ip0_encap = vlib_buffer_get_current (b0); ip1_encap = vlib_buffer_get_current (b1); @@ -1254,9 +1254,8 @@ sr_policy_rewrite_encaps (vlib_main_t * vm, vlib_node_runtime_t * node, sl0 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); ip0_encap = vlib_buffer_get_current (b0); @@ -1426,15 +1425,14 @@ sr_policy_rewrite_encaps_v4 (vlib_main_t * vm, vlib_node_runtime_t * node, sl3 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b3)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl1->rewrite) + b1->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl2->rewrite) + b2->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl3->rewrite) + b3->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); + ASSERT (b1->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl1->rewrite)); + ASSERT (b2->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl2->rewrite)); + ASSERT (b3->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl3->rewrite)); ip0_encap = vlib_buffer_get_current (b0); ip1_encap = vlib_buffer_get_current (b1); @@ -1535,9 +1533,8 @@ sr_policy_rewrite_encaps_v4 (vlib_main_t * vm, vlib_node_runtime_t * node, sl0 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); ip0_encap = vlib_buffer_get_current (b0); @@ -1785,14 +1782,14 @@ sr_policy_rewrite_encaps_l2 (vlib_main_t * vm, vlib_node_runtime_t * node, pool_elt_at_index (sm->sid_lists, vnet_buffer (b3)->ip.adj_index[VLIB_TX]); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl1->rewrite) + b1->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl2->rewrite) + b2->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl3->rewrite) + b3->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); + ASSERT (b1->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl1->rewrite)); + ASSERT (b2->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl2->rewrite)); + ASSERT (b3->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl3->rewrite)); en0 = vlib_buffer_get_current (b0); en1 = vlib_buffer_get_current (b1); @@ -1926,9 +1923,8 @@ sr_policy_rewrite_encaps_l2 (vlib_main_t * vm, vlib_node_runtime_t * node, sl0 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); en0 = vlib_buffer_get_current (b0); @@ -2075,15 +2071,14 @@ sr_policy_rewrite_insert (vlib_main_t * vm, vlib_node_runtime_t * node, sl3 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b3)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl1->rewrite) + b1->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl2->rewrite) + b2->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl3->rewrite) + b3->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); + ASSERT (b1->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl1->rewrite)); + ASSERT (b2->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl2->rewrite)); + ASSERT (b3->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl3->rewrite)); ip0 = vlib_buffer_get_current (b0); ip1 = vlib_buffer_get_current (b1); @@ -2321,8 +2316,8 @@ sr_policy_rewrite_insert (vlib_main_t * vm, vlib_node_runtime_t * node, sl0 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); ip0 = vlib_buffer_get_current (b0); @@ -2498,15 +2493,14 @@ sr_policy_rewrite_b_insert (vlib_main_t * vm, vlib_node_runtime_t * node, sl3 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b3)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite_bsid) + b0->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl1->rewrite_bsid) + b1->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl2->rewrite_bsid) + b2->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl3->rewrite_bsid) + b3->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite_bsid)); + ASSERT (b1->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl1->rewrite_bsid)); + ASSERT (b2->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl2->rewrite_bsid)); + ASSERT (b3->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl3->rewrite_bsid)); ip0 = vlib_buffer_get_current (b0); ip1 = vlib_buffer_get_current (b1); @@ -2735,8 +2729,8 @@ sr_policy_rewrite_b_insert (vlib_main_t * vm, vlib_node_runtime_t * node, sl0 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite_bsid) + b0->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite_bsid)); ip0 = vlib_buffer_get_current (b0); @@ -2943,15 +2937,14 @@ sr_policy_rewrite_b_encaps (vlib_main_t * vm, vlib_node_runtime_t * node, sl3 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b3)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl1->rewrite) + b1->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl2->rewrite) + b2->current_data)); - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl3->rewrite) + b3->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); + ASSERT (b1->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl1->rewrite)); + ASSERT (b2->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl2->rewrite)); + ASSERT (b3->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl3->rewrite)); ip0_encap = vlib_buffer_get_current (b0); ip1_encap = vlib_buffer_get_current (b1); @@ -3067,9 +3060,8 @@ sr_policy_rewrite_b_encaps (vlib_main_t * vm, vlib_node_runtime_t * node, sl0 = pool_elt_at_index (sm->sid_lists, vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - - ASSERT (VLIB_BUFFER_PRE_DATA_SIZE >= - (vec_len (sl0->rewrite) + b0->current_data)); + ASSERT (b0->current_data + VLIB_BUFFER_PRE_DATA_SIZE >= + vec_len (sl0->rewrite)); ip0_encap = vlib_buffer_get_current (b0); ip6_ext_header_find_t (ip0_encap, prev0, sr0, |