From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id 21A4F1322C for ; Thu, 28 Dec 2017 05:56:11 +0100 (CET) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id vBS4uAQo025205 for unknown; Thu, 28 Dec 2017 13:56:10 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id vBS4u8aR027384 for unknown; Thu, 28 Dec 2017 13:56:08 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id PAA27374; Thu, 28 Dec 2017 13:56:08 +0900 Received: from imss03.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id vBS4u71Z011132 for unknown; Thu, 28 Dec 2017 13:56:07 +0900 Received: from mgate01.silk.ntt-tx.co.jp (smtp02.silk.ntt-tx.co.jp [10.107.0.37]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id vBS4u7KW011101 for unknown; Thu, 28 Dec 2017 13:56:07 +0900 Message-Id: <201712280456.vBS4u7KW011101@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate01.silk.ntt-tx.co.jp (unknown) id vBS4u4bH025622 ; Thu, 28 Dec 2017 13:56:07 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: spp@dpdk.org Date: Thu, 28 Dec 2017 13:55:50 +0900 X-Mailer: git-send-email 1.9.1 In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> References: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> X-TM-AS-MML: No Subject: [spp] [PATCH 43/57] spp_vf: update command decode procedure X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Dec 2017 04:56:12 -0000 From: Hiroyuki Nakamura update command decode procedures due to the change of command request format (fix bugs caused by the change.) * Fix bugs in comditional statements and loop index. * Fix index of received character array. * Add initializeion of received commands counter. Signed-off-by: Kentaro Watanabe Signed-off-by: Yasufum Ogawa --- src/vf/command_dec.c | 21 ++++++++++++--------- src/vf/command_proc.c | 6 ++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/vf/command_dec.c b/src/vf/command_dec.c index 468702f..75619d9 100644 --- a/src/vf/command_dec.c +++ b/src/vf/command_dec.c @@ -63,7 +63,7 @@ static int get_arrary_index(const char *match, const char *list[]) { int i; - for (i = 0; list[i][0] == '\0'; i++) { + for (i = 0; list[i][0] != '\0'; i++) { if (strcmp(list[i], match) == 0) return i; } @@ -113,7 +113,7 @@ decode_classifier_type_value(void *output, const char *arg_val) { int ret = 0; ret = get_arrary_index(arg_val, CLASSIFILER_TYPE_STRINGS); - if (unlikely(ret < 0)) { + if (unlikely(ret <= 0)) { RTE_LOG(ERR, SPP_COMMAND_PROC, "Unknown classifier type. val=%s\n", arg_val); return -1; } @@ -196,13 +196,14 @@ check_comand_argment_in_list(struct spp_command_request *request, int ci = request->commands[0].type; int pi = 0; static struct decode_parameter_list *list = NULL; - for(pi = 1; pi < argc-1; pi++) { - list = ¶meter_list[ci][pi]; + for(pi = 1; pi < argc; pi++) { + list = ¶meter_list[ci][pi-1]; +RTE_LOG(ERR, SPP_COMMAND_PROC, "TEST: command=%s, name=%s, index=%d, value=%s\n", argv[0], list->name, pi, argv[pi]); ret = (*list->func)((void *)((char*)&request->commands[0]+list->offset), argv[pi]); if (unlikely(ret < 0)) { RTE_LOG(ERR, SPP_COMMAND_PROC, - "Bad value. command = %s, name=%s, index=%d\n", - argv[0], list->name, pi); + "Bad value. command=%s, name=%s, index=%d, value=%s\n", + argv[0], list->name, pi, argv[pi]); return set_string_value_decode_error(error, argv[pi], list->name); } } @@ -241,8 +242,6 @@ decode_command_argment(struct spp_command_request *request, memset(argv, 0x00, sizeof(argv)); memset(tmp_str, 0x00, sizeof(tmp_str)); - request->num_command = 1; - strcpy(tmp_str, request_str); decode_argument_value(tmp_str, &argc, argv); RTE_LOG(DEBUG, SPP_COMMAND_PROC, "Decode array. num=%d\n", argc); @@ -279,14 +278,18 @@ spp_command_decode_request(struct spp_command_request *request, const char *requ int ret = -1; int i; +RTE_LOG(ERR, SPP_COMMAND_PROC, "ERROR:request_str=%s\n", request_str); /* decode request */ + request->num_command = 1; ret = decode_command_argment(request, request_str, error); - if (unlikely(ret < 0)) { + if (unlikely(ret != 0)) { RTE_LOG(ERR, SPP_COMMAND_PROC, "Cannot decode command request. " "ret=%d, request_str=%.*s\n", ret, (int)request_str_len, request_str); return ret; } + request->num_valid_command = 1; +RTE_LOG(ERR, SPP_COMMAND_PROC, "ERROR:command type=%d\n", request->commands[0].type); /* check getter command */ for (i = 0; i < request->num_valid_command; ++i) { diff --git a/src/vf/command_proc.c b/src/vf/command_proc.c index 0dd1d56..ef1ae81 100644 --- a/src/vf/command_proc.c +++ b/src/vf/command_proc.c @@ -462,7 +462,6 @@ spp_command_proc_do(void) static int sock = -1; static char *msgbuf = NULL; - static size_t msg_len = 0; if (unlikely(msgbuf == NULL)) { msgbuf = spp_strbuf_allocate(CMD_REQ_BUF_INIT_SIZE); @@ -487,9 +486,8 @@ spp_command_proc_do(void) return -1; } - msg_len += (msg_ret + 1); - ret = process_request(&sock, msgbuf, msg_len); - spp_strbuf_remove_front(msgbuf, msg_len); + ret = process_request(&sock, msgbuf, msg_ret); + spp_strbuf_remove_front(msgbuf, msg_ret); return 0; } -- 1.9.1