diff options
author | Michele Papalini <micpapal@cisco.com> | 2023-01-23 16:55:38 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2023-01-23 16:55:38 +0000 |
commit | 677eedc91dc5c048ed94fb9bb5d0074f8712e476 (patch) | |
tree | c594058b99bde5cf371b40875a1d2594714c3e57 | |
parent | 5c55c05438d881a138c66e4f3ad8021cd6aa0130 (diff) | |
parent | 4ec2784197db60e4f287a88b7944ecb1067bfc08 (diff) |
Merge "feat(hicn-plugin): reuse strategy node to forward interests" into stable/2210
-rw-r--r-- | hicn-plugin/src/interest_hitpit_node.c | 182 | ||||
-rw-r--r-- | hicn-plugin/src/interest_pcslookup_node.c | 82 | ||||
-rw-r--r-- | hicn-plugin/src/strategy_node.c | 2 | ||||
-rw-r--r-- | tests/functional-tests/2-nodes-vpp-memif-local-remote.robot | 21 |
4 files changed, 91 insertions, 196 deletions
diff --git a/hicn-plugin/src/interest_hitpit_node.c b/hicn-plugin/src/interest_hitpit_node.c index 0b09711f7..fb2393f54 100644 --- a/hicn-plugin/src/interest_hitpit_node.c +++ b/hicn-plugin/src/interest_hitpit_node.c @@ -38,8 +38,6 @@ static char *hicn_interest_hitpit_error_strings[] = { vlib_node_registration_t hicn_interest_hitpit_node; -always_inline void drop_packet (u32 *next0); - /* * hICN forwarder node for interests hitting the PIT */ @@ -47,7 +45,6 @@ static uword hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) { - int ret; u32 n_left_from, *from, *to_next; hicn_interest_hitpit_next_t next_index; hicn_interest_hitpit_runtime_t *rt; @@ -62,9 +59,6 @@ hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, const hicn_dpo_vft_t *dpo_vft0; u8 dpo_ctx_id0; u8 forward = 0; - hicn_face_id_t outfaces[MAX_OUT_FACES]; - u32 clones[MAX_OUT_FACES]; - u16 outfaces_len; u32 pit_entry_index; hicn_pcs_entry_t *pcs_entry = NULL; hicn_buffer_t *hicnb0; @@ -119,152 +113,56 @@ hicn_interest_hitpit_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, // Increment packet counter stats.pkts_processed += 1; - // If the entry is expired, remove it no matter of the possible - // cases. - if (tnow > hicn_pcs_entry_get_expire_time (pcs_entry)) + // A data packet may have arrived in the time between the pcs + // lookup and now. Check again to make sure the entry is CS or + // PIT + if (hicn_pcs_entry_is_cs (pcs_entry)) { - // Notify strategy - strategy_vft0->hicn_on_interest_timeout (dpo_ctx_id0); - - // Release lock on entry - this MUST delete the entry - hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry); - - stats.pit_expired_count++; - - // Forward to strategy node - // TODO this can be simplified by checking directly in the - // pcslookup node! - next0 = HICN_INTEREST_HITPIT_NEXT_STRATEGY; + next0 = HICN_INTEREST_HITPIT_NEXT_INTEREST_HITCS; } else { - // A data packet may have arrived in the time between the pcs - // lookup and now. Check again to make sure the entry is CS or - // PIT - if (hicn_pcs_entry_is_cs (pcs_entry)) + // Distinguish between aggregation, retransmission and + // additionally check if the strategy mandates to always send + // the interest + + // Retransmission + forward = hicn_pcs_entry_pit_search (pcs_entry, hicnb0->face_id); + + // Strategy mandates to force send after aggregation + if (!forward && strategy_vft0->hicn_send_after_aggregation ( + dpo_ctx_id0, hicnb0->face_id)) + { + forward = true; + hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); + } + + if (forward && hicnb0->payload_type != HPT_MANIFEST) { - next0 = HICN_INTEREST_HITPIT_NEXT_INTEREST_HITCS; + next0 = HICN_INTEREST_HITPIT_NEXT_STRATEGY; } else { - // Distinguish between aggregation, retransmission and - // additionally check if the strategy mandates to always send - // the interest - - // Retransmission - forward = - hicn_pcs_entry_pit_search (pcs_entry, hicnb0->face_id); - - // Strategy mandates to force send after aggregation - if (!forward && strategy_vft0->hicn_send_after_aggregation ( - dpo_ctx_id0, hicnb0->face_id)) - { - forward = true; - hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); - } - - if (forward && hicnb0->payload_type != HPT_MANIFEST) - { - // Send interest - strategy_vft0->hicn_select_next_hop ( - dpo_ctx_id0, hicnb0->face_id, outfaces, &outfaces_len); - - // If no next hops, drop the packet - if (outfaces_len == 0) - { - drop_packet (&next0); - vlib_validate_buffer_enqueue_x1 ( - vm, node, next_index, to_next, n_left_to_next, bi0, - next0); - continue; - } - - // Prepare the packet for the forwarding - next0 = isv6 ? HICN_INTEREST_HITPIT_NEXT_FACE6_OUTPUT : - HICN_INTEREST_HITPIT_NEXT_FACE4_OUTPUT; + // Aggregation + hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); - // Update stats - stats.interests_retx += outfaces_len; + next0 = HICN_INTEREST_HITPIT_NEXT_ERROR_DROP; - // Clone interest if needed - if (outfaces_len > 1) - { - ret = vlib_buffer_clone (vm, bi0, clones, - (u16) outfaces_len, - CLIB_CACHE_LINE_BYTES * 2); - ASSERT (ret == outfaces_len); - } - else - { - clones[0] = bi0; - } - - // We need to clone the packet over multiple output - // faces - - // Restore pointers - to_next -= 1; - n_left_to_next += 1; - - for (u32 nh = 0; nh < outfaces_len; nh++) - { - vlib_buffer_t *local_b0 = - vlib_get_buffer (vm, clones[nh]); - to_next[0] = clones[nh]; - to_next += 1; - n_left_to_next -= 1; - - vnet_buffer (local_b0)->ip.adj_index[VLIB_TX] = - outfaces[nh]; - - /* Maybe trace */ - if (PREDICT_FALSE ( - (node->flags & VLIB_NODE_FLAG_TRACE) && - (local_b0->flags & VLIB_BUFFER_IS_TRACED))) - { - hicn_interest_hitpit_trace_t *t = - vlib_add_trace (vm, node, local_b0, - sizeof (*t)); - t->pkt_type = HICN_PACKET_TYPE_INTEREST; - t->sw_if_index = - vnet_buffer (local_b0)->sw_if_index[VLIB_RX]; - t->next_index = next0; - } - - /* - * Verify speculative enqueue, maybe switch - * current next frame - */ - vlib_validate_buffer_enqueue_x1 ( - vm, node, next_index, to_next, n_left_to_next, - clones[nh], next0); - } - continue; - } - else - { - // Aggregation - hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); - - drop_packet (&next0); - stats.interests_aggregated++; - - /* Maybe trace */ - if (PREDICT_FALSE ( - (node->flags & VLIB_NODE_FLAG_TRACE) && - (b0->flags & VLIB_BUFFER_IS_TRACED))) - { - hicn_interest_hitpit_trace_t *t = - vlib_add_trace (vm, node, b0, sizeof (*t)); - t->pkt_type = HICN_PACKET_TYPE_INTEREST; - t->sw_if_index = - vnet_buffer (b0)->sw_if_index[VLIB_RX]; - t->next_index = next0; - } - } + stats.interests_aggregated++; } } + /* Maybe trace */ + if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && + (b0->flags & VLIB_BUFFER_IS_TRACED))) + { + hicn_interest_hitpit_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->pkt_type = HICN_PACKET_TYPE_INTEREST; + t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->next_index = next0; + } + /* * Verify speculative enqueue, maybe switch current * next frame @@ -311,12 +209,6 @@ hicn_interest_hitpit_format_trace (u8 *s, va_list *args) return (s); } -void -drop_packet (u32 *next0) -{ - *next0 = HICN_INTEREST_HITPIT_NEXT_ERROR_DROP; -} - /* * Node registration for the interest forwarder node */ diff --git a/hicn-plugin/src/interest_pcslookup_node.c b/hicn-plugin/src/interest_pcslookup_node.c index a0b2ee3f0..e8aad4a83 100644 --- a/hicn-plugin/src/interest_pcslookup_node.c +++ b/hicn-plugin/src/interest_pcslookup_node.c @@ -80,6 +80,7 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm, hicn_pcs_entry_t *pcs_entry = NULL; f64 tnow; hicn_buffer_t *hicnb0; + const hicn_strategy_vft_t *strategy; rt = vlib_node_get_runtime_data (vm, hicn_interest_pcslookup_node.index); @@ -132,49 +133,72 @@ hicn_interest_pcslookup_node_inline (vlib_main_t *vm, if (ret == HICN_ERROR_NONE) { - // We found an entry in the PCS. Next stage for this packet is - // one of hitpit/cs nodes - next0 = HICN_INTEREST_PCSLOOKUP_NEXT_INTEREST_HITPIT + - hicn_pcs_entry_is_cs (pcs_entry); - + // We found an entry in the PCS. ret = hicn_store_internal_state ( b0, hicn_pcs_entry_get_index (rt->pitcs, pcs_entry), vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) - next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; - } - else - { - // No entry in PCS. Let's create one now - pcs_entry = hicn_pcs_entry_pit_get ( - rt->pitcs, tnow, hicn_buffer_get_lifetime (b0)); + // Make sure the entry is not expired first + if (tnow > hicn_pcs_entry_get_expire_time (pcs_entry)) + { + // Notify strategy + strategy = hicn_dpo_get_strategy_vft (hicnb0->vft_id); + strategy->hicn_on_interest_timeout ( + vnet_buffer (b0)->ip.adj_index[VLIB_TX]); - ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &name); + // Release lock on entry - this MUST delete the entry + hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry); - if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) + stats.pit_expired_count++; + + // Forward to strategy node + // TODO this can be simplified by checking directly in the + // pcslookup node! + next0 = HICN_INTEREST_PCSLOOKUP_NEXT_STRATEGY; + + goto newentry; + } + else { - next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; + // Next stage for this packet is one of hitpit/cs nodes + next0 = HICN_INTEREST_PCSLOOKUP_NEXT_INTEREST_HITPIT + + hicn_pcs_entry_is_cs (pcs_entry); + + if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) + next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; + goto end; } + } + newentry: + // No entry in PCS. Let's create one now + pcs_entry = hicn_pcs_entry_pit_get (rt->pitcs, tnow, + hicn_buffer_get_lifetime (b0)); - // Store internal state - ret = hicn_store_internal_state ( - b0, hicn_pcs_entry_get_index (rt->pitcs, pcs_entry), - vnet_buffer (b0)->ip.adj_index[VLIB_TX]); + ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &name); - if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) - { - hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry); - drop_packet (vm, bi0, &n_left_from, &next0, &to_next, - &next_index, node); - continue; - } + if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) + { + next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP; + goto end; + } - // Add face - hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); + // Store internal state + ret = hicn_store_internal_state ( + b0, hicn_pcs_entry_get_index (rt->pitcs, pcs_entry), + vnet_buffer (b0)->ip.adj_index[VLIB_TX]); + + if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) + { + hicn_pcs_entry_remove_lock (rt->pitcs, pcs_entry); + drop_packet (vm, bi0, &n_left_from, &next0, &to_next, + &next_index, node); + continue; } + // Add face + hicn_pcs_entry_pit_add_face (pcs_entry, hicnb0->face_id); + end: stats.pkts_interest_count++; diff --git a/hicn-plugin/src/strategy_node.c b/hicn-plugin/src/strategy_node.c index 9c1a484d6..add5772a4 100644 --- a/hicn-plugin/src/strategy_node.c +++ b/hicn-plugin/src/strategy_node.c @@ -155,7 +155,7 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node, if (PREDICT_FALSE (ret != HICN_ERROR_NONE || outfaces_len == 0)) { - drop_packet (vm, bi0, &n_left_from, &next0, &to_next, + drop_packet (vm, bi0, &n_left_to_next, &next0, &to_next, &next_index, node); continue; } diff --git a/tests/functional-tests/2-nodes-vpp-memif-local-remote.robot b/tests/functional-tests/2-nodes-vpp-memif-local-remote.robot deleted file mode 100644 index 31f5143ea..000000000 --- a/tests/functional-tests/2-nodes-vpp-memif-local-remote.robot +++ /dev/null @@ -1,21 +0,0 @@ -*** Settings *** -Resource ../resources/libraries/robot/runtest.robot -Resource ../resources/libraries/robot/common.robot - -Suite Setup Run Keywords -... Build Topology -... 2-nodes -... vpp-memif-local-remote -... AND -... Check Environment -Suite Teardown Run Keywords -... Destroy Topology - - -*** Test Cases *** -Test traffic received from local face is forwarded to remote face - Log to console Test traffic received from local face is forwarded to remote face - ${result} = Run Process bash -x ${EXECDIR}/config.sh localremote - Log Many - ... stdout: ${result.stdout} - ... stderr: ${result.stderr} |