diff options
| author | songyanchao <[email protected]> | 2022-04-20 04:17:54 -0400 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2022-04-20 04:18:51 -0400 |
| commit | 6ffddf81cf32bf823cd2d45bb44a30865c34f237 (patch) | |
| tree | 1d8b35b160ae06701580eb3be4f24f2786f2ef64 | |
| parent | 6d2c7ea1423c8f10bf303969c91391e79fbdde4b (diff) | |
🎈 perf(TSG-10188): 优化request result 函数v4.5.2-20220420
优化request result 函数,设置日志级别
TSG-10188
| -rw-r--r-- | infra/include/common.h | 12 | ||||
| -rw-r--r-- | service/include/sc_flow.h | 1 | ||||
| -rw-r--r-- | service/src/flow_manage.c | 301 | ||||
| -rw-r--r-- | tools/mrctl/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | tools/mrctl/mrctl.c | 248 |
5 files changed, 269 insertions, 296 deletions
diff --git a/infra/include/common.h b/infra/include/common.h index 51ebb98..ea43691 100644 --- a/infra/include/common.h +++ b/infra/include/common.h @@ -11,7 +11,7 @@ extern "C" { #include <rte_common.h> #ifndef MR_STRING_MAX -#define MR_STRING_MAX 2048 +#define MR_STRING_MAX 4096 #endif #ifndef MR_SYMBOL_MAX @@ -57,7 +57,7 @@ extern "C" { #ifndef MR_PHYDEV_MAX #define MR_PHYDEV_MAX RTE_MAX_ETHPORTS #endif - + typedef uint64_t cpu_mask_t; typedef uint32_t port_id_t; typedef uint32_t queue_id_t; @@ -169,7 +169,7 @@ do { curser += snprintf(__local_fmt + curser, sizeof(__local_fmt) - curser, \ fmt, ## __VA_ARGS__); \ MR_WARNING("%s", __local_fmt); \ -} while(0) +} while(0) static inline const char * __str_rte_errno() { @@ -229,7 +229,7 @@ static inline int parser_uint(const char * str) //TODO: 支持更多比特位的掩码 typedef uint64_t mask_t; - + /* ================================= MASK ======================================== */ static unsigned int inline mask_popcnt(mask_t mask) { @@ -276,7 +276,7 @@ static int inline str_to_mask(const char * str, mask_t * out_mask) nr_str_tokens++; __mask |= 1ULL << core_id; } - + if (nr_str_tokens == 0) goto errout; *out_mask = __mask; @@ -299,7 +299,7 @@ static inline void timespec_diff(struct timespec * start, struct timespec * end, result->tv_sec = end->tv_sec - start->tv_sec; result->tv_nsec = end->tv_nsec - start->tv_nsec; } - + return; } diff --git a/service/include/sc_flow.h b/service/include/sc_flow.h index 6ad8232..58861d7 100644 --- a/service/include/sc_flow.h +++ b/service/include/sc_flow.h @@ -639,6 +639,7 @@ union mr_flow_action_union struct mr_flow_action_set_mac set_src_mac; struct mr_flow_action_set_mac set_dst_mac; }; + /* Rule */ struct mrctl_flow_rule { diff --git a/service/src/flow_manage.c b/service/src/flow_manage.c index fb22876..f5f1890 100644 --- a/service/src/flow_manage.c +++ b/service/src/flow_manage.c @@ -7,7 +7,7 @@ #include <sc_common.h> #include <sc_flow.h> -/* Json Parse */ +/* Json Parse Err */ #define MR_FLOW_CREAT_SUCCESS "Flow Create Success" #define MR_FLOW_DELETE_SUCCESS "Flow Delete Success" #define MR_FLOW_DELETE_ERR "The Deletion Pperation Is Not Supported" @@ -163,51 +163,30 @@ struct mr_flow * mr_get_free_flow(struct sc_main * sc) void mr_flow_print(uint16_t port_id , struct rte_flow_attr * attr, uint64_t item_num, struct rte_flow_item * items, uint64_t action_num, struct rte_flow_action * actions) { int i = 0; - MR_INFO("---------- Flow Creat ----------"); - MR_INFO("Port ID: %u",port_id); + MR_DEBUG("---------- Flow Creat ----------"); + MR_DEBUG("Port ID: %u",port_id); /* Attr */ - MR_INFO("---------- Attr ----------"); - MR_INFO("Group: %u",attr->group); - MR_INFO("Priority: %u",attr->priority); - MR_INFO("Ingress: %u",attr->ingress); - MR_INFO("Egress: %u",attr->egress); + MR_DEBUG("---------- Attr ----------"); + MR_DEBUG("Group: %u",attr->group); + MR_DEBUG("Priority: %u",attr->priority); + MR_DEBUG("Ingress: %u",attr->ingress); + MR_DEBUG("Egress: %u",attr->egress); /* Item */ - MR_INFO("---------- Item----------"); + MR_DEBUG("---------- Item----------"); for (i = 0; i <= item_num; i++) { - MR_INFO("Type: %u\n",items[i].type); + MR_DEBUG("Type: %u\n",items[i].type); } /* Action */ - MR_INFO("---------- Action----------"); + MR_DEBUG("---------- Action----------"); for (i = 0; i <= action_num; i++) { - MR_INFO("Type: %u\n",actions[i].type); + MR_DEBUG("Type: %u\n",actions[i].type); } } -/* Send Create Request Result Msg */ -void send_create_request_result_msg(struct ctrlmsg_handler * ct_hand, struct ctrlmsg_conn * ct_conn, int result,char * str) -{ - struct ctrl_msg_flow_response rep_msg; - - memset(&rep_msg, 0, sizeof(rep_msg)); - - ctrl_msg_header_construct(&rep_msg.msg_header, sizeof(rep_msg), CTRL_MSG_TYPE_RESPONSE, CTRLMSG_TOPIC_FLOW_CREATE); - - rep_msg.msg_err.errcode = result; - - if (result == RT_ERR) - { - cJSON * cjson_error = cJSON_CreateObject(); - cJSON_AddStringToObject(cjson_error, MR_CJSON_KEY_ERROR_INFO, str); - char * str_error_info = cJSON_Print(cjson_error); - snprintf((char *)rep_msg.msg_err.strerr, sizeof(rep_msg.msg_err.strerr), "%s", str_error_info); - } - ctrlmsg_msg_send(ct_hand, ct_conn, (struct ctrl_msg_header*)&rep_msg); -} - /* Send Request Result Msg */ int send_request_result_msg(struct ctrlmsg_handler * ct_hand, struct ctrlmsg_conn * ct_conn, int result,char * str,const char * tocpi) { @@ -235,27 +214,6 @@ int send_request_result_msg(struct ctrlmsg_handler * ct_hand, struct ctrlmsg_con } return ctrlmsg_msg_send(ct_hand, ct_conn, (struct ctrl_msg_header*)&rep_msg); } -/* Send Request Result Msg */ -void send_delete_request_result_msg(struct ctrlmsg_handler * ct_hand, struct ctrlmsg_conn * ct_conn, int result,char * str) -{ - struct ctrl_msg_flow_response rep_msg; - - memset(&rep_msg, 0, sizeof(rep_msg)); - - ctrl_msg_header_construct(&rep_msg.msg_header, sizeof(rep_msg), CTRL_MSG_TYPE_RESPONSE, CTRLMSG_TOPIC_FLOW_DELETE); - - rep_msg.msg_err.errcode = result; - - if (result == RT_ERR) - { - cJSON * cjson_error = cJSON_CreateObject(); - cJSON_AddStringToObject(cjson_error, MR_CJSON_KEY_ERROR_INFO, str); - char * str_error_info = cJSON_Print(cjson_error); - snprintf((char *)rep_msg.msg_err.strerr, sizeof(rep_msg.msg_err.strerr), "%s", str_error_info); - } - ctrlmsg_msg_send(ct_hand, ct_conn, (struct ctrl_msg_header*)&rep_msg); -} - /* Parsing Json For Create Request */ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg_conn * ct_conn,char * rule_string, struct mrctl_flow_rule * rule_item) @@ -266,7 +224,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * j_cmd = cJSON_Parse(rule_string); if (j_cmd == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -274,7 +232,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_prot_name = cJSON_GetObjectItem(j_cmd,MR_CJSON_KEY_PORT_NAME); if (cj_prot_name == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_PORT_NAME_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_PORT_NAME_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } else @@ -286,7 +244,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_rule_type = cJSON_GetObjectItem(j_cmd,MR_CJSON_KEY_RULE_TYPE); if (cj_rule_type == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_RULE_TYPE_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_RULE_TYPE_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } else @@ -298,7 +256,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_attr = cJSON_GetObjectItem(j_cmd,MR_CJSON_KEY_ATTR); if (cj_attr == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } else @@ -307,7 +265,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_attr_arg_flag = cJSON_GetObjectItem(cj_attr,MR_CJSON_KEY_ARG_FLAG); if (cj_attr_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->attrs.arg_flag = (uint16_t)cj_attr_arg_flag->valuedouble; @@ -318,7 +276,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_attr_group = cJSON_GetObjectItem(cj_attr,MR_CJSON_KEY_ATTR_GROUP); if (cj_attr_group == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_GROUP_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_GROUP_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->attrs.attr.group = (uint32_t) cj_attr_group->valuedouble; @@ -330,7 +288,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_attr_priority = cJSON_GetObjectItem(cj_attr,MR_CJSON_KEY_ATTR_PRIORITY); if (cj_attr_priority == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_PRIORITY_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ATTR_PRIORITY_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->attrs.attr.priority = (uint32_t) cj_attr_priority->valuedouble; @@ -342,7 +300,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_attr_ingress = cJSON_GetObjectItem(cj_attr,MR_CJSON_KEY_ATTR_INGRESS); if (cj_attr_ingress == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_INGRESS_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_INGRESS_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->attrs.attr.ingress = MR_RULE_ARG_ENABLE; @@ -354,7 +312,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_attr_egress = cJSON_GetObjectItem(cj_attr,MR_CJSON_KEY_ATTR_EGRESS); if (cj_attr_egress == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_EGRESS_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_EGRESS_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->attrs.attr.egress = MR_RULE_ARG_ENABLE; @@ -365,7 +323,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_items = cJSON_GetObjectItem(j_cmd,MR_CJSON_KEY_ITEMS); if (cj_items == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } else @@ -375,7 +333,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_items_list = cJSON_GetObjectItem(cj_items,MR_CJSON_KEY_ITEM_LIST); if (cj_items_list == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_LIST_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_LIST_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->item_list = item_list = (uint16_t)cj_items_list->valuedouble; @@ -383,13 +341,13 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_items_num = cJSON_GetObjectItem(cj_items,MR_CJSON_KEY_ITEM_NUM); if (cj_items_num == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_NUM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_NUM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->item_num = (uint64_t)cj_items_num->valuedouble; if (rule_item->item_num > MR_MAX_ITEM_NUM) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_NUM_OUT_OF_MAX_NUM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ITEM_NUM_OUT_OF_MAX_NUM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -406,7 +364,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item = cJSON_GetObjectItem(cj_items,MR_CJSON_KEY_ETHER); if (cj_ether_item == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -414,7 +372,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item_arg_flag = cJSON_GetObjectItem(cj_ether_item,MR_CJSON_KEY_ARG_FLAG); if (cj_ether_item_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ether_item->arg_flag = (uint16_t)cj_ether_item_arg_flag->valuedouble; @@ -425,7 +383,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item_hasvlan = cJSON_GetObjectItem(cj_ether_item,MR_CJSON_KEY_ETHER_HASVLAN); if (cj_ether_item_hasvlan == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_HAS_VLAN_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_HAS_VLAN_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ether_item->has_vlan = (uint8_t)cj_ether_item_hasvlan->valuedouble; @@ -437,12 +395,12 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item_smac = cJSON_GetObjectItem(cj_ether_item,MR_CJSON_KEY_ETHER_SMAC); if (cj_ether_item_smac == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } if(string_to_mac(cj_ether_item_smac->valuestring,ðer_item->ether_hdr.s_addr) == RT_ERR) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_FORMAT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } } @@ -453,12 +411,12 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item_dmac = cJSON_GetObjectItem(cj_ether_item,MR_CJSON_KEY_ETHER_DMAC); if (cj_ether_item_dmac == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } if(string_to_mac(cj_ether_item_dmac->valuestring,ðer_item->ether_hdr.d_addr) == RT_ERR) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_FORMAT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } } @@ -469,12 +427,12 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item_smac_mask = cJSON_GetObjectItem(cj_ether_item,MR_CJSON_KEY_ETHER_SMAC_MASK); if (cj_ether_item_smac_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } if(string_to_mac(cj_ether_item_smac_mask->valuestring,ðer_item->smac_mask) == RT_ERR) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_MASK_FORMAT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_SMAC_MASK_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } } @@ -485,12 +443,12 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item_dmac_mask = cJSON_GetObjectItem(cj_ether_item,MR_CJSON_KEY_ETHER_DMAC_MASK); if (cj_ether_item_dmac_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } if(string_to_mac(cj_ether_item_dmac_mask->valuestring,ðer_item->dmac_mask) == RT_ERR) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_MASK_FORMAT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_DMAC_MASK_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } } @@ -501,7 +459,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ether_item_type = cJSON_GetObjectItem(cj_ether_item,MR_CJSON_KEY_ETHER_TYPE); if (cj_ether_item_type == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_TYPE_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ETHER_ITEM_TYPE_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ether_item->ether_hdr.ether_type = htons((uint16_t)cj_ether_item_type->valuedouble); @@ -521,7 +479,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item = cJSON_GetObjectItem(cj_items,MR_CJSON_KEY_IPV4); if (cj_ipv4_item == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -529,7 +487,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_arg_flag = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_ARG_FLAG); if (cj_ipv4_item_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ipv4_item->arg_flag = (uint16_t)cj_ipv4_item_arg_flag->valuedouble; @@ -540,7 +498,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_tos = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_TOS); if (cj_ipv4_item_tos == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_TOS_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_TOS_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ipv4_item->ipv4_hdr.type_of_service = (uint8_t)cj_ipv4_item_tos->valuedouble; @@ -552,11 +510,11 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_fragement_offset = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_FRAGMENT_OFFSET); if (cj_ipv4_item_fragement_offset == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_FRAGEMENT_OFFSET_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_FRAGEMENT_OFFSET_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } /* Not Support Fragement Offset,Because Prompt: Flow can't be created 13 message: specified value not supported */ - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_FRAGEMENT_NOT_SUPPORT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_FRAGEMENT_NOT_SUPPORT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; ipv4_item->ipv4_hdr.fragment_offset = htons((uint16_t)cj_ipv4_item_fragement_offset->valuedouble); } @@ -567,7 +525,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_ttl = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_TTL); if (cj_ipv4_item_ttl == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_TTL_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_TTL_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ipv4_item->ipv4_hdr.time_to_live = (uint8_t)cj_ipv4_item_ttl->valuedouble; @@ -579,7 +537,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_next_proto = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_NEXT_PROTO); if (cj_ipv4_item_next_proto == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_NEXT_PROTO_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_NEXT_PROTO_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ipv4_item->ipv4_hdr.next_proto_id = (uint8_t)cj_ipv4_item_next_proto->valuedouble; @@ -592,7 +550,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_src_addr = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_SADDR); if (cj_ipv4_item_src_addr == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_SRC_ADDR_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_SRC_ADDR_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ipv4_item->ipv4_hdr.src_addr = (uint32_t)cj_ipv4_item_src_addr->valuedouble; @@ -604,7 +562,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_src_addr_mask = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_SADDR_MASK); if (cj_ipv4_item_src_addr_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_SRC_ADDR_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_SRC_ADDR_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -617,7 +575,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_dst_addr = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_DADDR); if (cj_ipv4_item_dst_addr == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_DST_ADDR_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_DST_ADDR_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ipv4_item->ipv4_hdr.dst_addr = (uint32_t)cj_ipv4_item_dst_addr->valuedouble; @@ -629,7 +587,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_ipv4_item_dst_addr_mask = cJSON_GetObjectItem(cj_ipv4_item,MR_CJSON_KEY_IPV4_DADDR_MASK); if (cj_ipv4_item_dst_addr_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_DST_ADDR_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_IPV4_ITEM_DST_ADDR_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } ipv4_item->ip_mask.dst_addr = (uint32_t)cj_ipv4_item_dst_addr_mask->valuedouble; @@ -647,7 +605,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_udp_item = cJSON_GetObjectItem(cj_items,MR_CJSON_KEY_UDP); if (cj_udp_item == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -655,7 +613,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_udp_item_arg_flag = cJSON_GetObjectItem(cj_udp_item,MR_CJSON_KEY_ARG_FLAG); if (cj_udp_item_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } udp_item->arg_flag = (uint16_t)cj_udp_item_arg_flag->valuedouble; @@ -666,7 +624,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_udp_item_src_port = cJSON_GetObjectItem(cj_udp_item,MR_CJSON_KEY_UDP_SRC_PORT); if (cj_udp_item_src_port == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_SRC_PORT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_SRC_PORT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } udp_item->udp_hdr.src_port = htons((uint16_t)cj_udp_item_src_port->valuedouble); @@ -678,7 +636,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_udp_item_src_port_mask = cJSON_GetObjectItem(cj_udp_item,MR_CJSON_KEY_UDP_SRC_PORT_MASK); if (cj_udp_item_src_port_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_SRC_PORT_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_SRC_PORT_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } udp_item->udp_mask.src_port = htons((uint16_t)cj_udp_item_src_port_mask->valuedouble); @@ -690,7 +648,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_udp_item_dst_port = cJSON_GetObjectItem(cj_udp_item,MR_CJSON_KEY_UDP_DST_PORT); if (cj_udp_item_dst_port == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_DST_PORT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_DST_PORT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } udp_item->udp_hdr.dst_port = htons((uint16_t)cj_udp_item_dst_port->valuedouble); @@ -702,7 +660,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_udp_item_dst_port_mask = cJSON_GetObjectItem(cj_udp_item,MR_CJSON_KEY_UDP_DST_PORT_MASK); if (cj_udp_item_dst_port_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_DST_PORT_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_UDP_ITEM_DST_PORT_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } udp_item->udp_mask.dst_port = htons((uint16_t)cj_udp_item_dst_port_mask->valuedouble); @@ -720,7 +678,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_tcp_item = cJSON_GetObjectItem(cj_items,MR_CJSON_KEY_TCP); if (cj_tcp_item == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -728,7 +686,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_tcp_item_arg_flag = cJSON_GetObjectItem(cj_tcp_item,MR_CJSON_KEY_ARG_FLAG); if (cj_tcp_item_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } tcp_item->arg_flag = (uint16_t)cj_tcp_item_arg_flag->valuedouble; @@ -739,7 +697,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_tcp_item_src_port = cJSON_GetObjectItem(cj_tcp_item,MR_CJSON_KEY_TCP_SRC_PORT); if (cj_tcp_item_src_port == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_SRC_PORT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_SRC_PORT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } tcp_item->tcp_hdr.src_port = htons((uint16_t)cj_tcp_item_src_port->valuedouble); @@ -751,7 +709,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_tcp_item_src_port_mask = cJSON_GetObjectItem(cj_tcp_item,MR_CJSON_KEY_TCP_SRC_PORT_MASK); if (cj_tcp_item_src_port_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_SRC_PORT_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_SRC_PORT_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } tcp_item->tcp_mask.src_port = htons((uint16_t)cj_tcp_item_src_port_mask->valuedouble); @@ -763,7 +721,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_tcp_item_dst_port = cJSON_GetObjectItem(cj_tcp_item,MR_CJSON_KEY_TCP_DST_PORT); if (cj_tcp_item_dst_port == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_DST_PORT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_DST_PORT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } tcp_item->tcp_hdr.dst_port = htons((uint16_t)cj_tcp_item_dst_port->valuedouble); @@ -775,7 +733,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_tcp_item_dst_port_mask = cJSON_GetObjectItem(cj_tcp_item,MR_CJSON_KEY_TCP_DST_PORT_MASK); if (cj_tcp_item_dst_port_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_DST_PORT_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_DST_PORT_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } tcp_item->tcp_mask.dst_port = htons((uint16_t)cj_tcp_item_dst_port_mask->valuedouble); @@ -787,7 +745,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_tcp_item_flags = cJSON_GetObjectItem(cj_tcp_item,MR_CJSON_KEY_TCP_FLAGS); if (cj_tcp_item_flags == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_FLAGS_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_TCP_ITEM_FLAGS_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } tcp_item->tcp_hdr.tcp_flags = (uint8_t)cj_tcp_item_flags->valuedouble; @@ -805,7 +763,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_vxlan_item = cJSON_GetObjectItem(cj_items,MR_CJSON_KEY_VXLAN); if (cj_vxlan_item == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -813,7 +771,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_vxlan_item_arg_flag = cJSON_GetObjectItem(cj_vxlan_item,MR_CJSON_KEY_ARG_FLAG); if (cj_vxlan_item_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } vxlan_item->arg_flag = (uint16_t)cj_vxlan_item_arg_flag->valuedouble; @@ -824,7 +782,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_vxlan_item_vni = cJSON_GetObjectItem(cj_vxlan_item,MR_CJSON_KEY_VXLAN_VNI); if (cj_vxlan_item_vni == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_VNI_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_VNI_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } vxlan_item->vni = (uint32_t)cj_vxlan_item_vni->valuedouble; @@ -836,7 +794,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_vxlan_item_vni_mask = cJSON_GetObjectItem(cj_vxlan_item,MR_CJSON_KEY_VXLAN_VNI_MASK); if (cj_vxlan_item_vni_mask == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_VNI_MASK_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_VXLAN_ITEM_VNI_MASK_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } vxlan_item->vni_mask = (uint32_t)cj_vxlan_item_vni_mask->valuedouble; @@ -850,7 +808,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_actions = cJSON_GetObjectItem(j_cmd,MR_CJSON_KEY_ACTIONS); if (cj_actions == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } else @@ -860,7 +818,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_actions_list = cJSON_GetObjectItem(cj_actions,MR_CJSON_KEY_ACTION_LIST); if (cj_actions_list == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_LIST_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_LIST_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->action_list = action_list = (uint16_t)cj_actions_list->valuedouble; @@ -868,13 +826,13 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_actions_num = cJSON_GetObjectItem(cj_actions,MR_CJSON_KEY_ACTION_NUM); if (cj_actions_num == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_NUM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_NUM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } rule_item->action_num = (uint64_t)cj_actions_num->valuedouble; if (rule_item->action_num > MR_MAX_ACTION_NUM) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_NUM_OUT_OF_MAX_NUM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ACTION_NUM_OUT_OF_MAX_NUM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -892,7 +850,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_count = cJSON_GetObjectItem(cj_actions,MR_CJSON_KEY_COUNT); if (cj_action_count == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -900,7 +858,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_count_arg_flag = cJSON_GetObjectItem(cj_action_count,MR_CJSON_KEY_ARG_FLAG); if (cj_action_count_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } count_action->arg_flag = (uint16_t)cj_action_count_arg_flag->valuedouble; @@ -911,7 +869,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_count_shared = cJSON_GetObjectItem(cj_action_count,MR_CJSON_KEY_COUNT_SHARED); if (cj_action_count_shared == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_SHARED_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_SHARED_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } count_action->shared = (uint8_t)cj_action_count_shared->valuedouble; @@ -923,7 +881,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_count_id = cJSON_GetObjectItem(cj_action_count,MR_CJSON_KEY_COUNT_ID); if (cj_action_count_id == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_ID_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_COUNT_ACTION_ID_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } count_action->id = (uint32_t)cj_action_count_id->valuedouble; @@ -940,7 +898,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_drop = cJSON_GetObjectItem(cj_actions,MR_CJSON_KEY_DROP); if (cj_action_drop == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DROP_ACTION_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DROP_ACTION_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -948,7 +906,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_drop_state = cJSON_GetObjectItem(cj_action_drop,MR_CJSON_KEY_STATE); if (cj_action_drop_state == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DROP_ACTION_STATE_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DROP_ACTION_STATE_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } if (strncmp(cj_action_drop_state->valuestring,"enable", sizeof("enable"))) @@ -971,7 +929,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_queue = cJSON_GetObjectItem(cj_actions,MR_CJSON_KEY_QUEUE); if (cj_action_queue == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_QUEUE_ACTION_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_QUEUE_ACTION_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -979,7 +937,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_queue_arg_flag = cJSON_GetObjectItem(cj_action_queue,MR_CJSON_KEY_ARG_FLAG); if (cj_action_queue_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_QUEUE_ACTION_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_QUEUE_ACTION_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } queue_action->arg_flag = (uint16_t)cj_action_queue_arg_flag->valuedouble; @@ -990,7 +948,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_queue_index = cJSON_GetObjectItem(cj_action_queue,MR_CJSON_KEY_QUEUE_INDEX); if (cj_action_queue_index == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_QUEUE_ACTION_INDEX_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_QUEUE_ACTION_INDEX_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } queue_action->index = (uint16_t)cj_action_queue_index->valuedouble; @@ -1007,7 +965,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_set_src_mac = cJSON_GetObjectItem(cj_actions,MR_CJSON_KEY_SET_SRC_MAC); if (cj_action_set_src_mac == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -1015,7 +973,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_set_src_mac_arg_flag = cJSON_GetObjectItem(cj_action_set_src_mac,MR_CJSON_KEY_ARG_FLAG); if (cj_action_set_src_mac_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } set_src_mac_action->arg_flag = (uint16_t)cj_action_set_src_mac_arg_flag->valuedouble; @@ -1026,12 +984,12 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_set_src_mac_smac = cJSON_GetObjectItem(cj_action_set_src_mac,MR_CJSON_KEY_SET_SRC_MAC_SMAC); if (cj_action_set_src_mac_smac == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_SMAC_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_SMAC_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } if(string_to_mac(cj_action_set_src_mac_smac->valuestring,&set_src_mac_action->mac_addr) == RT_ERR) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_SMAC_FORMAT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_SRC_MAC_ACTION_SMAC_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } } @@ -1047,7 +1005,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_set_dst_mac = cJSON_GetObjectItem(cj_actions,MR_CJSON_KEY_SET_DST_MAC); if (cj_action_set_dst_mac == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -1055,7 +1013,7 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_set_dst_mac_arg_flag = cJSON_GetObjectItem(cj_action_set_dst_mac,MR_CJSON_KEY_ARG_FLAG); if (cj_action_set_dst_mac_arg_flag == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } set_dst_mac_action->arg_flag = (uint16_t)cj_action_set_dst_mac_arg_flag->valuedouble; @@ -1066,12 +1024,12 @@ int json_parsing_create_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_action_set_dst_mac_dmac = cJSON_GetObjectItem(cj_action_set_dst_mac,MR_CJSON_KEY_SET_DST_MAC_DMAC); if (cj_action_set_dst_mac_dmac == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_SMAC_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_SMAC_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } if(string_to_mac(cj_action_set_dst_mac_dmac->valuestring,&set_dst_mac_action->mac_addr) == RT_ERR) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_SMAC_FORMAT_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_SET_DST_MAC_ACTION_SMAC_FORMAT_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } } @@ -1090,7 +1048,7 @@ int json_parsing_delete_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * j_cmd = cJSON_Parse(rule_string); if (j_cmd == NULL) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_ERR,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } @@ -1098,7 +1056,7 @@ int json_parsing_delete_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_delete = cJSON_GetObjectItem(j_cmd,MR_CJSON_KEY_DELETE_RULE); if (cj_delete == NULL) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_ERR,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } else @@ -1107,7 +1065,7 @@ int json_parsing_delete_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_delete_arg_flag = cJSON_GetObjectItem(cj_delete,MR_CJSON_KEY_ARG_FLAG); if (cj_delete_arg_flag == NULL) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_ARG_FLAG_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_ARG_FLAG_ERR,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } rule_item->delete.arg_flag = (uint16_t)cj_delete_arg_flag->valuedouble; @@ -1118,13 +1076,13 @@ int json_parsing_delete_request(struct ctrlmsg_handler * ct_hand, struct ctrlmsg cJSON * cj_delete_rule_id = cJSON_GetObjectItem(cj_delete,MR_CJSON_KEY_DELETE_RULE_ID); if (cj_delete_rule_id == NULL) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_RULE_ID_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_RULE_ID_ERR,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } rule_item->delete.rule_id = (u_int32_t)cj_delete_rule_id->valuedouble; if (rule_item->delete.rule_id >= MR_FLOW_MAX_NUM) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_RULE_ID_OUT_OF_MAX_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_PARSE_DELETE_RULE_ID_OUT_OF_MAX_ERR,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } } @@ -1194,6 +1152,19 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand struct rte_flow_item items[MR_MAX_ITEM_NUM]; struct rte_flow_action actions[MR_MAX_ACTION_NUM]; + /* Items */ + struct rte_flow_item_eth eth_spec = {},eth_mask = {}; + struct rte_flow_item_ipv4 ipv4_spec = {},ipv4_mask = {}; + struct rte_flow_item_udp udp_spec = {},udp_mask = {}; + struct rte_flow_item_tcp tcp_spec = {},tcp_mask = {}; + struct rte_flow_item_vxlan vxlan_spec = {},vxlan_mask = {}; + + /* Actions */ + struct rte_flow_action_count counter_conf = {}; + struct rte_flow_action_queue queue_conf = {}; + struct rte_flow_action_set_mac conf_set_src_mac_conf = {}; + struct rte_flow_action_set_mac conf_set_dst_mac_conf = {}; + memset(items, 0, sizeof(items)); memset(actions, 0, sizeof(actions)); @@ -1212,7 +1183,7 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand /* 1.1 Check Port ID */ if (port_id == MR_INVALID_PORT_ID) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_GENERATE_FLOW_GET_PORT_ID_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_GENERATE_FLOW_GET_PORT_ID_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -1223,7 +1194,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand /* 2.1 Fill Ether Items */ if (item_list & MR_RULE_FLOW_ITEM_LIST_ETHER) { - struct rte_flow_item_eth eth_spec = {},eth_mask = {}; struct mr_flow_item_ether * ether_item = &rule_item->items[MR_RULE_FLOW_ITEM_ETHER].ether_item; /* 2.1.0 Clear Ether Item Flag */ @@ -1274,8 +1244,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand { /* 2.2 Vlan Items Not currently supported */ /* 2.3 Fill IPv4 Items */ - struct rte_flow_item_ipv4 ipv4_spec = {},ipv4_mask = {}; - struct mr_flow_item_ipv4 * ipv4_item = &rule_item->items[MR_RULE_FLOW_ITEM_IPV4].ipv4_item; /* 2.3.0 Clear IPv4 Item Flag */ @@ -1343,8 +1311,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand else if (item_list & MR_RULE_FLOW_ITEM_LIST_UDP) { /* 2.4 Fill UDP Items */ - struct rte_flow_item_udp udp_spec = {},udp_mask = {}; - struct mr_flow_item_udp * udp_item = &rule_item->items[MR_RULE_FLOW_ITEM_UDP].udp_item; /* 2.4.0 Clear UDP Item Flag */ @@ -1383,8 +1349,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand else if (item_list & MR_RULE_FLOW_ITEM_LIST_TCP) { /* 2.5 Fill TCP Items */ - struct rte_flow_item_tcp tcp_spec = {},tcp_mask = {}; - struct mr_flow_item_tcp * tcp_item = &rule_item->items[MR_RULE_FLOW_ITEM_TCP].tcp_item; /* 2.5.0 Clear TCP Item Flag */ @@ -1430,8 +1394,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand else if (item_list & MR_RULE_FLOW_ITEM_LIST_VXLAN) { /* 2.6 Fill Vxlan Items */ - struct rte_flow_item_vxlan vxlan_spec = {},vxlan_mask = {}; - struct mr_flow_item_vxlan * vxlan_item = &rule_item->items[MR_RULE_FLOW_ITEM_VXLAN].vxlan_item; /* 2.6.0 Clear Vxlan Item Flag */ @@ -1474,7 +1436,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand /* 3.1 Fill Count Action */ if (action_list & MR_RULE_FLOW_ACTION_LIST_COUNT) { - struct rte_flow_action_count counter_conf = {}; struct mr_flow_action_count * action_counter = &rule_item->actions[MR_RULE_FLOW_ACTION_COUNT].count; /* 3.1.0 Clear Count Action Flag */ @@ -1504,7 +1465,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand } else if (action_list & MR_RULE_FLOW_ACTION_LIST_QUEUE) { - struct rte_flow_action_queue queue_conf = {}; struct mr_flow_action_queue * action_queue = &rule_item->actions[MR_RULE_FLOW_ACTION_QUEUE].queue; /* 3.3.0 Clear Queue Action Flag */ @@ -1522,7 +1482,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand } else if (action_list & MR_RULE_FLOW_ACTION_LIST_SET_SRC_MAC) { - struct rte_flow_action_set_mac conf_set_src_mac_conf = {}; struct mr_flow_action_set_mac * action_set_src_mac = &rule_item->actions[MR_RULE_FLOW_ACTION_SET_SRC_MAC].set_src_mac; /* 3.4.0 Clear Set Src Mac Action Flag */ @@ -1540,7 +1499,6 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand } else if (action_list & MR_RULE_FLOW_ACTION_LIST_SET_DST_MAC) { - struct rte_flow_action_set_mac conf_set_dst_mac_conf = {}; struct mr_flow_action_set_mac * action_set_dst_mac = &rule_item->actions[MR_RULE_FLOW_ACTION_SET_DST_MAC].set_dst_mac; /* 3.5.0 Clear Set Dst Mac Action Flag */ @@ -1572,7 +1530,7 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand char error_buf[MR_STRING_MAX]; sprintf(error_buf,"Flow can't be created %d message: %s\n",flow_error.type, flow_error.message ? flow_error.message : "(no stated reason)"); MR_INFO("%s", error_buf); - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,error_buf); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,error_buf,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } @@ -1581,7 +1539,7 @@ int mr_generate_flow_create(struct sc_main * sc,struct ctrlmsg_handler * ct_hand mr_flow = mr_get_free_flow(sc); if (mr_flow == NULL) { - send_create_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_GENERATE_FLOW_OUT_OF_MAX_RULE_NUM_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_GENERATE_FLOW_OUT_OF_MAX_RULE_NUM_ERR,CTRLMSG_TOPIC_FLOW_CREATE); return RT_ERR; } /* 7.2 Save Flow And Rule Str */ @@ -1604,14 +1562,14 @@ int mr_generate_flow_delete(struct sc_main * sc,struct ctrlmsg_handler * ct_hand if (delete_flow->valid_flag == MR_FLOW_INVALID) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_DELETE_RULE_ID_INVALID_ERR); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,MR_JSON_DELETE_RULE_ID_INVALID_ERR,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } ret = rte_flow_destroy(delete_flow->port_id, delete_flow->flow, &flow_error); if (ret < 0) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,(char *)flow_error.message); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,(char *)flow_error.message,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } @@ -1636,7 +1594,7 @@ int mr_generate_flow_delete(struct sc_main * sc,struct ctrlmsg_handler * ct_hand int ret = rte_flow_destroy(delete_flow->port_id, delete_flow->flow, &flow_error); if (ret < 0) { - send_delete_request_result_msg(ct_hand,ct_conn,RT_ERR,(char *)flow_error.message); + send_request_result_msg(ct_hand,ct_conn,RT_ERR,(char *)flow_error.message,CTRLMSG_TOPIC_FLOW_DELETE); return RT_ERR; } @@ -1776,7 +1734,7 @@ static int __flow_create_request_handler(struct ctrlmsg_handler * ct_hand, struc memset(&rule_item, 0, sizeof(rule_item)); rule_string = (char *)reg_msg->cmd; - MR_INFO("Flow Create Request : %s", rule_string); + MR_DEBUG("Flow Create Request : %s", rule_string); /* Parsing Json */ if (json_parsing_create_request(ct_hand,ct_conn,rule_string,&rule_item) == RT_ERR) @@ -1792,7 +1750,7 @@ static int __flow_create_request_handler(struct ctrlmsg_handler * ct_hand, struc else { /* Send Success Mesg */ - send_create_request_result_msg(ct_hand,ct_conn,RT_SUCCESS,MR_FLOW_CREAT_SUCCESS); + send_request_result_msg(ct_hand,ct_conn,RT_SUCCESS,MR_FLOW_CREAT_SUCCESS,CTRLMSG_TOPIC_FLOW_CREATE); } return RT_SUCCESS; } @@ -1803,22 +1761,15 @@ static int __flow_search_request_handler(struct ctrlmsg_handler * ct_hand, struc u_int32_t flow_id = 0; struct sc_main * sc = (struct sc_main *)arg; char * str_cjson_rule = NULL; - struct ctrl_msg_flow_response rep_msg; cJSON * cjson_rule = cJSON_CreateObject(); cJSON * cjson_rule_search_end = cJSON_CreateObject(); - /* 1. Set Rep Msg Header */ - memset(&rep_msg, 0, sizeof(rep_msg)); - ctrl_msg_header_construct(&rep_msg.msg_header, sizeof(rep_msg), CTRL_MSG_TYPE_RESPONSE, CTRLMSG_TOPIC_FLOW_SEARCH); - rep_msg.msg_err.errcode = RT_SUCCESS; - - /* 2. Send Flow Rule Num */ + /* 1. Send Flow Rule Num */ cJSON_AddNumberToObject(cjson_rule, MR_CJSON_KEY_RULE_NUM, sc->flow_manage_main->used_num); str_cjson_rule = cJSON_Print(cjson_rule); - snprintf((char *)rep_msg.msg_err.strerr, sizeof(rep_msg.msg_err.strerr), "%s", str_cjson_rule); - ctrlmsg_msg_send(ct_hand, ct_conn, (struct ctrl_msg_header*)&rep_msg); + send_request_result_msg(ct_hand,ct_conn,RT_SUCCESS,str_cjson_rule,CTRLMSG_TOPIC_FLOW_SEARCH); - /* 3. Send Rule Str */ + /* 2. Send Rule Str */ for (flow_id = 0; flow_id < MR_FLOW_MAX_NUM; flow_id++) { if (sc->flow_manage_main->flow_array[flow_id].valid_flag == MR_FLOW_VALID) @@ -1829,22 +1780,19 @@ static int __flow_search_request_handler(struct ctrlmsg_handler * ct_hand, struc cJSON_AddStringToObject(cjson_flow, MR_CJSON_KEY_RULE_STR, (char *)sc->flow_manage_main->flow_array[flow_id].rule_str); cJSON_AddItemToObject(cjson_rule_info,MR_CJSON_KEY_RULE_INFO,cjson_flow); str_cjson_rule = cJSON_Print(cjson_rule_info); - memset(&rep_msg.msg_err.strerr, 0, sizeof(rep_msg.msg_err.strerr)); - snprintf((char *)rep_msg.msg_err.strerr, sizeof(rep_msg.msg_err.strerr), "%s", str_cjson_rule); - if (ctrlmsg_msg_send(ct_hand, ct_conn, (struct ctrl_msg_header*)&rep_msg) == -ENOBUFS) + int ret = send_request_result_msg(ct_hand,ct_conn,RT_SUCCESS,str_cjson_rule,CTRLMSG_TOPIC_FLOW_SEARCH); + if (ret == -ENOBUFS) { MR_INFO("Search Request Send Rule Str Msg Error"); } } } - /* 4. Send End Flag */ + /* 3. Send End Flag */ cJSON_AddNumberToObject(cjson_rule_search_end, MR_CJSON_KEY_RULE_END,RT_SUCCESS); str_cjson_rule = cJSON_Print(cjson_rule_search_end); - printf("Send :%s\n",str_cjson_rule); - memset(&rep_msg.msg_err.strerr, 0, sizeof(rep_msg.msg_err.strerr)); - snprintf((char *)rep_msg.msg_err.strerr, sizeof(rep_msg.msg_err.strerr), "%s", str_cjson_rule); - if (ctrlmsg_msg_send(ct_hand, ct_conn, (struct ctrl_msg_header*)&rep_msg) == -ENOBUFS) + int ret = send_request_result_msg(ct_hand,ct_conn,RT_SUCCESS,str_cjson_rule,CTRLMSG_TOPIC_FLOW_SEARCH); + if (ret == -ENOBUFS) { MR_INFO("Search Request Send End Msg Error"); } @@ -1862,7 +1810,7 @@ static int __flow_delete_request_handler(struct ctrlmsg_handler * ct_hand, struc memset(&rule_item, 0, sizeof(rule_item)); rule_string = (char *)reg_msg->cmd; - MR_INFO("Flow Delete Request : %s", rule_string); + MR_DEBUG("Flow Delete Request : %s", rule_string); /* Parsing Json */ if (json_parsing_delete_request(ct_hand,ct_conn,rule_string,&rule_item) == RT_ERR) @@ -1878,7 +1826,7 @@ static int __flow_delete_request_handler(struct ctrlmsg_handler * ct_hand, struc else { /* Send Success Mesg */ - send_delete_request_result_msg(ct_hand,ct_conn,RT_SUCCESS,MR_FLOW_DELETE_SUCCESS); + send_request_result_msg(ct_hand,ct_conn,RT_SUCCESS,MR_FLOW_DELETE_SUCCESS,CTRLMSG_TOPIC_FLOW_DELETE); } return RT_SUCCESS; } @@ -1913,13 +1861,14 @@ static int __flow_get_count_request_handler(struct ctrlmsg_handler * ct_hand, st int flow_main_init(struct sc_main * sc) { - /* Init FlowManageMain */ + /* Init Flow Manage Main */ sc->flow_manage_main = ZMALLOC(sizeof(struct flow_manage_main)); MR_VERIFY_MALLOC(sc->flow_manage_main); + /* Register Flow Create Request Handler*/ ctrlmsg_msg_reciver_register(sc->ctrlmsg_handler, CTRLMSG_TOPIC_FLOW_CREATE, CTRL_MSG_TYPE_REQUEST, __flow_create_request_handler, sc); ctrlmsg_msg_reciver_register(sc->ctrlmsg_handler, CTRLMSG_TOPIC_FLOW_SEARCH, CTRL_MSG_TYPE_REQUEST, __flow_search_request_handler, sc); ctrlmsg_msg_reciver_register(sc->ctrlmsg_handler, CTRLMSG_TOPIC_FLOW_DELETE, CTRL_MSG_TYPE_REQUEST, __flow_delete_request_handler, sc); ctrlmsg_msg_reciver_register(sc->ctrlmsg_handler, CTRLMSG_TOPIC_FLOW_GET_COUNT, CTRL_MSG_TYPE_REQUEST, __flow_get_count_request_handler, sc); return RT_SUCCESS; -}/* */
\ No newline at end of file +}
\ No newline at end of file diff --git a/tools/mrctl/CMakeLists.txt b/tools/mrctl/CMakeLists.txt index 6b989f5..2d05a04 100644 --- a/tools/mrctl/CMakeLists.txt +++ b/tools/mrctl/CMakeLists.txt @@ -5,4 +5,5 @@ include_directories(${CMAKE_SOURCE_DIR}/service/include) include_directories(${DPDK_INCLUDE_DIR}) add_executable(mrctl mrctl.c) -target_link_libraries(mrctl MESA_prof_load_static infra m MESA_htable_static ${SYSTEMD_LIBRARIES})
\ No newline at end of file +target_link_libraries(mrctl MESA_prof_load_static infra m MESA_htable_static ${SYSTEMD_LIBRARIES}) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/mrctl DESTINATION bin COMPONENT Program)
\ No newline at end of file diff --git a/tools/mrctl/mrctl.c b/tools/mrctl/mrctl.c index 4d07df0..25c2878 100644 --- a/tools/mrctl/mrctl.c +++ b/tools/mrctl/mrctl.c @@ -19,9 +19,6 @@ #define MR_CLI_RESPONSE_ENABLE 1 #define MR_CLI_CLOSE_DELAY 100 - -struct mrctl_flow_rule * rule_global; - /* Cli Arg List */ enum mr_cli_arg { @@ -93,8 +90,9 @@ struct mrctl_instance struct mrctl_instance * mrctl_instance = NULL; unsigned int g_logger_to_stdout = 1; unsigned int g_logger_level = LOG_DEBUG; +struct mrctl_flow_rule * rule_global; -/* Command Line Prompt */ +/* Command Line Options */ static struct option cli_options[] = { {"help", no_argument,NULL, 'h'}, @@ -153,6 +151,115 @@ static struct option cli_options[] = {"dmac_arg", required_argument,NULL, MR_CLI_ACTION_SET_DST_MAC_ARG}, }; +/* Help Info */ +int help() +{ + printf("Usage: mrctl {Attr} {Items} {Actions}\n"); + /* Attr */ + printf("Attr:\n"); + printf(" Must Choose:\n"); + printf(" RuleType : -c,--create eg: -c\n"); + printf(" -d,--delete eg: -c\n"); + printf(" -s,--search eg: -c\n"); + printf(" --get_count eg: --get_count\n"); + printf(" Create Must Choose:\n"); + printf(" Direction : -i,--ingress eg: -i\n"); + printf(" -e,--egress eg: -e\n"); + printf(" Portname : -p,--portname eg: -p ens18f1\n"); + printf(" Optional:\n"); + printf(" Group : -g,--group eg: -g 1 \n"); + printf(" Priority : --priority eg: --priority 1\n"); + printf("\n"); + + /* Delete */ + printf("Delete Arg:\n"); + printf(" Must Choose:\n"); + printf(" RuleId : --rule_id eg: --rule_id 0\n"); + printf(" --all eg: --all\n"); + + /* Get Rule Count */ + printf("Get Rule Count:\n"); + printf(" Must Choose:\n"); + printf(" CountRuleId : --count_rule_id eg: --count_rule_id 0\n"); + printf(" --count_all eg: --count_all\n"); + + /* Items */ + printf("Items: Must Choose One Item\n"); + printf(" Ether : --ether eg: --ether\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" SrcMac : --smac eg: --smac C8:3A:35:09:EF:A1 \n"); + printf(" DstMac : --dmac eg: --dmac 08:C0:EB:97:D2:37\n"); + printf(" SrcMacMask : --smac_mask eg: --smac_mask FF:FF:FF:FF:FF:FF\n"); + printf(" DstMacMask : --dmac_mask eg: --dmac_mask FF:FF:FF:FF:FF:FF\n"); + printf(" EtherType : --ethertype eg: --ethertype ipv4 (OnlySupport ipv4 ipv6 vlan)\n"); + printf(" HasVlan : --hasvlan eg: --hasvlan\n"); + + printf(" IPv4 : --ipv4 eg: --ipv4\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" Tos : --tos eg: --tos 0 \n"); + printf(" FragmentOffset: --fragment_offset eg: --fragment_offset 0 \n"); + printf(" Ttl : --ttl eg: --ttl 64 \n"); + printf(" Proto : --proto eg: --proto udp (Only Support 'tcp' 'udp') \n"); + printf(" Src : --src eg: --src 123.101.255.252 \n"); + printf(" SrcMask : --src_mask eg: --src_mask 255.255.255.255 \n"); + printf(" Dst : --dst eg: --dst 123.101.255.253 \n"); + printf(" DstMask : --dst_mask eg: --dst_mask 255.255.255.255 \n"); + + printf(" Udp : --udp eg: --udp\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" SrcPort : --udp_sport eg: --udp_sport 4789 \n"); + printf(" SrcPortMask : --udp_sport_mask eg: --udp_sport_mask 65535 \n"); + printf(" DstPort : --udp_dport eg: --udp_dport 4789 \n"); + printf(" DstPortMask : --udp_dport_mask eg: --udp_dport_mask 65535 \n"); + + printf(" Tcp : --tcp eg: --tcp\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" SrcPort : --tcp_sport eg: --tcp_sport 60000 \n"); + printf(" SrcPortMask : --tcp_sport_mask eg: --tcp_sport_mask 65535 \n"); + printf(" DstPort : --tcp_dport eg: --tcp_dport 80 \n"); + printf(" DstPortMask : --tcp_dport_mask eg: --tcp_dport_mask 65535 \n"); + printf(" Flags : --tcp_flags eg: --tcp_flags 11 \n"); + + printf(" Vxlan : --vxlan eg: --vxlan\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" Vni : --vni eg: --vni 123456789 \n"); + printf(" VniMask : --vni_mask eg: --vni_mask 16777215 \n"); + printf("\n"); + + /* Actions */ + printf("Actions: Must Choose One Action\n"); + printf(" Count : --count eg: --count\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" Shared : --shared eg: --shared \n"); + printf(" Countid : --countid eg: --countid 11 \n"); + + printf(" Drop : --drop eg: --drop\n"); + + printf(" Queue : --queue eg: --queue\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" Index : --index eg: --index 7 \n"); + + printf(" SetSmac : --set_smac eg: --set_smac\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" SmacArg : --smac_arg eg: --smac_arg 08:c0:eb:97:d2:37 \n"); + + printf(" SetDmac : --set_dmac eg: --set_dmac\n"); + printf(" Arg : Must Choose One Arg\n"); + printf(" DmacArg : --dmac_arg eg: --dmac_arg c8:3a:35:09:ef:a1 \n"); + /* Eg */ + printf("Create Eg:\n"); + printf("mrctl -c -p eth_pf_100G_1 -g 1 --priority 1 -i --ether --smac c8:3a:35:09:ef:a1 --dmac 08:c0:eb:97:d2:37 --ethertype ipv4 --dmac_mask ff:ff:ff:ff:ff:ff --smac_mask ff:ff:ff:ff:ff:ff --ipv4 --tos 0 --ttl 64 --proto udp --src 123.101.255.252 --src_mask 255.255.255.255 --dst 123.101.255.253 --udp --udp_sport 4789 --udp_sport_mask 65535 --udp_dport 4789 --udp_dport_mask 65535 --dst_mask 255.255.255.255 --vxlan --vni 0 --vni_mask 16777215 --queue --index 7 --set_smac --smac_arg 08:c0:eb:97:d2:37 --set_dmac --dmac_arg c8:3a:35:09:ef:a1\n"); + printf("Search Eg:\n"); + printf("mrctl -s\n"); + printf("Delete Eg:\n"); + printf("mrctl -d --rule_id 1\n"); + printf("mrctl -d --all\n"); + printf("Get Count Eg:\n"); + printf("mrctl --get_count --count_rule_id 1\n"); + printf("mrctl --get_count --count_all\n"); + return RT_SUCCESS; +} + /* rte_ether_addr to str */ void ether_format_addr(char *buf, uint16_t size, const struct rte_ether_addr *eth_addr) @@ -326,10 +433,13 @@ static int mrctl_ctrlmsg_init(struct mrctl_instance * instance) { char str_ctrlmsg_addr[MR_STRING_MAX] = { 0 }; unsigned int ctrlmsg_port = 0; + unsigned int loglevel = g_logger_level + 1; /* Get Ip & Port */ MESA_load_profile_string_def(GLOBAL_CONF_FILE_PATH, "ctrlmsg", "listen_addr", str_ctrlmsg_addr, sizeof(str_ctrlmsg_addr), CTRLMSG_DEFAULT_ADDR); MESA_load_profile_uint_def(GLOBAL_CONF_FILE_PATH, "ctrlmsg", "listen_port", &ctrlmsg_port, CTRLMSG_DEFAULT_PORT); + MESA_load_profile_uint_def(GLOBAL_CONF_FILE_PATH, "eal", "loglevel", &loglevel, loglevel); + g_logger_level = loglevel - 1; /* Change Ip Addr */ struct sockaddr_in sockaddr_in; @@ -398,9 +508,27 @@ static int __flow_search_response_handler(struct ctrlmsg_handler * ct_hand, stru if (rep_msg->msg_err.errcode == RT_SUCCESS) { cjson_search_response = cJSON_Parse((char *)rep_msg->msg_err.strerr); - cJSON * cjson_flow_rule_num = cJSON_GetObjectItem(cjson_search_response,MR_CJSON_KEY_RULE_NUM); - cJSON * cjson_flow_rule_info = cJSON_GetObjectItem(cjson_search_response,MR_CJSON_KEY_RULE_INFO); - cJSON * cjson_flow_rule_end = cJSON_GetObjectItem(cjson_search_response,MR_CJSON_KEY_RULE_END); + + /* Parsing Success Info Str */ + cJSON * cjson_search_success = cJSON_GetObjectItem(cjson_search_response,MR_CJSON_KEY_SUCCESS_INFO); + if (cjson_search_success == NULL) + { + printf("Cant Get The Search Success Info.\n"); + return RT_ERR; + } + + /* Parsing Success Info */ + cJSON * cjson_search_success_info = cJSON_Parse((char *)cjson_search_success->valuestring); + if (cjson_search_success_info == NULL) + { + printf("Cant Parsing The Search Success Info.\n"); + return RT_ERR; + } + + cJSON * cjson_flow_rule_num = cJSON_GetObjectItem(cjson_search_success_info,MR_CJSON_KEY_RULE_NUM); + cJSON * cjson_flow_rule_info = cJSON_GetObjectItem(cjson_search_success_info,MR_CJSON_KEY_RULE_INFO); + cJSON * cjson_flow_rule_end = cJSON_GetObjectItem(cjson_search_success_info,MR_CJSON_KEY_RULE_END); + if (cjson_flow_rule_num != NULL) { printf("The Flow Rule Num : %u\n",(uint32_t)cjson_flow_rule_num->valuedouble); @@ -1333,112 +1461,6 @@ int send_get_count_request_msg(struct mrctl_instance * instance, struct mrctl_fl return RT_SUCCESS; } -/* Help Info */ -int help() -{ - printf("Usage: ./mrctl {Attr} {Items} {Actions}\n"); - /* Attr */ - printf("Attr:\n"); - printf(" Must Choose:\n"); - printf(" RuleType : -c,--create eg: -c\n"); - printf(" -d,--delete eg: -c\n"); - printf(" -s,--search eg: -c\n"); - printf(" --get_count eg: --get_count\n"); - printf(" Create Must Choose:\n"); - printf(" Direction : -i,--ingress eg: -i\n"); - printf(" -e,--egress eg: -e\n"); - printf(" Portname : -p,--portname eg: -p ens18f1\n"); - printf(" Optional:\n"); - printf(" Group : -g,--group eg: -g 1 \n"); - printf(" Priority : --priority eg: --priority 1\n"); - printf("\n"); - - /* Delete */ - printf("Delete Arg:\n"); - printf(" Must Choose:\n"); - printf(" RuleId : --rule_id eg: --rule_id 0\n"); - printf(" --all eg: --all\n"); - - /* Get Rule Count */ - printf("Get Rule Count:\n"); - printf(" Must Choose:\n"); - printf(" CountRuleId : --count_rule_id eg: --count_rule_id 0\n"); - printf(" --count_all eg: --count_all 0\n"); - - /* Items */ - printf("Items: Must Choose One Item\n"); - printf(" Ether : --ether eg: --ether\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" SrcMac : --smac eg: --smac C8:3A:35:09:EF:A1 \n"); - printf(" DstMac : --dmac eg: --dmac 08:C0:EB:97:D2:37\n"); - printf(" SrcMacMask : --smac_mask eg: --smac_mask FF:FF:FF:FF:FF:FF\n"); - printf(" DstMacMask : --dmac_mask eg: --dmac_mask FF:FF:FF:FF:FF:FF\n"); - printf(" EtherType : --ethertype eg: --ethertype ipv4 (OnlySupport ipv4 ipv6 vlan)\n"); - printf(" HasVlan : --hasvlan eg: --hasvlan\n"); - - printf(" IPv4 : --ipv4 eg: --ipv4\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" Tos : --tos eg: --tos 0 \n"); - printf(" FragmentOffset: --fragment_offset eg: --fragment_offset 0 \n"); - printf(" Ttl : --ttl eg: --ttl 64 \n"); - printf(" Proto : --proto eg: --proto udp (Only Support 'tcp' 'udp') \n"); - printf(" Src : --src eg: --src 123.101.255.252 \n"); - printf(" SrcMask : --src_mask eg: --src_mask 255.255.255.255 \n"); - printf(" Dst : --dst eg: --dst 123.101.255.253 \n"); - printf(" DstMask : --dst_mask eg: --dst_mask 255.255.255.255 \n"); - - printf(" Udp : --udp eg: --udp\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" SrcPort : --udp_sport eg: --udp_sport 4789 \n"); - printf(" SrcPortMask : --udp_sport_mask eg: --udp_sport_mask 65535 \n"); - printf(" DstPort : --udp_dport eg: --udp_dport 4789 \n"); - printf(" DstPortMask : --udp_dport_mask eg: --udp_dport_mask 65535 \n"); - - printf(" Tcp : --tcp eg: --tcp\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" SrcPort : --tcp_sport eg: --tcp_sport 60000 \n"); - printf(" SrcPortMask : --tcp_sport_mask eg: --tcp_sport_mask 65535 \n"); - printf(" DstPort : --tcp_dport eg: --tcp_dport 80 \n"); - printf(" DstPortMask : --tcp_dport_mask eg: --tcp_dport_mask 65535 \n"); - printf(" Flags : --tcp_flags eg: --tcp_flags 11 \n"); - - printf(" Vxlan : --vxlan eg: --vxlan\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" Vni : --vni eg: --vni 123456789 \n"); - printf(" VniMask : --vni_mask eg: --vni_mask 16777215 \n"); - printf("\n"); - - /* Actions */ - printf("Actions: Must Choose One Action\n"); - printf(" Count : --count eg: --count\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" Shared : --shared eg: --shared \n"); - printf(" Countid : --countid eg: --countid 11 \n"); - - printf(" Drop : --drop eg: --drop\n"); - - printf(" Queue : --queue eg: --queue\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" Index : --index eg: --index 7 \n"); - - printf(" SetSmac : --set_smac eg: --set_smac\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" SmacArg : --smac_arg eg: --smac_arg 08:c0:eb:97:d2:37 \n"); - - printf(" SetDmac : --set_dmac eg: --set_dmac\n"); - printf(" Arg : Must Choose One Arg\n"); - printf(" DmacArg : --dmac_arg eg: --dmac_arg c8:3a:35:09:ef:a1 \n"); - /* Eg */ - printf("Create Eg:\n"); - printf("./mrctl -c -p eth_pf_100G_1 -g 1 --priority 1 -i --ether --smac c8:3a:35:09:ef:a1 --dmac 08:c0:eb:97:d2:37 --ethertype ipv4 --dmac_mask ff:ff:ff:ff:ff:ff --smac_mask ff:ff:ff:ff:ff:ff --ipv4 --tos 0 --ttl 64 --proto udp --src 123.101.255.252 --src_mask 255.255.255.255 --dst 123.101.255.253 --udp --udp_sport 4789 --udp_sport_mask 65535 --udp_dport 4789 --udp_dport_mask 65535 --dst_mask 255.255.255.255 --vxlan --vni 0 --vni_mask 16777215 --queue --index 7 --set_smac --smac_arg 08:c0:eb:97:d2:37 --set_dmac --dmac_arg c8:3a:35:09:ef:a1\n"); - printf("Search Eg:\n"); - printf("./mrctl -s\n"); - printf("Delete Eg:\n"); - printf("./mrctl -d --rule_id 1\n"); - printf("./mrctl -d --all\n"); - return RT_SUCCESS; -} - int main(int argc, char * argv[]) { int opt = 0,close_delay = 0; |
