diff options
-rw-r--r-- | hicn-light/src/io/udpListener.c | 4 | ||||
-rw-r--r-- | hicn-plugin/src/cli.c | 36 | ||||
-rw-r--r-- | hicn-plugin/src/data_fwd_node.c | 80 | ||||
-rw-r--r-- | hicn-plugin/src/data_push_node.c | 28 | ||||
-rw-r--r-- | hicn-plugin/src/params.h | 2 | ||||
-rw-r--r-- | utils/src/ping_server.cc | 24 |
6 files changed, 118 insertions, 56 deletions
diff --git a/hicn-light/src/io/udpListener.c b/hicn-light/src/io/udpListener.c index 6cdb9283e..c49571dd4 100644 --- a/hicn-light/src/io/udpListener.c +++ b/hicn-light/src/io/udpListener.c @@ -520,6 +520,10 @@ static void _readcb(int fd, PARCEventType what, void *udpVoid) { ssize_t readLength = recvfrom(fd, packet, 1500, 0, (struct sockaddr *)&peerIpAddress, &peerIpAddressLength); +#ifdef __APPLE__ + peerIpAddress.ss_len = 0x00; +#endif + if(readLength < 0) { printf("unable to read the message\n"); return; diff --git a/hicn-plugin/src/cli.c b/hicn-plugin/src/cli.c index c8c0be4ff..b03d6a29c 100644 --- a/hicn-plugin/src/cli.c +++ b/hicn-plugin/src/cli.c @@ -86,9 +86,12 @@ hicn_cli_node_ctl_start_set_command_fn (vlib_main_t * vm, ret = hicn_infra_plugin_enable_disable (1 /* enable */ , node_ctl_params.pit_max_size, - node_ctl_params.pit_dflt_lifetime_sec, - node_ctl_params.pit_min_lifetime_sec, - node_ctl_params.pit_max_lifetime_sec, + node_ctl_params. + pit_dflt_lifetime_sec, + node_ctl_params. + pit_min_lifetime_sec, + node_ctl_params. + pit_max_lifetime_sec, node_ctl_params.cs_max_size, node_ctl_params.cs_reserved_app); @@ -131,9 +134,12 @@ hicn_cli_node_ctl_stop_set_command_fn (vlib_main_t * vm, } ret = hicn_infra_plugin_enable_disable (0 /* !enable */ , node_ctl_params.pit_max_size, - node_ctl_params.pit_dflt_lifetime_sec, - node_ctl_params.pit_min_lifetime_sec, - node_ctl_params.pit_max_lifetime_sec, + node_ctl_params. + pit_dflt_lifetime_sec, + node_ctl_params. + pit_min_lifetime_sec, + node_ctl_params. + pit_max_lifetime_sec, node_ctl_params.cs_max_size, node_ctl_params.cs_reserved_app); @@ -877,8 +883,8 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm, { /* Add data node to the vpp graph */ u32 next_hit_node = vlib_node_add_next (vm, - hicn_punt_glb. - hicn_node_info.ip4_inacl_node_index, + hicn_punt_glb.hicn_node_info. + ip4_inacl_node_index, hicn_pg_data_node.index); /* Add pgen_client node to the vpp graph */ @@ -915,8 +921,8 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm, { /* Add node to the vpp graph */ u32 next_hit_node = vlib_node_add_next (vm, - hicn_punt_glb.hicn_node_info. - ip6_inacl_node_index, + hicn_punt_glb. + hicn_node_info.ip6_inacl_node_index, hicn_pg_data_node.index); /* Add pgen_client node to the vpp graph */ @@ -1086,8 +1092,8 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm, { /* Add node to the vpp graph */ u32 next_hit_node = vlib_node_add_next (vm, - hicn_punt_glb. - hicn_node_info.ip4_inacl_node_index, + hicn_punt_glb.hicn_node_info. + ip4_inacl_node_index, hicn_pg_server_node.index); /* Create the punting table if it does not exist */ @@ -1113,8 +1119,8 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm, { /* Add node to the vpp graph */ u32 next_hit_node = vlib_node_add_next (vm, - hicn_punt_glb.hicn_node_info. - ip6_inacl_node_index, + hicn_punt_glb. + hicn_node_info.ip6_inacl_node_index, hicn_pg_server_node.index); /* Create the punting table if it does not exist */ @@ -1210,7 +1216,7 @@ VLIB_CLI_COMMAND(hicn_cli_show_command, static)= VLIB_CLI_COMMAND(hicn_cli_punting_command, static)= { .path = "hicn punting", - .short_help = "hicn punting {add|delete} prefix <ip_address/mask> intfc <interface> type <ip/udp>", + .short_help = "hicn punting {add|delete} prefix <ip_address/mask> intfc <interface> {type ip | type <udp4|udp6> src_port <port> dst_port <port>}", .function = hicn_cli_punting_command_fn, }; diff --git a/hicn-plugin/src/data_fwd_node.c b/hicn-plugin/src/data_fwd_node.c index b25c9e0ac..19181ac03 100644 --- a/hicn-plugin/src/data_fwd_node.c +++ b/hicn-plugin/src/data_fwd_node.c @@ -50,7 +50,7 @@ clone_data_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs, hicn_hash_node_t * nodep, vlib_buffer_t * b0, hicn_hash_entry_t * hash_entry, u64 name_hash, hicn_buffer_t * hicnb, const hicn_dpo_vft_t * dpo_vft, - dpo_id_t * hicn_dpo_id); + dpo_id_t * hicn_dpo_id, hicn_lifetime_t dmsg_lifetime); /* packet trace format function */ @@ -221,24 +221,69 @@ hicn_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, pitp->u.pit.pe_txnh); #if HICN_FEATURE_CS - /* - * Clone data packet in the content store and - * convert the PIT entry into a CS entry - */ - clone_data_to_cs (vm, pitcs, pitp, hicn0, tnow, node0, - b0, hash_entry0, hicnb0->name_hash, hicnb0, - dpo_vft0, &hicn_dpo_id0); + hicn_lifetime_t dmsg_lifetime; - hicn_pcs_remove_lock (pitcs, &pitp, &node0, vm, - hash_entry0, NULL, NULL); + hicn_type_t type = hicnb0->type; + hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol, + &dmsg_lifetime); + + if (dmsg_lifetime) + { + /* + * Clone data packet in the content store and + * convert the PIT entry into a CS entry + */ + clone_data_to_cs (vm, pitcs, pitp, hicn0, tnow, node0, + b0, hash_entry0, hicnb0->name_hash, + hicnb0, dpo_vft0, &hicn_dpo_id0, + dmsg_lifetime); + + hicn_pcs_remove_lock (pitcs, &pitp, &node0, vm, + hash_entry0, NULL, NULL); + } + else + { + /* + * If the packet is copied and not cloned, we need to free the vlib_buffer + */ + if (hicnb0->flags & HICN_BUFFER_FLAGS_PKT_LESS_TWO_CL) + { + vlib_buffer_free_one (vm, bi0); + } + else + { + /* + * Remove one reference as the buffer is no + * longer in any frame. The vlib_buffer will be freed when + * all its cloned vlib_buffer will be freed. + */ + b0->n_add_refs--; + } + + /* Delete the PIT entry */ + hicn_pcs_pit_delete (pitcs, &pitp, &node0, vm, + hash_entry0, dpo_vft0, &hicn_dpo_id0); + } #else ASSERT (pitp == hicn_pit_get_data (node0)); /* - * Remove one reference as the buffer is no - * longer in any frame + * If the packet is copied and not cloned, we need to free the vlib_buffer */ - b0->n_add_refs--; - /* If not enabled, delete the PIT entry */ + if (hicnb0->flags & HICN_BUFFER_FLAGS_PKT_LESS_TWO_CL) + { + vlib_buffer_free_one (vm, bi0); + } + else + { + /* + * Remove one reference as the buffer is no + * longer in any frame. The vlib_buffer will be freed when + * all its cloned vlib_buffer will be freed. + */ + b0->n_add_refs--; + } + + /* Delete the PIT entry */ hicn_pcs_pit_delete (pitcs, &pitp, &node0, vm, hash_entry0, dpo_vft0, &hicn_dpo_id0); #endif @@ -490,9 +535,8 @@ clone_data_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs, hicn_hash_node_t * nodep, vlib_buffer_t * b0, hicn_hash_entry_t * hash_entry, u64 name_hash, hicn_buffer_t * hicnb, const hicn_dpo_vft_t * dpo_vft, - dpo_id_t * hicn_dpo_id) + dpo_id_t * hicn_dpo_id, hicn_lifetime_t dmsg_lifetime) { - hicn_lifetime_t dmsg_lifetime; /* * At this point we think we're safe to proceed. Store the CS buf in * the PIT/CS hashtable entry @@ -510,10 +554,6 @@ clone_data_to_cs (vlib_main_t * vm, hicn_pit_cs_t * pitcs, pitp->shared.create_time = tnow; - hicn_type_t type = hicnb0->type; - hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol, - &dmsg_lifetime); - if (dmsg_lifetime < HICN_PARAM_CS_LIFETIME_MIN || dmsg_lifetime > HICN_PARAM_CS_LIFETIME_MAX) { diff --git a/hicn-plugin/src/data_push_node.c b/hicn-plugin/src/data_push_node.c index d530173bc..b955a765d 100644 --- a/hicn-plugin/src/data_push_node.c +++ b/hicn-plugin/src/data_push_node.c @@ -97,7 +97,7 @@ hicn_new_data (vlib_main_t * vm, hicn_data_push_runtime_t * rt, u32 bi0 = vlib_get_buffer_index (vm, b0); hicn_hash_node_t *nodep; hicn_pcs_entry_t *pitp; - hicn_header_t *hicn0; + hicn_header_t *hicn0 = vlib_buffer_get_current (b0); hicn_buffer_t *hicnb0 = hicn_get_buffer (b0); u32 node_id0 = 0; u8 dpo_ctx_id0 = ~0; @@ -108,6 +108,17 @@ hicn_new_data (vlib_main_t * vm, hicn_data_push_runtime_t * rt, u8 bucket_is_overflow = 0; hicn_lifetime_t dmsg_lifetime; + hicnb0 = hicn_get_buffer (b0); + hicn_type_t type = hicnb0->type; + hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol, + &dmsg_lifetime); + + if (!dmsg_lifetime) + { + vlib_buffer_free_one (vm, bi0); + return HICN_ERROR_NONE; + } + /* Create PIT node and init PIT entry */ nodep = hicn_hashtb_alloc_node (rt->pitcs->pcs_table); if (PREDICT_FALSE (nodep == NULL)) @@ -121,12 +132,6 @@ hicn_new_data (vlib_main_t * vm, hicn_data_push_runtime_t * rt, hicn_pit_init_data (pitp); pitp->shared.create_time = tnow; - hicn0 = vlib_buffer_get_current (b0); - - hicn_type_t type = hicnb0->type; - hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol, - &dmsg_lifetime); - if (dmsg_lifetime < HICN_PARAM_CS_LIFETIME_MIN || dmsg_lifetime > HICN_PARAM_CS_LIFETIME_MAX) { @@ -238,10 +243,13 @@ hicn_data_push_fn (vlib_main_t * vm, ret0 = hicn_data_parse_pkt (b0, &name, &namelen, &hicn0, &isv6); nameptr = (u8 *) (&name); + if (PREDICT_TRUE (ret0 == HICN_ERROR_NONE)) - hicn_new_data (vm, rt, b0, &to_forward, &n_to_forward, tnow, nameptr, - namelen, isv6); - stats.pkts_data_count++; + { + hicn_new_data (vm, rt, b0, &to_forward, &n_to_forward, tnow, + nameptr, namelen, isv6); + stats.pkts_data_count++; + } } to_forward -= n_to_forward; diff --git a/hicn-plugin/src/params.h b/hicn-plugin/src/params.h index 5adafd7e6..f3af714ec 100644 --- a/hicn-plugin/src/params.h +++ b/hicn-plugin/src/params.h @@ -80,7 +80,7 @@ STATIC_ASSERT ((HICN_PARAM_PIT_ENTRY_PHOPS_MAX <= HICN_PARAM_FACES_MAX), #define HICN_PARAM_CS_LRU_DEFAULT (16 * 1024) /* CS lifetime defines, in mseconds, integer type */ -#define HICN_PARAM_CS_LIFETIME_MIN 100 +#define HICN_PARAM_CS_LIFETIME_MIN 0 #define HICN_PARAM_CS_LIFETIME_DFLT (5 * 60 * 1000) // 300 seconds #define HICN_PARAM_CS_LIFETIME_MAX (24 * 3600 * 1000) //24 hours... diff --git a/utils/src/ping_server.cc b/utils/src/ping_server.cc index 3a20dffd1..8e3c6a0ed 100644 --- a/utils/src/ping_server.cc +++ b/utils/src/ping_server.cc @@ -44,7 +44,7 @@ class CallbackContainer { public: CallbackContainer(const Name &prefix, uint32_t object_size, bool verbose, bool dump, bool quite, bool flags, bool reset, uint8_t ttl, - utils::Identity *identity, bool sign) + utils::Identity *identity, bool sign, uint32_t lifetime) : buffer_(object_size, 'X'), content_objects_((std::uint32_t)(1 << log2_content_object_buffer_size)), mask_((std::uint16_t)(1 << log2_content_object_buffer_size) - 1), @@ -74,12 +74,11 @@ class CallbackContainer { for (int i = 0; i < (1 << log2_content_object_buffer_size); i++) { content_objects_[i] = std::make_shared<ContentObject>( prefix, format, (const uint8_t *)buffer_.data(), buffer_.size()); - content_objects_[i]->setLifetime( - default_values::content_object_expiry_time); + content_objects_[i]->setLifetime(lifetime); } } - void processInterest(ProducerSocket &p, const Interest &interest) { + void processInterest(ProducerSocket &p, const Interest &interest, uint32_t lifetime) { if (verbose_) { std::cout << "<<< received interest " << interest.getName() << " src port: " << interest.getSrcPort() @@ -102,7 +101,7 @@ class CallbackContainer { auto &content_object = content_objects_[content_objects_index_++ & mask_]; content_object->setName(interest.getName()); - content_object->setLifetime(default_values::content_object_expiry_time); + content_object->setLifetime(lifetime); content_object->setLocator(interest.getLocator()); content_object->setSrcPort(interest.getDstPort()); content_object->setDstPort(interest.getSrcPort()); @@ -173,6 +172,7 @@ void help() { std::cout << "-f set tcp flags according to the flag received " "(default false)" << std::endl; + std::cout << "-l data lifetime" << std::endl; std::cout << "-r always reply with a reset flag (default false)" << std::endl; std::cout << "-t set ttl (default 64)" << std::endl; @@ -208,12 +208,13 @@ int main(int argc, char **argv) { std::string keystore_path = "./rsa_crypto_material.p12"; std::string keystore_password = "cisco"; bool sign = false; + uint32_t data_lifetime = default_values::content_object_expiry_time; int opt; #ifndef _WIN32 - while ((opt = getopt(argc, argv, "s:n:t:qfrVDdHk:p:")) != -1) { + while ((opt = getopt(argc, argv, "s:n:t:l:qfrVDdHk:p:")) != -1) { #else - while ((opt = getopt(argc, argv, "s:n:t:qfrVDHk:p:")) != -1) { + while ((opt = getopt(argc, argv, "s:n:t:l:qfrVDHk:p:")) != -1) { #endif switch (opt) { case 's': @@ -225,6 +226,9 @@ int main(int argc, char **argv) { case 't': ttl = (uint8_t)std::stoi(optarg); break; + case 'l': + data_lifetime = std::stoi(optarg); + break; case 'V': verbose = true; break; @@ -281,11 +285,11 @@ int main(int argc, char **argv) { if (sign) { stubs = new CallbackContainer(n, object_size, verbose, dump, quite, flags, - reset, ttl, &identity, sign); + reset, ttl, &identity, sign, data_lifetime); } else { utils::Identity *identity = nullptr; stubs = new CallbackContainer(n, object_size, verbose, dump, quite, flags, - reset, ttl, identity, sign); + reset, ttl, identity, sign, data_lifetime); } ProducerSocket p; @@ -295,7 +299,7 @@ int main(int argc, char **argv) { p.setSocketOption(ProducerCallbacksOptions::CACHE_MISS, (ProducerInterestCallback)bind( &CallbackContainer::processInterest, stubs, - std::placeholders::_1, std::placeholders::_2)); + std::placeholders::_1, std::placeholders::_2, data_lifetime)); p.connect(); |