From 6d22a0db96aa7f8e3102ae44d00c09e36a2e9c57 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 4 Aug 2022 16:06:34 +0200 Subject: feat: Due to the deep modifications related to names and packet format, this task cover a large part of the codebase and involves several changes: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - the library provides a name data structure (hicn_name_t ), which is composed of a name prefix (hicn_name_prefix_t) and a name suffix (hicn_name_suffix_t), and it has been extended to provide all support functions required for name manipulation, including common prefix computation, as required for the Longest Prefix Match (LPM)in the forwarder, in addition to Exact Prefix Match (EPM). - all code has been rewritten to use this data structure instead of having for instance the forwarder define its own name class (used to be Name and NameBitVector) the code has been refactored to minimize name allocations and copies, one remaining aspect is the difference of name storage between PIT and CS entries (respectively in the PIT entry, and in the message buffer), which causes the packet cache index to be updated when a PIT entry is converted into a CS entry. By storing the name in the PIT/CS entry everytime, we might save on this operation). - hicn-light FIB has been rewritten : code has been refactored and should now be shorter and documented; unit tests have been drafted but more would be required to cover all cases and match the algorithms to add/remove nodes, as specified in the doc. all protocol details and hICN header formats are now abstracted by the library for the forwarder (and thus header.h and  protocols/*.h have been removed from public includes, and replaced by packet.h providing protocol agnostic packet level functions, completely replacing the compat.h header that used to provide similar functions. - this works by exposing a opaque buffer to the application (a kind of socket buffer) which is used by the lib to cache the packet format and offsets of the different layers in the buffer and provider efficient operations (the packet format is either defined for packet construction, or guessed at ingress, and this structure is updated accordingly only once). Co-authored-by: Jordan Augé Signed-off-by: Luca Muscariello Change-Id: I31e321897f85f0267fe8ba4720363c180564492f --- hicn-plugin/src/CMakeLists.txt | 4 +- hicn-plugin/src/data_fwd_node.c | 11 ++-- hicn-plugin/src/data_pcslookup_node.c | 9 +-- hicn-plugin/src/faces/app/face_prod.c | 3 +- hicn-plugin/src/faces/app/face_prod_node.c | 26 ++++----- hicn-plugin/src/faces/face.c | 3 - hicn-plugin/src/faces/face_node.c | 24 ++++---- hicn-plugin/src/faces/iface_node.c | 46 +++++++++------ hicn-plugin/src/hicn.h | 44 +++++++------- hicn-plugin/src/interest_pcslookup_node.c | 10 ++-- hicn-plugin/src/mapme_ack_node.c | 2 +- hicn-plugin/src/mapme_ctrl_node.c | 2 +- hicn-plugin/src/mapme_eventmgr.c | 21 ++++--- hicn-plugin/src/parser.h | 81 ++++++++++--------------- hicn-plugin/src/pcs.h | 4 +- hicn-plugin/src/pg.c | 58 +++++++++++++++++- hicn-plugin/src/pg_node.c | 94 +++++++++++++++++------------- hicn-plugin/src/strategy_node.c | 9 ++- 18 files changed, 258 insertions(+), 193 deletions(-) (limited to 'hicn-plugin') diff --git a/hicn-plugin/src/CMakeLists.txt b/hicn-plugin/src/CMakeLists.txt index d232b4ab1..3b89e4b53 100644 --- a/hicn-plugin/src/CMakeLists.txt +++ b/hicn-plugin/src/CMakeLists.txt @@ -180,7 +180,7 @@ set(COMPILE_DEFINITIONS if (${CMAKE_BUILD_TYPE} MATCHES "Debug") list(APPEND COMPILE_DEFINITIONS "-DHICN_DDEBUG" - "-DCLIB_DEBUG" + # "-DCLIB_DEBUG" ) endif() @@ -249,4 +249,4 @@ build_module(${HICN_API_TEST_PLUGIN} ############################################################## if (${BUILD_TESTS}) add_subdirectory(test) -endif() \ No newline at end of file +endif() diff --git a/hicn-plugin/src/data_fwd_node.c b/hicn-plugin/src/data_fwd_node.c index f909ae536..981dc2c5e 100644 --- a/hicn-plugin/src/data_fwd_node.c +++ b/hicn-plugin/src/data_fwd_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -253,8 +253,7 @@ hicn_satisfy_faces (vlib_main_t *vm, u32 bi0, hicn_pcs_entry_t *pitp, always_inline void clone_data_to_cs (hicn_pit_cs_t *pitcs, hicn_pcs_entry_t *pcs_entry, - u32 buffer_index, hicn_header_t *hicn0, f64 tnow, - hicn_lifetime_t dmsg_lifetime) + u32 buffer_index, f64 tnow, hicn_lifetime_t dmsg_lifetime) { /* * At this point we think we're safe to proceed. Store the CS buf in @@ -314,7 +313,6 @@ hicn_data_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, u8 isv6; u32 bi0; u32 next0 = HICN_DATA_FWD_NEXT_ERROR_DROP; - hicn_header_t *hicn0; hicn_buffer_t *hicnb0; const hicn_strategy_vft_t *strategy_vft0 = NULL; const hicn_dpo_vft_t *dpo_vft0; @@ -364,7 +362,6 @@ hicn_data_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, // Get hicn buffer and state hicnb0 = hicn_get_buffer (b0); - hicn0 = (hicn_header_t *) (vlib_buffer_get_current (b0)); hicn_get_internal_state (hicnb0, &pcs_entry_id, &strategy_vft0, &dpo_vft0, &dpo_ctx_id0); @@ -442,7 +439,7 @@ hicn_data_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, { // Clone data packet in the content store and convert the PIT // entry into a CS entry - clone_data_to_cs (rt->pitcs, pcs_entry, bi0, hicn0, tnow, + clone_data_to_cs (rt->pitcs, pcs_entry, bi0, tnow, dmsg_lifetime); } else @@ -520,4 +517,4 @@ VLIB_REGISTER_NODE(hicn_data_fwd_node) = * fd.io coding-style-patch-verification: ON * * Local Variables: eval: (c-set-style "gnu") End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/data_pcslookup_node.c b/hicn-plugin/src/data_pcslookup_node.c index 55ddda9c4..5ae6958f5 100644 --- a/hicn-plugin/src/data_pcslookup_node.c +++ b/hicn-plugin/src/data_pcslookup_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -97,8 +97,9 @@ hicn_data_pcslookup_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, stats.pkts_data_count += 1; // Lookup the name in the PIT - ret = hicn_pcs_lookup_one (rt->pitcs, hicn_buffer_get_name (b0), - &pcs_entry); + hicn_name_t name; + hicn_packet_get_name (&hicn_get_buffer (b0)->pkbuf, &name); + ret = hicn_pcs_lookup_one (rt->pitcs, &name, &pcs_entry); if (ret == HICN_ERROR_NONE) { @@ -197,4 +198,4 @@ VLIB_REGISTER_NODE(hicn_data_pcslookup_node) = * fd.io coding-style-patch-verification: ON * * Local Variables: eval: (c-set-style "gnu") End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c index 1e569b82b..73e2a1262 100644 --- a/hicn-plugin/src/faces/app/face_prod.c +++ b/hicn-plugin/src/faces/app/face_prod.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -285,6 +285,7 @@ hicn_face_prod_add (fib_prefix_t *prefix, u32 sw_if, u32 *cs_reserved, } face = hicn_face_get (&local_app_ip, sw_if, &hicn_face_hashtb, adj_index); + assert (face); *faceid = hicn_dpoi_get_index (face); diff --git a/hicn-plugin/src/faces/app/face_prod_node.c b/hicn-plugin/src/faces/app/face_prod_node.c index 8adb7dce7..93e80d1ac 100644 --- a/hicn-plugin/src/faces/app/face_prod_node.c +++ b/hicn-plugin/src/faces/app/face_prod_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -100,16 +100,16 @@ match_ip6_name (u8 *name, const fib_prefix_t *prefix) } static_always_inline u32 -hicn_face_prod_next_from_data_hdr (vlib_buffer_t *b) +hicn_face_prod_next_from_data_hdr (vlib_main_t *vm, vlib_buffer_t *b) { u8 is_v6; int match_res = 1; int ret = 0; - hicn_name_t *name; + hicn_name_t name; hicn_face_prod_state_t *prod_face = NULL; // 1 - ensure the packet is hicn and its format is correct - ret = hicn_data_parse_pkt (b); + ret = hicn_data_parse_pkt (b, vlib_buffer_length_in_chain (vm, b)); if (PREDICT_FALSE (ret)) { return HICN_FACE_PROD_NEXT_ERROR_DROP; @@ -124,14 +124,14 @@ hicn_face_prod_next_from_data_hdr (vlib_buffer_t *b) // of this face const fib_prefix_t *prefix = &prod_face->prefix; is_v6 = hicn_buffer_is_v6 (b); - name = &hicn_get_buffer (b)->name; + hicn_packet_get_name (&hicn_get_buffer (b)->pkbuf, &name); if (PREDICT_TRUE (!is_v6 && ip46_address_is_ip4 (&prefix->fp_addr))) { - match_res = match_ip4_name (&name->prefix.ip4.as_u32, prefix); + match_res = match_ip4_name (&name.prefix.v4.as_u32, prefix); } else if (PREDICT_TRUE (is_v6 && !ip46_address_is_ip4 (&prefix->fp_addr))) { - match_res = match_ip6_name (name->prefix.ip6.as_u8, prefix); + match_res = match_ip6_name (name.prefix.v6.as_u8, prefix); } // 4 - if match found, forward data to next hicn node @@ -230,10 +230,10 @@ hicn_face_prod_input_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hicnb3->flags = HICN_FACE_FLAGS_DEFAULT; // parse packets and get next node - next0 = hicn_face_prod_next_from_data_hdr (b0); - next1 = hicn_face_prod_next_from_data_hdr (b1); - next2 = hicn_face_prod_next_from_data_hdr (b2); - next3 = hicn_face_prod_next_from_data_hdr (b3); + next0 = hicn_face_prod_next_from_data_hdr (vm, b0); + next1 = hicn_face_prod_next_from_data_hdr (vm, b1); + next2 = hicn_face_prod_next_from_data_hdr (vm, b2); + next3 = hicn_face_prod_next_from_data_hdr (vm, b3); stats.pkts_data_count += 4; // counters @@ -304,7 +304,7 @@ hicn_face_prod_input_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hicnb0 = hicn_get_buffer (b0); hicnb0->flags = HICN_FACE_FLAGS_DEFAULT; - next0 = hicn_face_prod_next_from_data_hdr (b0); + next0 = hicn_face_prod_next_from_data_hdr (vm, b0); stats.pkts_data_count++; // counters @@ -357,4 +357,4 @@ VLIB_REGISTER_NODE(hicn_face_prod_input_node) = * fd.io coding-style-patch-verification: ON * * Local Variables: eval: (c-set-style "gnu") End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c index 4ee1c283f..58c1c34c8 100644 --- a/hicn-plugin/src/faces/face.c +++ b/hicn-plugin/src/faces/face.c @@ -303,9 +303,6 @@ hicn_face_add (const dpo_id_t *dpo_nh, ip46_address_t *nat_address, int sw_if, hicn_face_id_t *pfaceid) { - hicn_face_flags_t flags = (hicn_face_flags_t) 0; - flags |= HICN_FACE_FLAGS_FACE; - hicn_face_t *face; face = diff --git a/hicn-plugin/src/faces/face_node.c b/hicn-plugin/src/faces/face_node.c index e2fb79d17..0d2e70fbe 100644 --- a/hicn-plugin/src/faces/face_node.c +++ b/hicn-plugin/src/faces/face_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -25,6 +25,9 @@ #include "../hicn.h" #include "../parser.h" +#include +#include + /** * @File * @@ -140,7 +143,7 @@ typedef enum ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current (b0); \ \ /* Parse packet and cache useful info in opaque2 */ \ - ret0 = hicn_data_parse_pkt (b0); \ + ret0 = hicn_data_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ is_icmp0 = ret0 == HICN_ERROR_PARSER_MAPME_PACKET; \ ret0 = (ret0 == HICN_ERROR_NONE) || \ (ret0 == HICN_ERROR_PARSER_MAPME_PACKET); \ @@ -235,8 +238,8 @@ typedef enum ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current (b1); \ \ /* Parse packet and cache useful info in opaque2 */ \ - ret0 = hicn_data_parse_pkt (b0); \ - ret1 = hicn_data_parse_pkt (b1); \ + ret0 = hicn_data_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ + ret1 = hicn_data_parse_pkt (b1, vlib_buffer_length_in_chain (vm, b1)); \ is_icmp0 = ret0 == HICN_ERROR_PARSER_MAPME_PACKET; \ is_icmp1 = ret1 == HICN_ERROR_PARSER_MAPME_PACKET; \ ret0 = (ret0 == HICN_ERROR_NONE) || \ @@ -545,18 +548,17 @@ hicn_face_rewrite_interest (vlib_main_t *vm, vlib_buffer_t *b0, * hicn_face_match_probe(b0, face, next)) */ /* return; */ - hicn_header_t *hicn = vlib_buffer_get_current (b0); + hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b0)->pkbuf; u8 is_v4 = ip46_address_is_ip4 (&face->nat_addr) && !ip6_address_is_loopback (&face->nat_addr.ip6); // hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data; - ip46_address_t temp_addr; - ip46_address_reset (&temp_addr); - hicn_type_t type = hicn_get_buffer (b0)->type; - int ret = hicn_ops_vft[type.l1]->rewrite_interest ( - type, &hicn->protocol, &face->nat_addr, &temp_addr); + hicn_ip_address_t temp_addr; + ip46_address_reset (&(temp_addr.as_ip46)); + hicn_ip_address_t *face_nat_addr = (hicn_ip_address_t *) &face->nat_addr; + int ret = hicn_interest_rewrite (pkbuf, face_nat_addr, &temp_addr); if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED) { ensure_offload_flags (b0, is_v4); @@ -887,4 +889,4 @@ VLIB_REGISTER_NODE (hicn6_face_output_node) = { * Local Variables: * eval: (c-set-style "gnu") * End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/faces/iface_node.c b/hicn-plugin/src/faces/iface_node.c index 2f651beb8..598a68db6 100644 --- a/hicn-plugin/src/faces/iface_node.c +++ b/hicn-plugin/src/faces/iface_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -21,6 +21,9 @@ #include "../cache_policies/cs_lru.h" #include "../parser.h" +#include +#include + /** * @File * @@ -200,7 +203,8 @@ typedef enum ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current (b0); \ \ /* Parse packet and cache useful info in opaque2 */ \ - ret0 = hicn_interest_parse_pkt (b0); \ + ret0 = \ + hicn_interest_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ is_icmp0 = (ret0 == HICN_ERROR_PARSER_MAPME_PACKET); \ ret0 = (ret0 == HICN_ERROR_NONE) || \ (ret0 == HICN_ERROR_PARSER_MAPME_PACKET); \ @@ -304,8 +308,10 @@ typedef enum stats.pkts_interest_count += 2; \ \ /* Parse packet and cache useful info in opaque2 */ \ - ret0 = hicn_interest_parse_pkt (b0); \ - ret1 = hicn_interest_parse_pkt (b1); \ + ret0 = \ + hicn_interest_parse_pkt (b0, vlib_buffer_length_in_chain (vm, b0)); \ + ret1 = \ + hicn_interest_parse_pkt (b1, vlib_buffer_length_in_chain (vm, b1)); \ is_icmp0 = ret0 == HICN_ERROR_PARSER_MAPME_PACKET; \ is_icmp1 = ret1 == HICN_ERROR_PARSER_MAPME_PACKET; \ ret0 = (ret0 == HICN_ERROR_NONE) || \ @@ -655,17 +661,19 @@ hicn_rewrite_iface_data4 (vlib_main_t *vm, vlib_buffer_t *b0, vnet_buffer (b0)->ip.adj_index[VLIB_TX] = iface->dpo.dpoi_index; *next = iface->dpo.dpoi_next_node; - hicn_header_t *hicn = vlib_buffer_get_current (b0); - ip46_address_t temp_addr; - ip46_address_reset (&temp_addr); - hicn_type_t type = hicn_get_buffer (b0)->type; + hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b0)->pkbuf; + + hicn_ip_address_t temp_addr; + ip46_address_reset (&(temp_addr.as_ip46)); + + hicn_ip_address_t *iface_nat_addr = (hicn_ip_address_t *) &(iface->nat_addr); + u8 flags = hicn_get_buffer (b0)->flags; u8 reset_pl = flags & HICN_BUFFER_FLAGS_FROM_CS; - ret = hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol, - &(iface->nat_addr), &(temp_addr), - iface->pl_id, reset_pl); + ret = hicn_data_rewrite (pkbuf, iface_nat_addr, &(temp_addr), iface->pl_id, + reset_pl); if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED) { @@ -693,17 +701,17 @@ hicn_rewrite_iface_data6 (vlib_main_t *vm, vlib_buffer_t *b0, vnet_buffer (b0)->ip.adj_index[VLIB_TX] = iface->dpo.dpoi_index; *next = iface->dpo.dpoi_next_node; - hicn_header_t *hicn = vlib_buffer_get_current (b0); + hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b0)->pkbuf; + + hicn_ip_address_t temp_addr; + ip46_address_reset (&(temp_addr.as_ip46)); - ip46_address_t temp_addr; - ip46_address_reset (&temp_addr); - hicn_type_t type = hicn_get_buffer (b0)->type; + hicn_ip_address_t *iface_nat_addr = (hicn_ip_address_t *) &(iface->nat_addr); u8 flags = hicn_get_buffer (b0)->flags; u8 reset_pl = flags & HICN_BUFFER_FLAGS_FROM_CS; - ret = hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol, - &(iface->nat_addr), &(temp_addr), - iface->pl_id, reset_pl); + ret = hicn_data_rewrite (pkbuf, iface_nat_addr, &(temp_addr), iface->pl_id, + reset_pl); if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED) { @@ -1007,4 +1015,4 @@ VLIB_REGISTER_NODE (hicn6_iface_output_node) = { * Local Variables: * eval: (c-set-style "gnu") * End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/hicn.h b/hicn-plugin/src/hicn.h index 3b197d6b4..9acd9662f 100644 --- a/hicn-plugin/src/hicn.h +++ b/hicn-plugin/src/hicn.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -16,20 +16,7 @@ #ifndef __HICN_H__ #define __HICN_H__ -#define ip_address_t hicn_ip_address_t -#define ip_address_cmp hicn_ip_address_cmp -#define ip_prefix_t hicn_ip_prefix_t -#define ip_prefix_cmp hicn_ip_prefix_cmp -#undef ip_prefix_len -#define ip_prefix_len hicn_ip_prefix_len #include -#undef ip_address_t -#undef ip_address_cmp -#undef ip_prefix_t -#undef ip_prefix_cmp -#undef ip_prefix_len -#define ip_prefix_len(_a) (_a)->len - #include "faces/face.h" #include @@ -60,6 +47,11 @@ typedef u8 weight_t; /* The following is stored in the opaque2 field in the vlib_buffer_t */ typedef struct { + /** + * Cached packet info + */ + hicn_packet_buffer_t pkbuf; + /** * IDs to prefetch a PIT/CS entry (4) */ @@ -85,15 +77,23 @@ typedef struct */ hicn_face_id_t face_id; - /** - * Cached packet info - */ - hicn_type_t type; + /* + hicn_packet_type_t type; + hicn_packet_format_t format; hicn_name_t name; + */ u16 port; hicn_lifetime_t lifetime; } hicn_buffer_t; +STATIC_ASSERT (offsetof (hicn_buffer_t, pcs_entry_id) == 28, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, vft_id) == 32, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, dpo_ctx_id) == 36, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, flags) == 40, ""); +STATIC_ASSERT (offsetof (hicn_buffer_t, face_id) == 44, ""); +// STATIC_ASSERT (offsetof (hicn_buffer_t, name) == 48, ""); +// + name = 16+4 = 20 +// opaque : u32[14] = 56 STATIC_ASSERT (sizeof (hicn_buffer_t) <= STRUCT_SIZE_OF (vlib_buffer_t, opaque2), "hICN buffer opaque2 meta-data too large for vlib_buffer"); @@ -104,6 +104,7 @@ hicn_get_buffer (vlib_buffer_t *b0) return (hicn_buffer_t *) &(b0->opaque2[0]); } +#if 0 always_inline u8 hicn_is_v6 (hicn_header_t *pkt_hdr) { @@ -113,13 +114,16 @@ hicn_is_v6 (hicn_header_t *pkt_hdr) always_inline hicn_name_t * hicn_buffer_get_name (vlib_buffer_t *b) { - return &hicn_get_buffer (b)->name; + return hicn_packet_get_name(&hicn_get_buffer (b)->pkbuf); } +#endif always_inline u8 hicn_buffer_is_v6 (vlib_buffer_t *b0) { - return hicn_get_buffer (b0)->type.l1 == IPPROTO_IPV6; + hicn_packet_format_t format = + hicn_packet_get_format (&hicn_get_buffer (b0)->pkbuf); + return format.l1 == IPPROTO_IPV6; } always_inline void diff --git a/hicn-plugin/src/interest_pcslookup_node.c b/hicn-plugin/src/interest_pcslookup_node.c index a9ff9ba29..f0683727a 100644 --- a/hicn-plugin/src/interest_pcslookup_node.c +++ b/hicn-plugin/src/interest_pcslookup_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -104,8 +104,10 @@ hicn_interest_pcslookup_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, stats.pkts_processed++; // Check if the interest is in the PCS already - ret = hicn_pcs_lookup_one (rt->pitcs, &hicn_get_buffer (b0)->name, - &pcs_entry); + hicn_name_t name; + hicn_packet_get_name (&hicn_get_buffer (b0)->pkbuf, &name); + ret = hicn_pcs_lookup_one (rt->pitcs, &name, &pcs_entry); + //&hicn_get_buffer (b0)->name, if (ret == HICN_ERROR_NONE) { @@ -203,4 +205,4 @@ VLIB_REGISTER_NODE(hicn_interest_pcslookup_node) = * fd.io coding-style-patch-verification: ON * * Local Variables: eval: (c-set-style "gnu") End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/mapme_ack_node.c b/hicn-plugin/src/mapme_ack_node.c index ea4834665..13ae7ee67 100644 --- a/hicn-plugin/src/mapme_ack_node.c +++ b/hicn-plugin/src/mapme_ack_node.c @@ -67,7 +67,7 @@ hicn_mapme_process_ack (vlib_main_t *vm, vlib_buffer_t *b, /* return true; */ /* } */ - dpo = fib_epm_lookup (&(prefix.name), prefix.len); + dpo = fib_epm_lookup (&(prefix.name.as_ip46), prefix.len); if (!dpo) { HICN_ERROR ("Ignored ACK for non-existing FIB entry %U. Ignored.", diff --git a/hicn-plugin/src/mapme_ctrl_node.c b/hicn-plugin/src/mapme_ctrl_node.c index 5314c49a0..e3d340e53 100644 --- a/hicn-plugin/src/mapme_ctrl_node.c +++ b/hicn-plugin/src/mapme_ctrl_node.c @@ -194,7 +194,7 @@ hicn_mapme_process_ctrl (vlib_main_t *vm, vlib_buffer_t *b, /* We forge the ACK which we be the packet forwarded by the node */ hicn_mapme_create_ack (vlib_buffer_get_current (b), ¶ms); - dpo = fib_epm_lookup (&prefix.name, prefix.len); + dpo = fib_epm_lookup (&prefix.name.as_ip46, prefix.len); if (!dpo) { #ifdef HICN_MAPME_ALLOW_NONEXISTING_FIB_ENTRY diff --git a/hicn-plugin/src/mapme_eventmgr.c b/hicn-plugin/src/mapme_eventmgr.c index c7ae4ecd7..bbfe77819 100644 --- a/hicn-plugin/src/mapme_eventmgr.c +++ b/hicn-plugin/src/mapme_eventmgr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -22,6 +22,8 @@ #include #include +#include + #define DEFAULT_TIMEOUT 1.0 /* s */ /** @@ -196,7 +198,7 @@ hicn_mapme_on_face_added (vlib_main_t *vm, hicn_face_id_t face) static_always_inline void * get_packet_buffer (vlib_main_t *vm, u32 node_index, u32 dpoi_index, - ip46_address_t *addr, hicn_type_t type) + ip46_address_t *addr, hicn_packet_format_t format) { vlib_frame_t *f; vlib_buffer_t *b; // for newly created packet @@ -216,7 +218,10 @@ get_packet_buffer (vlib_main_t *vm, u32 node_index, u32 dpoi_index, /* Face information for next hop node index */ vnet_buffer (b)->ip.adj_index[VLIB_TX] = dpoi_index; - hicn_get_buffer (b)->type = type; + + hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b)->pkbuf; + hicn_packet_set_format (pkbuf, format); + hicn_packet_init_header (pkbuf, 0); /* Enqueue the packet right now */ f = vlib_get_frame_to_node (vm, node_index); @@ -227,8 +232,8 @@ get_packet_buffer (vlib_main_t *vm, u32 node_index, u32 dpoi_index, // pointer to IP layer ? do we need to prepare for ethernet ??? buffer = vlib_buffer_get_current (b); - b->current_length = - (type.l1 == IPPROTO_IPV6) ? HICN_MAPME_V6_HDRLEN : HICN_MAPME_V4_HDRLEN; + b->current_length = (format.l1 == IPPROTO_IPV6) ? EXPECTED_MAPME_V6_HDRLEN : + EXPECTED_MAPME_V4_HDRLEN; return buffer; } @@ -255,8 +260,8 @@ hicn_mapme_send_message (vlib_main_t *vm, const hicn_prefix_t *prefix, u8 *buffer = get_packet_buffer ( vm, node_index, face, (ip46_address_t *) prefix, - (params->protocol == IPPROTO_IPV6) ? HICN_TYPE_IPV6_ICMP : - HICN_TYPE_IPV4_ICMP); + (params->protocol == IPPROTO_IPV6) ? HICN_PACKET_FORMAT_IPV6_ICMP : + HICN_PACKET_FORMAT_IPV4_ICMP); n = hicn_mapme_create_packet (buffer, prefix, params); if (n <= 0) { @@ -282,7 +287,7 @@ hicn_mapme_send_updates (vlib_main_t *vm, hicn_prefix_t *prefix, dpo_id_t dpo, mapme_params_t params = { .protocol = - ip46_address_is_ip4 (&prefix->name) ? IPPROTO_IP : IPPROTO_IPV6, + ip46_address_is_ip4 (&prefix->name.as_ip46) ? IPPROTO_IP : IPPROTO_IPV6, .type = UPDATE, .seq = tfib->seq, }; diff --git a/hicn-plugin/src/parser.h b/hicn-plugin/src/parser.h index 3c21a33f8..1d297e510 100644 --- a/hicn-plugin/src/parser.h +++ b/hicn-plugin/src/parser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -26,62 +26,26 @@ * @file parser.h */ -#define PARSE(PACKET_TYPE) \ +#define PARSE(PACKET_TYPE, SIZE) \ do \ { \ if (pkt == NULL) \ return HICN_ERROR_PARSER_PKT_INVAL; \ \ - int ret = HICN_LIB_ERROR_NONE; \ + int ret = HICN_ERROR_NONE; \ \ - hicn_header_t *pkt_hdr; \ - u8 *ip_pkt; \ - u8 ip_proto; \ - int isv6; \ - u8 next_proto_offset; \ - hicn_type_t type; \ - hicn_name_t *name; \ u16 *port; \ hicn_lifetime_t *lifetime; \ \ - /* start parsing first fields to get the protocols */ \ - pkt_hdr = vlib_buffer_get_current (pkt); \ - isv6 = hicn_is_v6 (pkt_hdr); \ - \ - ip_pkt = vlib_buffer_get_current (pkt); \ - ip_proto = (1 - isv6) * IPPROTO_IP + (isv6) *IPPROTO_IPV6; \ - \ - /* in the ipv6 header the next header field is at byte 6 in the ipv4*/ \ - /* header the protocol field is at byte 9*/ \ - next_proto_offset = 6 + (1 - isv6) * 3; \ - \ - /* get type info*/ \ - type.l4 = IPPROTO_NONE; \ - type.l3 = ip_pkt[next_proto_offset] == IPPROTO_UDP ? IPPROTO_ENCAP : \ - IPPROTO_NONE; \ - type.l2 = ip_pkt[next_proto_offset]; \ - type.l1 = ip_proto; \ + hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (pkt)->pkbuf; \ \ - /* cache hicn packet type in opaque2*/ \ - hicn_get_buffer (pkt)->type = type; \ - \ - /* get name and name length*/ \ - name = &hicn_get_buffer (pkt)->name; \ - ret = hicn_ops_vft[type.l1]->get_##PACKET_TYPE##_name ( \ - type, &pkt_hdr->protocol, name); \ - if (PREDICT_FALSE (ret)) \ - { \ - if (type.l2 == IPPROTO_ICMPV4 || type.l2 == IPPROTO_ICMPV6) \ - { \ - return HICN_ERROR_PARSER_MAPME_PACKET; \ - } \ - return HICN_ERROR_PARSER_PKT_INVAL; \ - } \ + hicn_packet_set_buffer (pkbuf, vlib_buffer_get_current (pkt), (SIZE), \ + (SIZE)); \ + hicn_packet_analyze (&hicn_get_buffer (pkt)->pkbuf); \ \ /* get source port*/ \ port = &hicn_get_buffer (pkt)->port; \ - hicn_ops_vft[type.l1]->get_source_port (type, &pkt_hdr->protocol, \ - port); \ + hicn_packet_get_src_port (pkbuf, port); \ if (PREDICT_FALSE (ret)) \ { \ return HICN_ERROR_PARSER_PKT_INVAL; \ @@ -89,8 +53,7 @@ \ /* get lifetime*/ \ lifetime = &hicn_get_buffer (pkt)->lifetime; \ - hicn_ops_vft[type.l1]->get_lifetime (type, &pkt_hdr->protocol, \ - lifetime); \ + hicn_packet_get_lifetime (pkbuf, lifetime); \ \ if (*lifetime > hicn_main.pit_lifetime_max_ms) \ *lifetime = hicn_main.pit_lifetime_max_ms; \ @@ -99,6 +62,22 @@ } \ while (0) +#if 0 + hicn_name_t *name; \ + + /* get name and name length*/ + name = &hicn_get_buffer (pkt)->name; + ret = hicn_##PACKET_TYPE##_get_name (pkbuf, name); + if (PREDICT_FALSE (ret)) + { + if (type.l2 == IPPROTO_ICMPV4 || type.l2 == IPPROTO_ICMPV6) + { + return HICN_ERROR_PARSER_MAPME_PACKET; + } + return HICN_ERROR_PARSER_PKT_INVAL; + } +#endif + /** * @brief Parse a interest packet * @@ -111,9 +90,9 @@ * ipv6 */ always_inline int -hicn_interest_parse_pkt (vlib_buffer_t *pkt) +hicn_interest_parse_pkt (vlib_buffer_t *pkt, uword size) { - PARSE (interest); + PARSE (interest, size); } /** @@ -128,9 +107,9 @@ hicn_interest_parse_pkt (vlib_buffer_t *pkt) * ipv6 */ always_inline int -hicn_data_parse_pkt (vlib_buffer_t *pkt) +hicn_data_parse_pkt (vlib_buffer_t *pkt, uword size) { - PARSE (data); + PARSE (data, size); } #endif /* __HICN_PARSER_H__ */ @@ -139,4 +118,4 @@ hicn_data_parse_pkt (vlib_buffer_t *pkt) * fd.io coding-style-patch-verification: ON * * Local Variables: eval: (c-set-style "gnu") End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/pcs.h b/hicn-plugin/src/pcs.h index fa5a68b27..f9cb7bd91 100644 --- a/hicn-plugin/src/pcs.h +++ b/hicn-plugin/src/pcs.h @@ -259,8 +259,8 @@ hicn_pcs_get_exp_time (f64 cur_time_sec, u64 lifetime_msec) always_inline void hicn_pcs_get_key_from_name (clib_bihash_kv_24_8_t *kv, const hicn_name_t *name) { - kv->key[0] = name->prefix.ip6.as_u64[0]; - kv->key[1] = name->prefix.ip6.as_u64[1]; + kv->key[0] = name->prefix.v6.as_u64[0]; + kv->key[1] = name->prefix.v6.as_u64[1]; kv->key[2] = name->suffix; } diff --git a/hicn-plugin/src/pg.c b/hicn-plugin/src/pg.c index 05172345b..78380a804 100644 --- a/hicn-plugin/src/pg.c +++ b/hicn-plugin/src/pg.c @@ -61,9 +61,37 @@ hicnpg_server_restack (hicnpg_server_t *hicnpg_server) static hicnpg_server_t * hicnpg_server_from_fib_node (fib_node_t *node) { +#if 1 ASSERT (hicnpg_server_fib_node_type == node->fn_type); return ((hicnpg_server_t *) (((char *) node) - STRUCT_OFFSET_OF (hicnpg_server_t, fib_node))); +#else + hicn_header_t *h0 = vlib_buffer_get_current (b0); + + /* Generate the right src and dst corresponding to flow and iface */ + ip46_address_t src_addr = { + .ip4 = hicnpg_main.pgen_clt_src_addr.ip4, + }; + hicn_name_t dst_name = { + .prefix.v4.as_u32 = hicnpg_main.pgen_clt_hicn_name->fp_addr.ip4.as_u32, + .suffix = seq_number, + }; + + src_addr.ip4.as_u32 += clib_host_to_net_u32 (iface); + dst_name.prefix.v4.as_u32 += clib_net_to_host_u32 (next_flow); + + /* Update locator and name */ + hicn_type_t type = hicn_get_buffer (b0)->type; + HICN_OPS4->set_interest_locator (type, &h0->protocol, + (hicn_ip_address_t *) &src_addr); + HICN_OPS4->set_interest_name (type, &h0->protocol, &dst_name); + + /* Update lifetime (currently L4 checksum is not updated) */ + HICN_OPS4->set_lifetime (type, &h0->protocol, interest_lifetime); + + /* Update checksums */ + HICN_OPS4->update_checksums (type, &h0->protocol, 0, 0); +#endif } /** @@ -74,7 +102,35 @@ hicnpg_server_fib_back_walk (fib_node_t *node, fib_node_back_walk_ctx_t *ctx) { hicnpg_server_restack (hicnpg_server_from_fib_node (node)); +#if 1 return FIB_NODE_BACK_WALK_CONTINUE; +#else + /* Generate the right src and dst corresponding to flow and iface */ + ip46_address_t src_addr = { + .ip6 = hicnpg_main.pgen_clt_src_addr.ip6, + }; + hicn_name_t dst_name = { + .prefix.v6.as_u64 = { + hicnpg_main.pgen_clt_hicn_name->fp_addr.ip6.as_u64[0], + hicnpg_main.pgen_clt_hicn_name->fp_addr.ip6.as_u64[1], + }, + .suffix = seq_number, + }; + src_addr.ip6.as_u32[3] += clib_host_to_net_u32 (iface); + dst_name.prefix.v6.as_u32[3] += clib_net_to_host_u32 (next_flow); + + /* Update locator and name */ + hicn_type_t type = hicn_get_buffer (b0)->type; + HICN_OPS6->set_interest_locator (type, &h0->protocol, + (hicn_ip_address_t *) &src_addr); + HICN_OPS6->set_interest_name (type, &h0->protocol, &dst_name); + + /* Update lifetime */ + HICN_OPS6->set_lifetime (type, &h0->protocol, interest_lifetime); + + /* Update checksums */ + calculate_tcp_checksum_v6 (vm, b0); +#endif } /** @@ -311,4 +367,4 @@ hicn_pg_init (vlib_main_t *vm) * fd.io coding-style-patch-verification: ON * * Local Variables: eval: (c-set-style "gnu") End: - */ \ No newline at end of file + */ diff --git a/hicn-plugin/src/pg_node.c b/hicn-plugin/src/pg_node.c index 1a99d3fa2..3d94c1cd1 100644 --- a/hicn-plugin/src/pg_node.c +++ b/hicn-plugin/src/pg_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -18,6 +18,9 @@ #include #include #include +#include +#include +#include #include "hicn.h" #include "pg.h" @@ -130,6 +133,7 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, u8 isv6_0; u8 isv6_1; u32 n_left_to_next; + uword size; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -178,7 +182,8 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vnet_buffer (b1)->sw_if_index[VLIB_RX] = hpgm->sw_if; /* Check icn packets, locate names */ - if (hicn_interest_parse_pkt (b0) == HICN_ERROR_NONE) + size = vlib_buffer_length_in_chain (vm, b0); + if (hicn_interest_parse_pkt (b0, size) == HICN_ERROR_NONE) { /* this node grabs only interests */ isv6_0 = hicn_buffer_is_v6 (b0); @@ -204,7 +209,8 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, next0 = isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP : HICNPG_INTEREST_NEXT_V4_LOOKUP; } - if (hicn_interest_parse_pkt (b1) == HICN_ERROR_NONE) + size = vlib_buffer_length_in_chain (vm, b1); + if (hicn_interest_parse_pkt (b1, size) == HICN_ERROR_NONE) { /* this node grabs only interests */ isv6_1 = hicn_buffer_is_v6 (b1); @@ -292,7 +298,8 @@ hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vnet_buffer (b0)->sw_if_index[VLIB_RX] = hpgm->sw_if; /* Check icn packets, locate names */ - if (hicn_interest_parse_pkt (b0) == HICN_ERROR_NONE) + size = vlib_buffer_length_in_chain (vm, b0); + if (hicn_interest_parse_pkt (b0, size) == HICN_ERROR_NONE) { /* this node grabs only interests */ isv6_0 = hicn_buffer_is_v6 (b0); @@ -363,30 +370,28 @@ void hicn_rewrite_interestv4 (vlib_main_t *vm, vlib_buffer_t *b0, u32 seq_number, u16 interest_lifetime, u32 next_flow, u32 iface) { - hicn_header_t *h0 = vlib_buffer_get_current (b0); - + hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b0)->pkbuf; /* Generate the right src and dst corresponding to flow and iface */ ip46_address_t src_addr = { .ip4 = hicnpg_main.pgen_clt_src_addr.ip4, }; hicn_name_t dst_name = { - .prefix.ip4 = hicnpg_main.pgen_clt_hicn_name->fp_addr.ip4, + .prefix.v4.as_u32 = hicnpg_main.pgen_clt_hicn_name->fp_addr.ip4.as_u32, .suffix = seq_number, }; src_addr.ip4.as_u32 += clib_host_to_net_u32 (iface); - dst_name.prefix.ip4.as_u32 += clib_net_to_host_u32 (next_flow); + dst_name.prefix.v4.as_u32 += clib_net_to_host_u32 (next_flow); /* Update locator and name */ - hicn_type_t type = hicn_get_buffer (b0)->type; - HICN_OPS4->set_interest_locator (type, &h0->protocol, &src_addr); - HICN_OPS4->set_interest_name (type, &h0->protocol, &dst_name); + hicn_interest_set_locator (pkbuf, (hicn_ip_address_t *) &src_addr); + hicn_interest_set_name (pkbuf, &dst_name); /* Update lifetime (currently L4 checksum is not updated) */ - HICN_OPS4->set_lifetime (type, &h0->protocol, interest_lifetime); + hicn_interest_set_lifetime (pkbuf, interest_lifetime); /* Update checksums */ - HICN_OPS4->update_checksums (type, &h0->protocol, 0, 0); + hicn_packet_compute_checksum (pkbuf); } /** @@ -409,28 +414,27 @@ void hicn_rewrite_interestv6 (vlib_main_t *vm, vlib_buffer_t *b0, u32 seq_number, u16 interest_lifetime, u32 next_flow, u32 iface) { - hicn_header_t *h0 = vlib_buffer_get_current (b0); + hicn_packet_buffer_t *pkbuf = &hicn_get_buffer (b0)->pkbuf; /* Generate the right src and dst corresponding to flow and iface */ ip46_address_t src_addr = { .ip6 = hicnpg_main.pgen_clt_src_addr.ip6, }; hicn_name_t dst_name = { - .prefix.ip6 = hicnpg_main.pgen_clt_hicn_name->fp_addr.ip6, + .prefix = (hicn_ip_address_t) (hicnpg_main.pgen_clt_hicn_name->fp_addr), .suffix = seq_number, }; src_addr.ip6.as_u32[3] += clib_host_to_net_u32 (iface); - dst_name.prefix.ip6.as_u32[3] += clib_net_to_host_u32 (next_flow); + dst_name.prefix.v6.as_u32[3] += clib_net_to_host_u32 (next_flow); /* Update locator and name */ - hicn_type_t type = hicn_get_buffer (b0)->type; - HICN_OPS6->set_interest_locator (type, &h0->protocol, &src_addr); - HICN_OPS6->set_interest_name (type, &h0->protocol, &dst_name); - + hicn_interest_set_locator (pkbuf, (hicn_ip_address_t *) &src_addr); + hicn_interest_set_name (pkbuf, &dst_name); /* Update lifetime */ - HICN_OPS6->set_lifetime (type, &h0->protocol, interest_lifetime); + hicn_interest_set_lifetime (pkbuf, interest_lifetime); /* Update checksums */ + hicn_packet_compute_checksum (pkbuf); calculate_tcp_checksum_v6 (vm, b0); } @@ -811,6 +815,7 @@ hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node, u32 hpgi0, hpgi1; hicnpg_server_t *hpg0, *hpg1; u32 n_left_to_next; + uword size; from = vlib_frame_vector_args (frame); @@ -863,7 +868,8 @@ hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hpg0 = hicnpg_server_get (hpgi0); hpg1 = hicnpg_server_get (hpgi1); - if (hicn_interest_parse_pkt (b0) == HICN_ERROR_NONE) + size = vlib_buffer_length_in_chain (vm, b0); + if (hicn_interest_parse_pkt (b0, size) == HICN_ERROR_NONE) { vlib_buffer_t *rb = NULL; rb = vlib_get_buffer (vm, hpg0->buffer_index); @@ -875,7 +881,8 @@ hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node, HICNPG_SERVER_NEXT_V4_LOOKUP; } - if (hicn_interest_parse_pkt (b1) == HICN_ERROR_NONE) + size = vlib_buffer_length_in_chain (vm, b1); + if (hicn_interest_parse_pkt (b1, size) == HICN_ERROR_NONE) { vlib_buffer_t *rb = NULL; rb = vlib_get_buffer (vm, hpg1->buffer_index); @@ -944,7 +951,8 @@ hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hpgi0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; hpg0 = hicnpg_server_get (hpgi0); - if (hicn_interest_parse_pkt (b0) == HICN_ERROR_NONE) + size = vlib_buffer_length_in_chain (vm, b0); + if (hicn_interest_parse_pkt (b0, size) == HICN_ERROR_NONE) { /* this node grabs only interests */ vlib_buffer_t *rb = NULL; @@ -995,10 +1003,10 @@ void convert_interest_to_data_v4 (vlib_main_t *vm, vlib_buffer_t *b0, vlib_buffer_t *rb, u32 bi0) { - hicn_header_t *h0 = vlib_buffer_get_current (b0); + ip4_header_t *ip4 = vlib_buffer_get_current (b0); /* Get the packet length */ - u16 pkt_len = clib_net_to_host_u16 (h0->v4.ip.len); + u16 pkt_len = clib_net_to_host_u16 (ip4->length); /* * Rule of thumb: We want the size of the IP packet to be <= 1500 bytes @@ -1013,14 +1021,14 @@ convert_interest_to_data_v4 (vlib_main_t *vm, vlib_buffer_t *b0, b0 = vlib_get_buffer (vm, bi0); - h0 = vlib_buffer_get_current (b0); + ip4 = vlib_buffer_get_current (b0); - ip4_address_t src_addr = h0->v4.ip.saddr; - h0->v4.ip.saddr = h0->v4.ip.daddr; - h0->v4.ip.daddr = src_addr; + ip4_address_t src_addr = ip4->src_address; + ip4->src_address = ip4->dst_address; + ip4->dst_address = src_addr; - h0->v4.ip.len = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)); - h0->v4.ip.csum = ip4_header_checksum ((ip4_header_t *) &(h0->v4.ip)); + ip4->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)); + ip4->checksum = ip4_header_checksum (ip4); calculate_tcp_checksum_v4 (vm, b0); } @@ -1028,11 +1036,11 @@ void convert_interest_to_data_v6 (vlib_main_t *vm, vlib_buffer_t *b0, vlib_buffer_t *rb, u32 bi0) { - hicn_header_t *h0 = vlib_buffer_get_current (b0); + ip6_header_t *ip6 = vlib_buffer_get_current (b0); /* Get the packet length */ uint16_t pkt_len = - clib_net_to_host_u16 (h0->v6.ip.len) + sizeof (ip6_header_t); + clib_net_to_host_u16 (ip6->payload_length) + sizeof (ip6_header_t); /* * Figure out how many bytes we can add to the content @@ -1049,15 +1057,17 @@ convert_interest_to_data_v6 (vlib_main_t *vm, vlib_buffer_t *b0, b0 = vlib_get_buffer (vm, bi0); - h0 = vlib_buffer_get_current (b0); - ip6_address_t src_addr = h0->v6.ip.saddr; - h0->v6.ip.saddr = h0->v6.ip.daddr; - h0->v6.ip.daddr = src_addr; + ip6 = vlib_buffer_get_current (b0); + ip6_address_t src_addr = ip6->src_address; + ip6->src_address = ip6->dst_address; + ip6->dst_address = src_addr; + + ip6->payload_length = clib_host_to_net_u16 ( + vlib_buffer_length_in_chain (vm, b0) - sizeof (ip6_header_t)); - h0->v6.ip.len = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) - - sizeof (ip6_header_t)); - h0->v6.tcp.data_offset_and_reserved |= 0x0f; - h0->v6.tcp.urg_ptr = htons (0xffff); + tcp_header_t *tcp = (tcp_header_t *) (ip6 + 1); + tcp->data_offset_and_reserved |= 0x0f; + tcp->urgent_pointer = htons (0xffff); calculate_tcp_checksum_v6 (vm, b0); } diff --git a/hicn-plugin/src/strategy_node.c b/hicn-plugin/src/strategy_node.c index 565f3e496..5f5a10749 100644 --- a/hicn-plugin/src/strategy_node.c +++ b/hicn-plugin/src/strategy_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Cisco and/or its affiliates. + * Copyright (c) 2021-2022 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -160,7 +160,10 @@ hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node, hicn_buffer_get_lifetime (b0)); // Add entry to PIT table - ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &hicnb0->name); + hicn_name_t name; + hicn_packet_get_name (&hicnb0->pkbuf, &name); + ret = hicn_pcs_pit_insert (rt->pitcs, pcs_entry, &name); + //&hicnb0->name); if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) { @@ -285,4 +288,4 @@ VLIB_REGISTER_NODE (hicn_strategy_node) = * fd.io coding-style-patch-verification: ON * * Local Variables: eval: (c-set-style "gnu") End: - */ \ No newline at end of file + */ -- cgit 1.2.3-korg