summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2017-12-08 03:39:49 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-12-08 03:39:49 +0000
commit7aa26ff208ab6c33f38e49f6d9abea15e6697b8c (patch)
tree75d8e3c1eb47762b18c3acfb7705dbb1a596e259
parent1a7a553c5c03c60595fe1f13d4e3428f94b9c27d (diff)
parent2a3f72a8f9d00f4ffd0a9727d7854ebae740bcd0 (diff)
Merge "Fix checks done when changing generator pkt_size"
-rw-r--r--VNFs/DPPD-PROX/handle_gen.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/VNFs/DPPD-PROX/handle_gen.c b/VNFs/DPPD-PROX/handle_gen.c
index f8c99ee5..c48b4c13 100644
--- a/VNFs/DPPD-PROX/handle_gen.c
+++ b/VNFs/DPPD-PROX/handle_gen.c
@@ -790,31 +790,45 @@ static int check_all_pkt_size(struct task_gen *task, int do_panic)
return 0;
}
-static void check_fields_in_bounds(struct task_gen *task)
+static int check_fields_in_bounds(struct task_gen *task, uint32_t pkt_size, int do_panic)
{
- const uint32_t pkt_size = task->pkt_template[0].len;
-
if (task->lat_enabled) {
uint32_t pos_beg = task->lat_pos;
uint32_t pos_end = task->lat_pos + 3U;
- PROX_PANIC(pkt_size <= pos_end, "Writing latency at %u-%u, but packet size is %u bytes\n",
+ if (do_panic)
+ PROX_PANIC(pkt_size <= pos_end, "Writing latency at %u-%u, but packet size is %u bytes\n",
pos_beg, pos_end, pkt_size);
+ else if (pkt_size <= pos_end) {
+ plog_err("Writing latency at %u-%u, but packet size is %u bytes\n", pos_beg, pos_end, pkt_size);
+ return -1;
+ }
}
if (task->packet_id_pos) {
uint32_t pos_beg = task->packet_id_pos;
uint32_t pos_end = task->packet_id_pos + 4U;
- PROX_PANIC(pkt_size <= pos_end, "Writing packet at %u-%u, but packet size is %u bytes\n",
+ if (do_panic)
+ PROX_PANIC(pkt_size <= pos_end, "Writing packet at %u-%u, but packet size is %u bytes\n",
pos_beg, pos_end, pkt_size);
+ else if (pkt_size <= pos_end) {
+ plog_err("Writing packet at %u-%u, but packet size is %u bytes\n", pos_beg, pos_end, pkt_size);
+ return -1;
+ }
}
if (task->accur_pos) {
uint32_t pos_beg = task->accur_pos;
uint32_t pos_end = task->accur_pos + 3U;
- PROX_PANIC(pkt_size <= pos_end, "Writing accuracy at %u%-u, but packet size is %u bytes\n",
+ if (do_panic)
+ PROX_PANIC(pkt_size <= pos_end, "Writing accuracy at %u%-u, but packet size is %u bytes\n",
pos_beg, pos_end, pkt_size);
+ else if (pkt_size <= pos_end) {
+ plog_err("Writing accuracy at %u%-u, but packet size is %u bytes\n", pos_beg, pos_end, pkt_size);
+ return -1;
+ }
}
+ return 0;
}
static void task_gen_pkt_template_recalc_metadata(struct task_gen *task)
@@ -919,7 +933,7 @@ static void task_init_gen_load_pkt_inline(struct task_gen *task, struct task_arg
task->pkt_template_orig[0].len = targ->pkt_size;
task_gen_reset_pkt_templates(task);
check_all_pkt_size(task, 1);
- check_fields_in_bounds(task);
+ check_fields_in_bounds(task, task->pkt_template[0].len, 1);
}
static void task_init_gen_load_pcap(struct task_gen *task, struct task_args *targ)
@@ -976,10 +990,11 @@ int task_gen_set_pkt_size(struct task_base *tbase, uint32_t pkt_size)
struct task_gen *task = (struct task_gen *)tbase;
int rc;
- task->pkt_template[0].len = pkt_size;
- if ((rc = check_all_pkt_size(task, 0)) != 0)
+ if ((rc = check_pkt_size(task, pkt_size, 0)) != 0)
return rc;
- check_fields_in_bounds(task);
+ if ((rc = check_fields_in_bounds(task, pkt_size, 0)) != 0)
+ return rc;
+ task->pkt_template[0].len = pkt_size;
return rc;
}