From 4fca0b4b7d825ba1bdd3c2f048a0bd27fadfa449 Mon Sep 17 00:00:00 2001 From: songyanchao Date: Fri, 26 Jan 2024 10:14:32 +0000 Subject: 🎈 perf: Optimize of classifier rule fields. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Optimize of classifier rule fields. --- infra/src/pkt_classifier_engine.c | 2 +- service/include/sc_classifier_rule_parser.h | 10 +- service/src/classifier_rule_parser.c | 206 +++++++++++++++------------- service/src/http_serv.c | 2 +- service/src/node_classifier.c | 35 ++++- test/ptf_test/bfd_test.py | 5 +- test/ptf_test/bond_test.py | 2 + test/ptf_test/bridge_test.py | 2 + test/ptf_test/classifier_test.py | 131 ++++++++---------- test/ptf_test/endpoint_dev_test.py | 2 + test/ptf_test/etherfabric_test.py | 30 ++-- test/ptf_test/health_check_test.py | 2 + test/ptf_test/load_balance_test.py | 7 +- test/ptf_test/mrzcpd.py | 7 +- test/ptf_test/msgpack_test.py | 21 +-- test/ptf_test/tera_test.py | 46 ++++--- test/ptf_test/vwire_test.py | 23 ++-- 17 files changed, 291 insertions(+), 242 deletions(-) diff --git a/infra/src/pkt_classifier_engine.c b/infra/src/pkt_classifier_engine.c index 99fa917..4d36097 100644 --- a/infra/src/pkt_classifier_engine.c +++ b/infra/src/pkt_classifier_engine.c @@ -465,7 +465,7 @@ void evaluate_pass_through_condition(struct domain * domain, struct rule_field_e else if (domain->can_pass_through_v4 && domain->can_pass_through_v6) { if ((domain->pass_through_action_v4.type == domain->pass_through_action_v6.type) && - (domain->pass_through_action_v4.data = domain->pass_through_action_v6.data)) + (domain->pass_through_action_v4.data == domain->pass_through_action_v6.data)) { domain->can_pass_through_domain = PASS_THROUGH_ENABLE; memcpy(&domain->pass_through_action_domain, &domain->pass_through_action_v4, sizeof(struct action)); diff --git a/service/include/sc_classifier_rule_parser.h b/service/include/sc_classifier_rule_parser.h index b54bc6d..8aa4d1b 100644 --- a/service/include/sc_classifier_rule_parser.h +++ b/service/include/sc_classifier_rule_parser.h @@ -71,11 +71,11 @@ struct rule_field_parser struct rule_list_parsed { uint16_t nr_rules; + uint16_t nr_static_rules; + uint16_t nr_dynamic_rules; struct rule_field_parser rules[MAX_RULES]; }; -extern int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_type, - struct rule_list_parsed * out_rule_list); -extern int pkt_classifier_remote_rule_parser(cJSON * c_rule, struct rule_list_parsed * out_rule_list, - char * str_error_reason, unsigned int sz_error_reason); -extern void classifier_rule_dump(struct rule_list_parsed * rule_list); +int pkt_classifier_rule_parser(const struct sc_main * sc, enum ruleset_type ruleset_type, uint8_t cfg_file_type, + struct rule_list_parsed * out_rule_list); +void classifier_rule_dump(struct rule_list_parsed * rule_list); diff --git a/service/src/classifier_rule_parser.c b/service/src/classifier_rule_parser.c index 463cd08..fae2753 100644 --- a/service/src/classifier_rule_parser.c +++ b/service/src/classifier_rule_parser.c @@ -1,51 +1,46 @@ #include #include -int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_type, +int pkt_classifier_rule_parser(const struct sc_main * sc, enum ruleset_type ruleset_type, uint8_t cfg_file_type, struct rule_list_parsed * out_rule_list) { - int ret = RT_SUCCESS; + const char * file_path = NULL; + uint16_t * nr_rules_by_type = NULL; + + switch (cfg_file_type) + { + case 0: + file_path = sc->local_cfgfile; + nr_rules_by_type = &out_rule_list->nr_static_rules; + break; + case 1: + file_path = sc->local_dyfile; + nr_rules_by_type = &out_rule_list->nr_dynamic_rules; + break; + default: + MR_ERROR("Pkt classifier rule parser, cfg_file_type '%u' is invalid.", cfg_file_type); + return RT_ERR; + } + for (int rule_index = 0; rule_index < MAX_RULES; rule_index++) { /* Retrieve the rule ID */ uint32_t rule_id; char str_section[MR_SYMBOL_MAX] = {}; snprintf(str_section, sizeof(str_section), "classifier_rule:%d", rule_index); - ret = MESA_load_profile_uint_nodef(sc->local_dyfile, str_section, "rule_id", &rule_id); + int ret = MESA_load_profile_uint_nodef(file_path, str_section, "rule_id", &rule_id); if (ret < 0) { continue; } /* Retrieve the ruleset type; if there's no configured ruleset, break the current rule */ - char str_ruleset_type[MR_SYMBOL_MAX] = {}; - ret = MESA_load_profile_string_nodef(sc->local_dyfile, str_section, "ruleset_type", str_ruleset_type, - sizeof(str_ruleset_type)); - if (ret < 0) - { - MR_ERROR("Pkt classifier rule name : %s ,no config the 'ruleset_type'.", str_section); - return RT_ERR; - } - /* Verify if the ruleset type is invalid or not required */ - if (strcmp(str_ruleset_type, "classifier") == 0) - { - if (ruleset_type != RULESET_TYPE_CLASSIFIER) - { - continue; - } - } - else if (strcmp(str_ruleset_type, "port") == 0) - { - if (ruleset_type != RULESET_TYPE_PORT) - { - continue; - } - } - else + uint32_t load_ruleset_type; + MESA_load_profile_uint_def(file_path, str_section, "ruleset_type", &load_ruleset_type, RULESET_TYPE_CLASSIFIER); + if (load_ruleset_type != ruleset_type) { - MR_ERROR("Pkt classifier rule name : %s ,ruleset type is invalid.", str_section); - return RT_ERR; + continue; } /* Initialize rule field with default values */ @@ -58,73 +53,88 @@ int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_ty rule_field_parser.rule_id = rule_id; /* Retrieve the proto */ - char str_proto[MR_SYMBOL_MAX] = {}; - MESA_load_profile_string_def(sc->local_dyfile, str_section, "proto", str_proto, sizeof(str_proto), "any"); - if (strcmp(str_proto, "tcp") == 0) + uint32_t proto; + MESA_load_profile_uint_def(file_path, str_section, "proto", &proto, UINT32_MAX); + + if (proto == UINT32_MAX) { - rule_field_parser.proto = IPPROTO_TCP; - rule_field_parser.proto_mask = UINT8_MAX; + /* UINT32_MAX indicates 'any' */ + rule_field_parser.proto = 0; + rule_field_parser.proto_mask = 0; } - else if (strcmp(str_proto, "udp") == 0) + else if ((proto == IPPROTO_TCP) || (proto == IPPROTO_UDP)) { - rule_field_parser.proto = IPPROTO_UDP; + rule_field_parser.proto = (uint8_t)proto; rule_field_parser.proto_mask = UINT8_MAX; } else { - /* 0 indicates 'any' */ - rule_field_parser.proto = 0; - rule_field_parser.proto_mask = 0; + MR_ERROR("Cfg path : '%s', rule name: '%s', proto must be either 'tcp(6)','udp(17)' or 'any(if not " + "configured)'.", + file_path, str_section); + return RT_ERR; } /* Retrieve source port start and end */ - uint32_t src_port_range_start = 0, src_port_range_end = 0; - int ret_start = - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "src_port_range_start", &src_port_range_start, 0); - int ret_end = - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "src_port_range_end", &src_port_range_end, 65535); + uint32_t src_port_start = 0, src_port_end = 0; + int ret_start = MESA_load_profile_uint_def(file_path, str_section, "src_port_start", &src_port_start, 0); + int ret_end = MESA_load_profile_uint_def(file_path, str_section, "src_port_end", &src_port_end, 65535); + if ((ret_start >= 0) && (ret_end < 0)) { - src_port_range_end = src_port_range_start; + src_port_end = src_port_start; } else if ((ret_start < 0) && (ret_end >= 0)) { - src_port_range_start = src_port_range_end; + src_port_start = src_port_end; } - rule_field_parser.src_port_start = (uint16_t)src_port_range_start; - rule_field_parser.src_port_end = (uint16_t)src_port_range_end; + if (src_port_start > src_port_end) + { + MR_ERROR("Cfg path : '%s', rule name: '%s', src_port_start must be less than or equal to src_port_end.", + file_path, str_section); + return RT_ERR; + } + + rule_field_parser.src_port_start = (uint16_t)src_port_start; + rule_field_parser.src_port_end = (uint16_t)src_port_end; /* Retrieve destination port start and end */ - uint32_t dst_port_range_start = 0, dst_port_range_end = 0; - ret_start = - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "dst_port_range_start", &dst_port_range_start, 0); - ret_end = - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "dst_port_range_end", &dst_port_range_end, 65535); + uint32_t dst_port_start = 0, dst_port_end = 0; + ret_start = MESA_load_profile_uint_def(file_path, str_section, "dst_port_start", &dst_port_start, 0); + ret_end = MESA_load_profile_uint_def(file_path, str_section, "dst_port_end", &dst_port_end, 65535); + if ((ret_start >= 0) && (ret_end < 0)) { - dst_port_range_end = dst_port_range_start; + dst_port_end = dst_port_start; } else if ((ret_start < 0) && (ret_end >= 0)) { - dst_port_range_start = dst_port_range_end; + dst_port_start = dst_port_end; } - rule_field_parser.dst_port_start = (uint16_t)dst_port_range_start; - rule_field_parser.dst_port_end = (uint16_t)dst_port_range_end; + if (dst_port_start > dst_port_end) + { + MR_ERROR("Cfg path : '%s', rule name: '%s', dst_port_start must be less than or equal to dst_port_end.", + file_path, str_section); + return RT_ERR; + } + + rule_field_parser.dst_port_start = (uint16_t)dst_port_start; + rule_field_parser.dst_port_end = (uint16_t)dst_port_end; /* Retrieve the priority */ uint32_t priority; - ret = MESA_load_profile_uint_nodef(sc->local_dyfile, str_section, "priority", &priority); + ret = MESA_load_profile_uint_nodef(file_path, str_section, "priority", &priority); if (ret < 0) { - MR_ERROR("Pkt classifier rule name : %s ,must config the 'priority'.", str_section); + MR_ERROR("Cfg path : '%s', rule name: '%s', must config the 'priority'.", file_path, str_section); return RT_ERR; } if (priority >= 16) { - MR_ERROR("Pkt classifier rule name : %s ,priority must be 0~15.", str_section); + MR_ERROR("Cfg path : '%s', rule name: '%s', priority must be 0~15.", file_path, str_section); return RT_ERR; } @@ -132,7 +142,7 @@ int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_ty /* Retrieve the IPv4 source address and mask*/ char str_src_ip_addr_v4[MR_SYMBOL_MAX] = {}; - if (MESA_load_profile_string_nodef(sc->local_dyfile, str_section, "src_ip_addr_v4", str_src_ip_addr_v4, + if (MESA_load_profile_string_nodef(file_path, str_section, "src_ip_addr_v4", str_src_ip_addr_v4, sizeof(str_src_ip_addr_v4)) > 0) { rule_field_parser.ether_type = RTE_ETHER_TYPE_IPV4; @@ -140,42 +150,43 @@ int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_ty ret = inet_pton(AF_INET, str_src_ip_addr_v4, &rule_field_parser.src_addr_v4); if ((!ret) && (strcmp(str_src_ip_addr_v4, "0.0.0.0") != 0)) { - MR_ERROR("The IPv4 Pkt classifier rule name : %s ,src ip addr is invalid: %s", str_section, + MR_ERROR("Cfg path : '%s', rule name: '%s', src ip addr is invalid: %s", file_path, str_section, str_src_ip_addr_v4); return RT_ERR; } - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "src_ip_mask_v4", - &rule_field_parser.src_addr_mask_len, 32); + MESA_load_profile_uint_def(file_path, str_section, "src_ip_mask_v4", &rule_field_parser.src_addr_mask_len, + 32); } /* Retrieve the IPv4 destination address and mask */ char str_dst_ip_addr_v4[MR_SYMBOL_MAX] = {}; - if (MESA_load_profile_string_nodef(sc->local_dyfile, str_section, "dst_ip_addr_v4", str_dst_ip_addr_v4, + if (MESA_load_profile_string_nodef(file_path, str_section, "dst_ip_addr_v4", str_dst_ip_addr_v4, sizeof(str_dst_ip_addr_v4)) > 0) { rule_field_parser.ether_type = RTE_ETHER_TYPE_IPV4; ret = inet_pton(AF_INET, str_dst_ip_addr_v4, &rule_field_parser.dst_addr_v4); if ((!ret) && (strcmp(str_dst_ip_addr_v4, "0.0.0.0") != 0)) { - MR_ERROR("The IPv4 Pkt classifier rule name : %s ,dst ip addr is invalid: %s", str_section, + MR_ERROR("Cfg path : '%s', rule name: '%s', dst ip addr is invalid: %s", file_path, str_section, str_dst_ip_addr_v4); return RT_ERR; } - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "dst_ip_mask_v4", - &rule_field_parser.dst_addr_mask_len, 32); + MESA_load_profile_uint_def(file_path, str_section, "dst_ip_mask_v4", &rule_field_parser.dst_addr_mask_len, + 32); } /* Retrieve the IPv6 source address and mask */ char str_src_ip_addr_v6[MR_SYMBOL_MAX] = {}; - if (MESA_load_profile_string_nodef(sc->local_dyfile, str_section, "src_ip_addr_v6", str_src_ip_addr_v6, + if (MESA_load_profile_string_nodef(file_path, str_section, "src_ip_addr_v6", str_src_ip_addr_v6, sizeof(str_src_ip_addr_v6)) > 0) { /* Verify the IP version */ if (rule_field_parser.ether_type == RTE_ETHER_TYPE_IPV4) { - MR_ERROR("Pkt classifier rule name : %s ,IPv4 or IPv6 only one can be configured.", str_section); + MR_ERROR("Cfg path : '%s', rule name: '%s', IPv4 or IPv6 only one can be configured.", file_path, + str_section); return RT_ERR; } @@ -183,24 +194,25 @@ int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_ty ret = inet_pton(AF_INET6, str_src_ip_addr_v6, &rule_field_parser.src_addr_v6); if ((!ret) && (strcmp(str_src_ip_addr_v6, "::") != 0)) { - MR_ERROR("The IPv6 Pkt classifier rule name : %s ,src ip addr is invalid: %s", str_section, + MR_ERROR("Cfg path : '%s', rule name: '%s', src ip addr is invalid: %s", file_path, str_section, str_src_ip_addr_v6); return RT_ERR; } - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "src_ip_mask_v6", - &rule_field_parser.src_addr_mask_len, 128); + MESA_load_profile_uint_def(file_path, str_section, "src_ip_mask_v6", &rule_field_parser.src_addr_mask_len, + 128); } /* Retrieve the IPv6 destination address and mask */ char str_dst_ip_addr_v6[MR_SYMBOL_MAX] = {}; - if (MESA_load_profile_string_nodef(sc->local_dyfile, str_section, "dst_ip_addr_v6", str_dst_ip_addr_v6, + if (MESA_load_profile_string_nodef(file_path, str_section, "dst_ip_addr_v6", str_dst_ip_addr_v6, sizeof(str_dst_ip_addr_v6)) > 0) { /* Verify the IP version */ if (rule_field_parser.ether_type == RTE_ETHER_TYPE_IPV4) { - MR_ERROR("Pkt classifier rule name : %s ,IPv4 or IPv6 only one can be configured.", str_section); + MR_ERROR("Cfg path : '%s', rule name: '%s', IPv4 or IPv6 only one can be configured.", file_path, + str_section); return RT_ERR; } @@ -208,48 +220,43 @@ int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_ty ret = inet_pton(AF_INET6, str_dst_ip_addr_v6, &rule_field_parser.dst_addr_v6); if ((!ret) && (strcmp(str_dst_ip_addr_v6, "::") != 0)) { - MR_ERROR("The IPv6 Pkt classifier rule name : %s ,dst ip addr is invalid: %s", str_section, + MR_ERROR("Cfg path : '%s', rule name: '%s', dst ip addr is invalid: %s", file_path, str_section, str_dst_ip_addr_v6); return RT_ERR; } - MESA_load_profile_uint_def(sc->local_dyfile, str_section, "dst_ip_mask_v6", - &rule_field_parser.dst_addr_mask_len, 128); + MESA_load_profile_uint_def(file_path, str_section, "dst_ip_mask_v6", &rule_field_parser.dst_addr_mask_len, + 128); } /* Retrieve the action */ - char str_action[MR_SYMBOL_MAX] = {}; - ret = MESA_load_profile_string_nodef(sc->local_dyfile, str_section, "action", str_action, sizeof(str_action)); + uint32_t action; + ret = MESA_load_profile_uint_nodef(file_path, str_section, "action", &action); + if (ret < 0) { - MR_ERROR("Pkt classifier rule name : %s ,no config the 'action'.", str_section); + MR_ERROR("Cfg path : '%s', rule name: '%s', must config the 'action'.", file_path, str_section); return RT_ERR; } /* Verify if the action type is invalid */ - if (strcmp(str_action, "drop") == 0) - { - rule_field_parser.action.type = ACTION_DROP; - } - else if (strcmp(str_action, "nf_steering") == 0) + if (action >= ACTION_MAX) { - rule_field_parser.action.type = ACTION_NF_STEERING; - } - else - { - MR_ERROR("Pkt classifier rule name : '%s' ,action invalid.", str_section); + MR_ERROR("Cfg path : '%s', rule name: '%s', action must be 0~2.", file_path, str_section); return RT_ERR; } + rule_field_parser.action.type = action; + /* Retrieve the Network Function Steering (NF steering) configuration */ if (rule_field_parser.action.type == ACTION_NF_STEERING) { /* Retrieve the SID */ uint32_t sid = 0; - ret = MESA_load_profile_uint_nodef(sc->local_dyfile, str_section, "sid", &sid); + ret = MESA_load_profile_uint_nodef(file_path, str_section, "sid", &sid); if (ret < 0) { - MR_ERROR("Pkt classifier rule name : %s ,no config the 'sid'.", str_section); + MR_ERROR("Cfg path : '%s', rule name: '%s', must config the 'sid'.", file_path, str_section); return RT_ERR; } @@ -259,10 +266,9 @@ int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_ty uint32_t ef_adapter_id = UINT32_MAX; uint32_t vwire_id = UINT32_MAX; uint32_t tera_adapter_id = UINT32_MAX; - int ef_ret = MESA_load_profile_uint_nodef(sc->local_dyfile, str_section, "ef_adapter_id", &ef_adapter_id); - int vwire_ret = MESA_load_profile_uint_nodef(sc->local_dyfile, str_section, "vwire_id", &vwire_id); - int tera_ret = - MESA_load_profile_uint_nodef(sc->local_dyfile, str_section, "tera_adapter_id", &tera_adapter_id); + int ef_ret = MESA_load_profile_uint_nodef(file_path, str_section, "ef_adapter_id", &ef_adapter_id); + int vwire_ret = MESA_load_profile_uint_nodef(file_path, str_section, "vwire_id", &vwire_id); + int tera_ret = MESA_load_profile_uint_nodef(file_path, str_section, "tera_adapter_id", &tera_adapter_id); if (ef_ret >= 0) { @@ -291,10 +297,10 @@ int pkt_classifier_rule_parser(struct sc_main * sc, enum ruleset_type ruleset_ty memcpy(rule_field_item, &rule_field_parser, sizeof(struct rule_field_parser)); out_rule_list->nr_rules++; + (*nr_rules_by_type)++; if (out_rule_list->nr_rules >= MAX_RULES) { - MR_ERROR("Pkt classifier rule name : %s , ruleset type is '%s', rules is full.", str_section, - str_ruleset_type); + MR_ERROR("Cfg path : '%s', rule name: '%s', rules is full.", file_path, str_section); return RT_ERR; } } @@ -391,4 +397,6 @@ void classifier_rule_dump(struct rule_list_parsed * rule_list) /* Dump the total rule number */ MR_INFO("Pkt classifier total rules: %u", rule_list->nr_rules); + MR_INFO("Pkt classifier total static rules: %u", rule_list->nr_static_rules); + MR_INFO("Pkt classifier total dynamic rules: %u", rule_list->nr_dynamic_rules); } diff --git a/service/src/http_serv.c b/service/src/http_serv.c index 2602d15..57ea5c3 100644 --- a/service/src/http_serv.c +++ b/service/src/http_serv.c @@ -103,7 +103,7 @@ int http_serv_init(struct sc_main * sc_main) evhttp_set_cb(http, "/probe", http_serv_probe_cb, (void *)http_server_main); /* Load the listen address and port */ - char str_listen_addr[INET_ADDRSTRLEN] = {}; + char str_listen_addr[INET6_ADDRSTRLEN] = {}; MESA_load_profile_string_def(sc_main->local_cfgfile, "http_server", "listen_addr", str_listen_addr, sizeof(str_listen_addr), "::"); diff --git a/service/src/node_classifier.c b/service/src/node_classifier.c index ee21765..22374b5 100644 --- a/service/src/node_classifier.c +++ b/service/src/node_classifier.c @@ -200,16 +200,28 @@ static inline void rule_list_engine_generator(struct rule_list_parsed * rule_lis int classifier_rule_update(struct sc_main * sc) { - /* Parse the local rules. */ + /* Parse rules. */ struct node_classifier_main * classifier_main = node_classifier_main_get(); struct pkt_classifier_engine * pkt_classifier_engine = classifier_main->pkt_classifier_engine; struct rule_list_parsed rule_list_parsed = {0}; - int ret = pkt_classifier_rule_parser(sc, pkt_classifier_engine_get_ruleset_type(pkt_classifier_engine), + /* Parse static rules */ + int ret = pkt_classifier_rule_parser(sc, pkt_classifier_engine_get_ruleset_type(pkt_classifier_engine), 0, &rule_list_parsed); + + if (ret != RT_SUCCESS) + { + MR_ERROR("Parsing of static packet classifier rule failed."); + return RT_ERR; + } + + /* Parse dynamic rules */ + ret = pkt_classifier_rule_parser(sc, pkt_classifier_engine_get_ruleset_type(pkt_classifier_engine), 1, + &rule_list_parsed); + if (ret != RT_SUCCESS) { - MR_ERROR("Parsing of packet classifier rule failed."); + MR_ERROR("Parsing of dynamic packet classifier rule failed."); return RT_ERR; } @@ -284,14 +296,24 @@ int classifier_init(struct sc_main * sc) classifier_main->pkt_classifier_engine = pkt_classifier_engine; } - /* Parse the rules. */ + /* Parse static rules */ struct rule_list_parsed rule_list_parsed = {0}; - int ret = pkt_classifier_rule_parser(sc, pkt_classifier_engine_get_ruleset_type(pkt_classifier_engine), + int ret = pkt_classifier_rule_parser(sc, pkt_classifier_engine_get_ruleset_type(pkt_classifier_engine), 0, &rule_list_parsed); if (ret != RT_SUCCESS) { - MR_ERROR("Parsing of packet classifier rule failed."); + MR_ERROR("Parsing of static packet classifier rule failed."); + return RT_ERR; + } + + /* Parse dynamic rules */ + ret = pkt_classifier_rule_parser(sc, pkt_classifier_engine_get_ruleset_type(pkt_classifier_engine), 1, + &rule_list_parsed); + + if (ret != RT_SUCCESS) + { + MR_ERROR("Parsing of dynamic packet classifier rule failed."); return RT_ERR; } @@ -498,6 +520,7 @@ static __rte_always_inline uint16_t classifier_node_process(struct rte_graph * g graph_stats->deal_pkts += cnt; graph_stats->hits += stats.hits; graph_stats->miss += stats.miss; + graph_stats->append_sid_err += stats.append_sid_err; return cnt; } diff --git a/test/ptf_test/bfd_test.py b/test/ptf_test/bfd_test.py index 06ec56f..97db79e 100644 --- a/test/ptf_test/bfd_test.py +++ b/test/ptf_test/bfd_test.py @@ -39,7 +39,10 @@ nohuge = 1 mem = 65535 [keepalive] -check_spinlock = 1 +check_spinlock=1 + +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0 = tunnat, 64 diff --git a/test/ptf_test/bond_test.py b/test/ptf_test/bond_test.py index 8a3d822..aed4e17 100644 --- a/test/ptf_test/bond_test.py +++ b/test/ptf_test/bond_test.py @@ -66,6 +66,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat,64 ctrlzone1=vsys,64 diff --git a/test/ptf_test/bridge_test.py b/test/ptf_test/bridge_test.py index bf1dfff..5bcc480 100644 --- a/test/ptf_test/bridge_test.py +++ b/test/ptf_test/bridge_test.py @@ -60,6 +60,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 diff --git a/test/ptf_test/classifier_test.py b/test/ptf_test/classifier_test.py index 82e525c..47d3dd4 100644 --- a/test/ptf_test/classifier_test.py +++ b/test/ptf_test/classifier_test.py @@ -67,6 +67,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -130,89 +132,81 @@ dynamic_conf_base = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier +ruleset_type=0 dst_ip_addr_v4=172.17.2.100 dst_ip_mask_v4=32 -action=nf_steering +action=2 priority=1 -category=0 sid=1000 vwire_id=0 [classifier_rule:1] rule_id=2 -ruleset_type=classifier +ruleset_type=0 dst_ip_addr_v4=172.17.2.101 dst_ip_mask_v4=32 -action=nf_steering +action=2 priority=1 -category=0 sid=1001 vwire_id=0 [classifier_rule:2] rule_id=3 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v4=172.17.2.102 src_ip_mask_v4=32 -action=nf_steering +action=2 priority=1 -category=0 sid=1002 vwire_id=0 [classifier_rule:3] rule_id=4 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v4=172.17.2.103 src_ip_mask_v4=32 -action=nf_steering +action=2 priority=1 -category=0 sid=1003 vwire_id=0 [classifier_rule:4] rule_id=5 -ruleset_type=classifier +ruleset_type=0 dst_ip_addr_v6=2222::4 dst_ip_mask_v6=128 -action=nf_steering +action=2 priority=1 -category=0 sid=1000 vwire_id=0 [classifier_rule:5] rule_id=6 -ruleset_type=classifier +ruleset_type=0 dst_ip_addr_v6=2222::5 dst_ip_mask_v6=128 -action=nf_steering +action=2 priority=1 -category=0 sid=1001 vwire_id=0 [classifier_rule:6] rule_id=7 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v6=2222::6 src_ip_mask_v6=128 -action=nf_steering +action=2 priority=1 -category=0 sid=1002 vwire_id=0 [classifier_rule:7] rule_id=8 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v6=2222::7 src_ip_mask_v6=128 -action=nf_steering +action=2 priority=1 -category=0 sid=1003 vwire_id=0 """ @@ -366,13 +360,12 @@ class TestForTreeSearch(BaseTest): global dynamic_conf_base for i in range(8,128): dynamic_conf_base += "[classifier_rule:" + str(i) + "]\n" - dynamic_conf_base += "ruleset_type=classifier\n" + dynamic_conf_base += "ruleset_type=0\n" dynamic_conf_base += "rule_id=" + str(i+1) + "\n" dynamic_conf_base += "dst_ip_addr_v4=172.19.2." + str(i) + "\n" dynamic_conf_base += "dst_ip_mask_v4=32\n" - dynamic_conf_base += "action=nf_steering\n" + dynamic_conf_base += "action=2\n" dynamic_conf_base += "priority=1\n" - dynamic_conf_base += "category=0\n" dynamic_conf_base += "sid=1000\n" dynamic_conf_base += "vwire_id=0\n\n" @@ -474,7 +467,6 @@ class TestForTreeSearch(BaseTest): finally: mrzcpd.stop() -category_conf = """Current not support priority""" start_conf_vwire = """ [device] @@ -526,6 +518,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -575,45 +569,42 @@ devices=veth0,normal mode=balance devices=veth1,normal -""" - -dynamic_conf_full_field_match_for_vwire = """ - [classifier_rule:0] rule_id=1 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v4=172.17.1.100 src_ip_mask_v4=32 dst_ip_addr_v4=172.17.2.100 dst_ip_mask_v4=32 -src_port_range_start=1000 -src_port_range_end=1000 -dst_port_range_start=80 -dst_port_range_end=80 -proto=tcp +src_port_start=1000 +src_port_end=1000 +dst_port_start=80 +dst_port_end=80 +proto=6 priority=1 sid=1000 -category=0 vwire_id=0 -action=nf_steering +action=2 -[classifier_rule:1] +""" + +dynamic_conf_full_field_match_for_vwire = """ +[classifier_rule:0] rule_id=2 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v6=1111::8888 src_ip_mask_v6=128 dst_ip_addr_v6=2222::9999 dst_ip_mask_v6=128 -src_port_range_start=1000 -src_port_range_end=1000 -dst_port_range_start=80 -dst_port_range_end=80 -proto=udp +src_port_start=1000 +src_port_end=1000 +dst_port_start=80 +dst_port_end=80 +proto=17 priority=1 sid=1001 -category=0 vwire_id=0 -action=nf_steering +action=2 """ """ @@ -707,13 +698,12 @@ class FullFieldTreeMatchForVwireTest(BaseTest): dynamic_conf = dynamic_conf_full_field_match_for_vwire for i in range(8,128): dynamic_conf += "[classifier_rule:" + str(i) + "]\n" - dynamic_conf += "ruleset_type=classifier\n" + dynamic_conf += "ruleset_type=0\n" dynamic_conf += "rule_id=" + str(i+1) + "\n" dynamic_conf += "dst_ip_addr_v4=172.19.2." + str(i) + "\n" dynamic_conf += "dst_ip_mask_v4=32\n" - dynamic_conf += "action=nf_steering\n" + dynamic_conf += "action=2\n" dynamic_conf += "priority=1\n" - dynamic_conf += "category=0\n" dynamic_conf += "sid=1000\n" dynamic_conf += "vwire_id=0\n\n" mrzcpd = Mrzcpd(start_conf_vwire,dynamic_conf) @@ -799,6 +789,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -859,39 +851,37 @@ devices=veth2,normal dynamic_conf_full_field_match_for_tera = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v4=172.17.1.100 src_ip_mask_v4=32 dst_ip_addr_v4=172.17.2.100 dst_ip_mask_v4=32 -src_port_range_start=1000 -src_port_range_end=1000 -dst_port_range_start=80 -dst_port_range_end=80 -proto=tcp +src_port_start=1000 +src_port_end=1000 +dst_port_start=80 +dst_port_end=80 +proto=6 priority=1 sid=1000 -category=0 tera_adapter_id=0 -action=nf_steering +action=2 [classifier_rule:1] rule_id=2 -ruleset_type=classifier +ruleset_type=0 src_ip_addr_v6=1111::8888 src_ip_mask_v6=128 dst_ip_addr_v6=2222::9999 dst_ip_mask_v6=128 -src_port_range_start=1000 -src_port_range_end=1000 -dst_port_range_start=80 -dst_port_range_end=80 -proto=udp +src_port_start=1000 +src_port_end=1000 +dst_port_start=80 +dst_port_end=80 +proto=17 priority=1 sid=1001 -category=0 tera_adapter_id=0 -action=nf_steering +action=2 """ @@ -976,13 +966,12 @@ class FullFieldTreeMatchForTeraTest(BaseTest): dynamic_conf = dynamic_conf_full_field_match_for_tera for i in range(8,128): dynamic_conf += "[classifier_rule:" + str(i) + "]\n" - dynamic_conf += "ruleset_type=classifier\n" + dynamic_conf += "ruleset_type=0\n" dynamic_conf += "rule_id=" + str(i+1) + "\n" dynamic_conf += "dst_ip_addr_v4=172.19.2." + str(i) + "\n" dynamic_conf += "dst_ip_mask_v4=32\n" - dynamic_conf += "action=nf_steering\n" + dynamic_conf += "action=2\n" dynamic_conf += "priority=1\n" - dynamic_conf += "category=0\n" dynamic_conf += "sid=1000\n" dynamic_conf += "tera_adapter_id=0\n\n" mrzcpd = Mrzcpd(start_conf_tera,dynamic_conf) diff --git a/test/ptf_test/endpoint_dev_test.py b/test/ptf_test/endpoint_dev_test.py index fa46b44..da136e6 100644 --- a/test/ptf_test/endpoint_dev_test.py +++ b/test/ptf_test/endpoint_dev_test.py @@ -40,6 +40,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat,128 diff --git a/test/ptf_test/etherfabric_test.py b/test/ptf_test/etherfabric_test.py index 61f2e17..5767968 100644 --- a/test/ptf_test/etherfabric_test.py +++ b/test/ptf_test/etherfabric_test.py @@ -40,6 +40,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -145,6 +147,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -271,6 +275,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -324,10 +330,9 @@ devices=veth-msgpack-tx,normal dynamic_conf_with_route_ctx = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 """ """ @@ -430,8 +435,10 @@ nohuge = 1 mem = 65535 [keepalive] -check_spinlock = 1 +check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0 = tunnat, 64 ctrlzone1 = vsys, 64 @@ -499,28 +506,25 @@ listen_device=veth4 dynamic_conf_with_non_contiguous_test = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 ef_adapter_id=0 [classifier_rule:1] rule_id=2 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1001 ef_adapter_id=2 [classifier_rule:2] rule_id=2 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1002 ef_adapter_id=4 """ diff --git a/test/ptf_test/health_check_test.py b/test/ptf_test/health_check_test.py index 71a48d9..5e85c5c 100644 --- a/test/ptf_test/health_check_test.py +++ b/test/ptf_test/health_check_test.py @@ -38,6 +38,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 diff --git a/test/ptf_test/load_balance_test.py b/test/ptf_test/load_balance_test.py index f762214..58a05d2 100644 --- a/test/ptf_test/load_balance_test.py +++ b/test/ptf_test/load_balance_test.py @@ -62,6 +62,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -111,10 +113,9 @@ devices=veth0,normal,veth1,normal,veth2,normal dynamic_conf = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 vwire_id=0 diff --git a/test/ptf_test/mrzcpd.py b/test/ptf_test/mrzcpd.py index 1f7b664..edb85c1 100644 --- a/test/ptf_test/mrzcpd.py +++ b/test/ptf_test/mrzcpd.py @@ -1,10 +1,9 @@ import ptf import time import os -import signal import subprocess import shutil -import urllib +from urllib import request mrzcpd_run_dir = "/var/run/mrzcpd" @@ -45,7 +44,9 @@ class Mrzcpd: start_timeout = 60 while start_timeout > 0: try: - response = urllib.urlopen('http://localhost:9086') + print("Try to connect to mrzcpd http server") + response = request.urlopen('http://127.0.0.1:9086/probe') + print(response.read()) break except: time.sleep(1) diff --git a/test/ptf_test/msgpack_test.py b/test/ptf_test/msgpack_test.py index a92b6ff..69e3108 100644 --- a/test/ptf_test/msgpack_test.py +++ b/test/ptf_test/msgpack_test.py @@ -56,6 +56,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat,128 @@ -105,10 +107,9 @@ dynamic_conf_serialize = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 vwire_id=0 """ @@ -203,6 +204,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat,128 @@ -252,10 +255,9 @@ devices=veth2,normal dynamic_conf_deserialize = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 vwire_id=0 @@ -358,6 +360,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat,128 @@ -406,10 +410,9 @@ devices=veth-msgpack-tx,normal dynamic_conf_serialize_and_deserialize = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 vwire_id=0 diff --git a/test/ptf_test/tera_test.py b/test/ptf_test/tera_test.py index 56b58f3..0d024a7 100644 --- a/test/ptf_test/tera_test.py +++ b/test/ptf_test/tera_test.py @@ -41,6 +41,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -153,6 +155,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -270,6 +274,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -615,6 +621,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -855,10 +863,9 @@ tera_adapter_id=15 dynamic_conf_with_msgpack = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 """ @@ -1067,6 +1074,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -1227,10 +1236,9 @@ devices=veth-msgpack-tx,normal dynamic_conf_with_nf = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 """ """ @@ -1412,6 +1420,8 @@ mem=65535 [keepalive] check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0=tunnat, 64 ctrlzone1=vsys, 64 @@ -1572,10 +1582,9 @@ devices=veth-msgpack-tx,normal dynamic_conf_with_route_ctx = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 """ """ @@ -1755,8 +1764,10 @@ nohuge = 1 mem = 65535 [keepalive] -check_spinlock = 1 +check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0 = tunnat, 64 ctrlzone1 = vsys, 64 @@ -1830,28 +1841,25 @@ mac_flipping=1 dynamic_conf_with_non_contiguous_test = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 tera_adapter_id=0 [classifier_rule:1] rule_id=2 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1001 tera_adapter_id=2 [classifier_rule:2] rule_id=2 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1002 tera_adapter_id=4 """ diff --git a/test/ptf_test/vwire_test.py b/test/ptf_test/vwire_test.py index 3d8e7b8..8868f2b 100644 --- a/test/ptf_test/vwire_test.py +++ b/test/ptf_test/vwire_test.py @@ -173,8 +173,10 @@ nohuge = 1 mem = 65535 [keepalive] -check_spinlock = 1 +check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0 = tunnat, 64 ctrlzone1 = vsys, 64 @@ -405,8 +407,10 @@ nohuge = 1 mem = 65535 [keepalive] -check_spinlock = 1 +check_spinlock=1 +[http_server] +listen_addr=127.0.0.1 [ctrlzone] ctrlzone0 = tunnat, 64 ctrlzone1 = vsys, 64 @@ -475,28 +479,25 @@ devices=veth8,normal dynamic_conf_with_non_contiguous_test = """ [classifier_rule:0] rule_id=1 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1000 vwire_id=0 [classifier_rule:1] rule_id=2 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1001 vwire_id=2 [classifier_rule:2] rule_id=2 -ruleset_type=classifier -action=nf_steering +ruleset_type=0 +action=2 priority=1 -category=0 sid=1002 vwire_id=4 """ -- cgit v1.2.3