diff options
Diffstat (limited to 'VNFs')
-rw-r--r-- | VNFs/DPPD-PROX/handle_esp.c | 9 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/handle_l2fwd.c | 28 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/handle_lat.c | 3 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/handle_swap.c | 36 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/lconf.c | 4 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/prox_args.c | 2 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/rx_pkt.c | 10 | ||||
-rw-r--r-- | VNFs/DPPD-PROX/task_base.h | 11 |
8 files changed, 59 insertions, 44 deletions
diff --git a/VNFs/DPPD-PROX/handle_esp.c b/VNFs/DPPD-PROX/handle_esp.c index ebdd2dcf..ab61f66c 100644 --- a/VNFs/DPPD-PROX/handle_esp.c +++ b/VNFs/DPPD-PROX/handle_esp.c @@ -309,7 +309,6 @@ static inline uint8_t handle_esp_ah_enc(struct task_esp_enc *task, struct rte_mb struct ether_addr dst_mac = peth->d_addr; uint32_t src_addr = pip4->src_addr; uint32_t dst_addr = pip4->dst_addr; - uint8_t ttl = pip4->time_to_live; uint8_t version_ihl = pip4->version_ihl; peth = (struct ether_hdr *)rte_pktmbuf_prepend(mbuf, extra_space); // encap + prefix @@ -329,13 +328,14 @@ static inline uint8_t handle_esp_ah_enc(struct task_esp_enc *task, struct rte_mb pip4 = (struct ipv4_hdr *)(peth + 1); pip4->src_addr = task->local_ipv4; pip4->dst_addr = task->remote_ipv4; - pip4->time_to_live = ttl; pip4->next_proto_id = IPPROTO_ESP; // 50 for ESP, ip in ip next proto trailer pip4->version_ihl = version_ihl; // 20 bytes, ipv4 pip4->total_length = rte_cpu_to_be_16(ipv4_length + sizeof(struct ipv4_hdr) + 4 + 4 + CIPHER_IV_LENGTH_AES_CBC + padding + 1 + 1 + DIGEST_BYTE_LENGTH_SHA1); // iphdr+SPI+SN+IV+payload+padding+padlen+next header + crc + auth pip4->packet_id = 0x0101; pip4->type_of_service = 0; pip4->time_to_live = 64; + pip4->fragment_offset = rte_cpu_to_be_16(0x4000); + pip4->hdr_checksum = 0; prox_ip_cksum_sw(pip4); //find the SA when there will be more than one @@ -458,12 +458,11 @@ static inline uint8_t handle_esp_ah_dec_finish(struct task_esp_dec *task, struct int len = rte_pktmbuf_pkt_len(mbuf); rte_pktmbuf_trim(mbuf, len - sizeof (struct ether_hdr) - ipv4_length); - prox_ip_cksum_sw(pip4); - peth = rte_pktmbuf_mtod(mbuf, struct ether_hdr *); - #if 1 do_ipv4_swap(task, mbuf); #endif + pip4->hdr_checksum = 0; + prox_ip_cksum_sw(pip4); // one key for them all for now // set key // struct crypto_aes_ctx ctx; diff --git a/VNFs/DPPD-PROX/handle_l2fwd.c b/VNFs/DPPD-PROX/handle_l2fwd.c index 79a5f02e..faebe6fb 100644 --- a/VNFs/DPPD-PROX/handle_l2fwd.c +++ b/VNFs/DPPD-PROX/handle_l2fwd.c @@ -69,17 +69,21 @@ static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ) struct ether_addr *src_addr, *dst_addr; /* - * Destination MAC can come from - * - pre-configured mac in case 'dst mac=xx:xx:xx:xx:xx:xx' in config file - * - src mac from the packet in case 'dst mac=packet' in config file - * - not written in case 'dst mac=no' in config file - * - (default - no 'dst mac') src mac from the packet - * Source MAC can come from - * - pre-configured mac in case 'src mac=xx:xx:xx:xx:xx:xx' in config file - * - dst mac from the packet in case 'src mac=packet' in config file - * - not written in case 'src mac=no' in config file - * - (default - no 'src mac') if (tx_port) port mac - * - (default - no 'src mac') if (no tx_port) dst mac from the packet + * The destination MAC of the outgoing packet is based on the config file: + * - 'dst mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as dst mac + * - 'dst mac=packet' => the src mac of the incoming packet is used as dst mac + * - 'dst mac=no' => the dst mac is untouched + * - (default - no 'dst mac') => the src mac from the incoming packet is used as dst mac + * + * The source MAC of the outgoing packet is based on the config file: + * - 'src mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as src mac + * - 'src mac=packet' => the dst mac of the incoming packet is used as src mac + * - 'src mac=hw' => the mac address of the tx port is used as src mac + * An error is returned if there are no physical tx ports + * - 'src mac=no' => the src mac is untouched + * - (default - no 'src mac') => if there is physical tx port, the mac of that port is used as src mac + * - (default - no 'src mac') if there are no physical tx ports the dst mac of the incoming packet + is used as src mac */ if (targ->flags & TASK_ARG_DST_MAC_SET) { @@ -92,6 +96,8 @@ static void init_task_l2fwd(struct task_base *tbase, struct task_args *targ) memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); plog_info("\t\tCore %d: src mac set from config file\n", targ->lconf->id); } else if ((targ->flags & TASK_ARG_DO_NOT_SET_SRC_MAC) == 0) { + if (targ->flags & TASK_ARG_HW_SRC_MAC) + PROX_PANIC(targ->nb_txports == 0, "src mac set to hw but no tx port\n"); if (targ->nb_txports) { src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr; targ->flags |= TASK_ARG_SRC_MAC_SET; diff --git a/VNFs/DPPD-PROX/handle_lat.c b/VNFs/DPPD-PROX/handle_lat.c index 0b7ad561..95ebcc73 100644 --- a/VNFs/DPPD-PROX/handle_lat.c +++ b/VNFs/DPPD-PROX/handle_lat.c @@ -611,6 +611,9 @@ static void init_task_lat(struct task_base *tbase, struct task_args *targ) task->lat_pos = targ->lat_pos; task->accur_pos = targ->accur_pos; + task->sig_pos = targ->sig_pos; + task->sig = targ->sig; + task->unique_id_pos = targ->packet_id_pos; task->latency_buffer_size = targ->latency_buffer_size; diff --git a/VNFs/DPPD-PROX/handle_swap.c b/VNFs/DPPD-PROX/handle_swap.c index 516d3f63..68dfe2b4 100644 --- a/VNFs/DPPD-PROX/handle_swap.c +++ b/VNFs/DPPD-PROX/handle_swap.c @@ -203,17 +203,18 @@ static void init_task_swap(struct task_base *tbase, struct task_args *targ) struct ether_addr *src_addr, *dst_addr; /* - * Destination MAC can come from - * - pre-configured mac in case 'dst mac=xx:xx:xx:xx:xx:xx' in config file - * - src mac from the packet in case 'dst mac=packet' in config file - * - not written in case 'dst mac=no' in config file - * - (default - no 'dst mac') src mac from the packet - * Source MAC can come from - * - pre-configured mac in case 'src mac=xx:xx:xx:xx:xx:xx' in config file - * - dst mac from the packet in case 'src mac=packet' in config file - * - not written in case 'src mac=no' in config file - * - (default - no 'src mac') if (tx_port) port mac - * - (default - no 'src mac') if (no tx_port) dst mac from the packet + * The destination MAC of the outgoing packet is based on the config file: + * - 'dst mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as dst mac + * - 'dst mac=packet' => the src mac of the incoming packet is used as dst mac + * - (default - no 'dst mac') => the src mac from the incoming packet is used as dst mac + * + * The source MAC of the outgoing packet is based on the config file: + * - 'src mac=xx:xx:xx:xx:xx:xx' => the pre-configured mac will be used as src mac + * - 'src mac=packet' => the dst mac of the incoming packet is used as src mac + * - 'src mac=hw' => the mac address of the tx port is used as src mac + * An error is returned if there are no physical tx ports + * - (default - no 'src mac') => if there is physical tx port, the mac of that port is used as src mac + * - (default - no 'src mac') if there are no physical tx ports the dst mac of the incoming packet */ if (targ->flags & TASK_ARG_DST_MAC_SET) { @@ -221,14 +222,19 @@ static void init_task_swap(struct task_base *tbase, struct task_args *targ) memcpy(&task->src_dst_mac[0], dst_addr, sizeof(*src_addr)); } + PROX_PANIC(targ->flags & TASK_ARG_DO_NOT_SET_SRC_MAC, "src mac must be set in swap mode, by definition => src mac=no is not supported\n"); + PROX_PANIC(targ->flags & TASK_ARG_DO_NOT_SET_DST_MAC, "dst mac must be set in swap mode, by definition => dst mac=no is not supported\n"); + if (targ->flags & TASK_ARG_SRC_MAC_SET) { src_addr = &targ->esaddr; memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); plog_info("\t\tCore %d: src mac set from config file\n", targ->lconf->id); - } else if (targ->nb_txports) { - src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr; - memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); - if (targ->flags & TASK_ARG_HW_SRC_MAC){ + } else { + if (targ->flags & TASK_ARG_HW_SRC_MAC) + PROX_PANIC(targ->nb_txports == 0, "src mac set to hw but no tx port\n"); + if (targ->nb_txports) { + src_addr = &prox_port_cfg[task->base.tx_params_hw.tx_port_queue[0].port].eth_addr; + memcpy(&task->src_dst_mac[6], src_addr, sizeof(*dst_addr)); targ->flags |= TASK_ARG_SRC_MAC_SET; plog_info("\t\tCore %d: src mac set from port\n", targ->lconf->id); } diff --git a/VNFs/DPPD-PROX/lconf.c b/VNFs/DPPD-PROX/lconf.c index 399c8a7d..682c106f 100644 --- a/VNFs/DPPD-PROX/lconf.c +++ b/VNFs/DPPD-PROX/lconf.c @@ -307,10 +307,10 @@ int lconf_do_flags(struct lcore_cfg *lconf) t = lconf->tasks_all[task_id]; if (t->aux->tx_pkt_orig) { if (t->tx_pkt == tx_pkt_l3) { - t->tx_pkt = t->aux->tx_pkt_orig; + t->aux->tx_pkt_l2 = t->aux->tx_pkt_orig; t->aux->tx_pkt_orig = NULL; } else { - t->aux->tx_pkt_l2 = t->aux->tx_pkt_orig; + t->tx_pkt = t->aux->tx_pkt_orig; t->aux->tx_pkt_orig = NULL; } lconf->flags &= ~LCONF_FLAG_TX_DISTR_ACTIVE; diff --git a/VNFs/DPPD-PROX/prox_args.c b/VNFs/DPPD-PROX/prox_args.c index 97b4fb15..fb053802 100644 --- a/VNFs/DPPD-PROX/prox_args.c +++ b/VNFs/DPPD-PROX/prox_args.c @@ -1293,7 +1293,7 @@ static int get_core_cfg(unsigned sindex, char *str, void *data) } else if (STR_EQ(pkey, "packet")) return 0; - else if (STR_EQ(pkey, "packet")) { + else if (STR_EQ(pkey, "hw")) { targ->flags |= TASK_ARG_HW_SRC_MAC; return 0; } else { diff --git a/VNFs/DPPD-PROX/rx_pkt.c b/VNFs/DPPD-PROX/rx_pkt.c index ec698d9a..bd06b267 100644 --- a/VNFs/DPPD-PROX/rx_pkt.c +++ b/VNFs/DPPD-PROX/rx_pkt.c @@ -388,13 +388,9 @@ static uint16_t call_prev_rx_pkt(struct task_base *tbase, struct rte_mbuf ***mbu { uint16_t ret; - if (tbase->aux->rx_prev_idx + 1 == tbase->aux->rx_prev_count) { - ret = tbase->aux->rx_pkt_prev[tbase->aux->rx_prev_idx](tbase, mbufs); - } else { - tbase->aux->rx_prev_idx++; - ret = tbase->aux->rx_pkt_prev[tbase->aux->rx_prev_idx](tbase, mbufs); - tbase->aux->rx_prev_idx--; - } + tbase->aux->rx_prev_idx++; + ret = tbase->aux->rx_pkt_prev[tbase->aux->rx_prev_idx - 1](tbase, mbufs); + tbase->aux->rx_prev_idx--; return ret; } diff --git a/VNFs/DPPD-PROX/task_base.h b/VNFs/DPPD-PROX/task_base.h index ad00962f..f8c05242 100644 --- a/VNFs/DPPD-PROX/task_base.h +++ b/VNFs/DPPD-PROX/task_base.h @@ -213,8 +213,8 @@ static void task_base_add_rx_pkt_function(struct task_base *tbase, rx_pkt_func t return; } - for (int16_t i = tbase->aux->rx_prev_count; i >= 0; --i) { - tbase->aux->rx_pkt_prev[i + 1] = tbase->aux->rx_pkt_prev[i]; + for (int16_t i = tbase->aux->rx_prev_count; i > 0; --i) { + tbase->aux->rx_pkt_prev[i] = tbase->aux->rx_pkt_prev[i - 1]; } tbase->aux->rx_pkt_prev[0] = tbase->rx_pkt; tbase->rx_pkt = to_add; @@ -226,8 +226,13 @@ static void task_base_del_rx_pkt_function(struct task_base *tbase, rx_pkt_func t int cur = 0; int found = 0; - if (tbase->aux->rx_prev_count == 1) { + if (unlikely(tbase->aux->rx_prev_count == 0)) { + return; + } else if (tbase->rx_pkt == to_del) { tbase->rx_pkt = tbase->aux->rx_pkt_prev[0]; + for (int16_t i = 0; i < tbase->aux->rx_prev_count - 1; ++i) { + tbase->aux->rx_pkt_prev[i] = tbase->aux->rx_pkt_prev[i + 1]; + } found = 1; } else { for (int16_t i = 0; i < tbase->aux->rx_prev_count; ++i) { |