diff options
author | Xavier Simonart <xavier.simonart@intel.com> | 2017-12-06 16:18:05 +0100 |
---|---|---|
committer | Xavier Simonart <xavier.simonart@intel.com> | 2017-12-06 16:18:05 +0100 |
commit | 8a5807543421c33556b7ab6f76f8a7bd234703aa (patch) | |
tree | 56b38721cf0188fe5c4143b38258c2b2f01bef8f | |
parent | e430f537cad603a131034d01068af7757142743d (diff) |
Fix command parser
Command parser could have been crashing if a wrong core/task was
used in pkt_size command. For some other commands both an error
and a warning were printed in case of errors.
Change-Id: I6648bfca1b5bcde3c6393d49687ed84900326d49
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
-rw-r--r-- | VNFs/DPPD-PROX/cmd_parser.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/VNFs/DPPD-PROX/cmd_parser.c b/VNFs/DPPD-PROX/cmd_parser.c index f61fbe45..18a4f5fc 100644 --- a/VNFs/DPPD-PROX/cmd_parser.c +++ b/VNFs/DPPD-PROX/cmd_parser.c @@ -401,10 +401,10 @@ static int parse_cmd_set_probability(const char *str, struct input *input) lcore_id = lcores[i]; if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){ plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); - return -1; + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_proba(tbase, probability); } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - task_impair_set_proba(tbase, probability); } } return 0; @@ -426,10 +426,10 @@ static int parse_cmd_delay_us(const char *str, struct input *input) lcore_id = lcores[i]; if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){ plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); - return -1; + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_delay_us(tbase, delay_us, 0); } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - task_impair_set_delay_us(tbase, delay_us, 0); } } return 0; @@ -451,10 +451,10 @@ static int parse_cmd_random_delay_us(const char *str, struct input *input) lcore_id = lcores[i]; if ((!task_is_mode_and_submode(lcore_id, task_id, "impair", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "impair", "l3"))){ plog_err("Core %u task %u is not impairing packets\n", lcore_id, task_id); - return -1; + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_impair_set_delay_us(tbase, 0, delay_us); } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - task_impair_set_delay_us(tbase, 0, delay_us); } } return 0; @@ -513,11 +513,10 @@ static int parse_cmd_pkt_size(const char *str, struct input *input) lcore_id = lcores[i]; if ((!task_is_mode_and_submode(lcore_id, task_id, "gen", "")) && (!task_is_mode_and_submode(lcore_id, task_id, "gen", "l3"))) { plog_err("Core %u task %u is not generating packets\n", lcore_id, task_id); + } else { + struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; + task_gen_set_pkt_size(tbase, pkt_size); /* error printed within function */ } - struct task_base *tbase = lcore_cfg[lcore_id].tasks_all[task_id]; - - if (task_gen_set_pkt_size(tbase, pkt_size) != 0) - return -1; } } return 0; |