diff --git a/platform/include/global_metrics.h b/platform/include/global_metrics.h index 8eaf699..4771136 100644 --- a/platform/include/global_metrics.h +++ b/platform/include/global_metrics.h @@ -52,8 +52,6 @@ struct global_metrics uint64_t sf_active_times; // 累计值 uint64_t sf_inactive_times; // 累计值 - uint64_t sf_mac_exist_times; // 累计值 - uint64_t sf_mac_noexist_times; // 累计值 uint64_t session_nums; // 瞬时值 uint64_t send_log; // 瞬时值 diff --git a/platform/include/policy.h b/platform/include/policy.h index c5293e0..faa3a77 100644 --- a/platform/include/policy.h +++ b/platform/include/policy.h @@ -39,7 +39,6 @@ enum session_action_reason ACTION_BYPASS_DUE_UNAVAILABLE_ACTION = 0x13, ACTION_BYPASS_DUE_FAILURE_ACTION = 0x14, ACTION_BYPASS_DUE_INVALID_POLICY = 0x15, - ACTION_BYPASS_DUE_INVALID_SF_MAC = 0x16, ACTION_BLOCK_DUE_UNAVAILABLE_ACTION = 0x21, ACTION_BLOCK_DUE_FAILURE_ACTION = 0x22, @@ -79,7 +78,6 @@ struct connectivity int int_vlan_tag; int ext_vlan_tag; char dest_ip[64]; - char dest_mac[32]; // CM does not send this field, but only reads it from json, which is used for debugging }; struct selected_sf diff --git a/platform/src/global_metrics.cpp b/platform/src/global_metrics.cpp index 5a26af0..36f6901 100644 --- a/platform/src/global_metrics.cpp +++ b/platform/src/global_metrics.cpp @@ -70,8 +70,6 @@ enum SCE_STAT_FIELD // health check STAT_SF_ACTIVE_TIMES, STAT_SF_INACTIVE_TIMES, - STAT_SF_MAC_EXIST_TIMES, - STAT_SF_MAC_NOEXIST_TIMES, // send log STAT_SEND_LOG, @@ -144,8 +142,6 @@ static const char *stat_map[] = // health check [STAT_SF_ACTIVE_TIMES] = "sf_active", [STAT_SF_INACTIVE_TIMES] = "sf_inactive", - [STAT_SF_MAC_EXIST_TIMES] = "sf_mac_succ", - [STAT_SF_MAC_NOEXIST_TIMES] = "sf_mac_err", // send log [STAT_SEND_LOG] = "send_log", @@ -299,8 +295,6 @@ void global_metrics_dump(struct global_metrics *metrics) // health check FS_operate(metrics->fs_handle, metrics->fs_id[STAT_SF_ACTIVE_TIMES], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->sf_active_times), 0, __ATOMIC_RELAXED)); FS_operate(metrics->fs_handle, metrics->fs_id[STAT_SF_INACTIVE_TIMES], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->sf_inactive_times), 0, __ATOMIC_RELAXED)); - FS_operate(metrics->fs_handle, metrics->fs_id[STAT_SF_MAC_EXIST_TIMES], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->sf_mac_exist_times), 0, __ATOMIC_RELAXED)); - FS_operate(metrics->fs_handle, metrics->fs_id[STAT_SF_MAC_NOEXIST_TIMES], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->sf_mac_noexist_times), 0, __ATOMIC_RELAXED)); // send log FS_operate(metrics->fs_handle, metrics->fs_id[STAT_SEND_LOG], 0, FS_OP_SET, __atomic_fetch_add(&(metrics->send_log), 0, __ATOMIC_RELAXED)); diff --git a/platform/src/policy.cpp b/platform/src/policy.cpp index b850e93..6705b37 100644 --- a/platform/src/policy.cpp +++ b/platform/src/policy.cpp @@ -209,8 +209,6 @@ const char *session_action_reason_to_string(enum session_action_reason session_a return "bypass_due_failure_action"; case ACTION_BYPASS_DUE_INVALID_POLICY: return "bypass_due_invalid_policy"; - case ACTION_BYPASS_DUE_INVALID_SF_MAC: - return "bypass_due_invalid_sf_mac"; case ACTION_BLOCK_DUE_UNAVAILABLE_ACTION: return "block_due_unavailable_action"; case ACTION_BLOCK_DUE_FAILURE_ACTION: @@ -838,14 +836,6 @@ static void sf_param_new_cb(int table_id, const char *key, const char *table_lin } memcpy(param->sf_connectivity.dest_ip, item->valuestring, strlen(item->valuestring)); LOG_DEBUG("%s: parse sf profile: %d, connectivity->dest_ip: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring); - - // CM does not send this field, but only reads it from json, which is used for debugging - item = cJSON_GetObjectItem(root1, "dest_mac"); - if (item && cJSON_IsString(item)) - { - memcpy(param->sf_connectivity.dest_mac, item->valuestring, strlen(item->valuestring)); - LOG_DEBUG("%s: parse sf profile: %d, connectivity->dst_mac: %s", LOG_TAG_POLICY, param->sf_profile_id, item->valuestring); - } } // health_check @@ -1029,13 +1019,12 @@ static void select_sf_by_nearby_and_active(struct policy_enforcer *enforcer, str // return : SESSION_ACTION_BYPASS, not care selected_sf_profile_id // return : SESSION_ACTION_BLOCK, not care selected_sf_profile_id // return : SESSION_ACTION_FORWARD, care selected_sf_profile_id -static enum session_action select_sf_by_ldbc(uint64_t hash, struct sff_param *sff_param, struct fixed_num_array *array, int *selected_sf_profile_id, enum session_action_reason *sf_action_reason, struct session_ctx *s_ctx) +static enum session_action select_sf_by_ldbc(uint64_t hash, struct sff_param *sff_param, struct fixed_num_array *array, int *selected_sf_profile_id, enum session_action_reason *sf_action_reason, char *sf_dst_mac, struct session_ctx *s_ctx) { struct thread_ctx *thread = (struct thread_ctx *)s_ctx->ref_thread_ctx; struct global_metrics *g_metrics = thread->ref_metrics; *selected_sf_profile_id = -1; - int sf_is_active = 0; int sf_profile_id = 0; int sf_profile_index = 0; int sf_profile_num = 0; @@ -1046,9 +1035,9 @@ static enum session_action select_sf_by_ldbc(uint64_t hash, struct sff_param *sf { sf_profile_index = (int)(hash % sf_profile_num); sf_profile_id = fixed_num_array_index_elem(array, sf_profile_index); - sf_is_active = health_check_session_get_status(sf_profile_id); - if (sf_is_active == 1) + memset(sf_dst_mac, 0, 32); + if (health_check_session_get_mac(sf_profile_id, sf_dst_mac) == 0) { __atomic_fetch_add(&g_metrics->sf_active_times, 1, __ATOMIC_RELAXED); @@ -1488,7 +1477,7 @@ void policy_enforce_select_chaining(struct selected_chaining *chaining, struct p } hash_value = raw_packet_parser_get_hash_value(parser, sff_param->sff_ldbc.method, dir_is_internal); - item->sf_action = select_sf_by_ldbc(hash_value, sff_param, &array, &(item->sf_profile_id), &(item->sf_action_reason), s_ctx); + item->sf_action = select_sf_by_ldbc(hash_value, sff_param, &array, &(item->sf_profile_id), &(item->sf_action_reason), item->sf_dst_mac, s_ctx); LOG_DEBUG("%s: chaining policy %d -> sff_profile %d sf_profile_ids_num %d (after filter ldbc)", LOG_TAG_POLICY, policy_id, item->sff_profile_id, fixed_num_array_count_elem(&array)); if (item->sf_action != SESSION_ACTION_FORWARD) { @@ -1514,32 +1503,8 @@ void policy_enforce_select_chaining(struct selected_chaining *chaining, struct p item->sf_connectivity.int_vlan_tag = sf_param->sf_connectivity.int_vlan_tag; item->sf_connectivity.ext_vlan_tag = sf_param->sf_connectivity.ext_vlan_tag; memcpy(item->sf_connectivity.dest_ip, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip)); - memcpy(item->sf_dst_ip, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip)); - if (strlen(sf_param->sf_connectivity.dest_mac)) - { - // CM does not send this field, but only reads it from json, which is used for debugging - memcpy(item->sf_dst_mac, sf_param->sf_connectivity.dest_ip, strlen(sf_param->sf_connectivity.dest_ip)); - } - else - { - if (health_check_session_get_mac(item->sf_profile_id, item->sf_dst_mac) == 0) - { - __atomic_fetch_add(&g_metrics->sf_mac_exist_times, 1, __ATOMIC_RELAXED); - } - else - { - __atomic_fetch_add(&g_metrics->sf_mac_noexist_times, 1, __ATOMIC_RELAXED); - LOG_ERROR("%s: failed to get sf mac address of selected profile %d, bypass current sff !!!", LOG_TAG_POLICY, item->sf_profile_id); - item->sf_action = SESSION_ACTION_BYPASS; - item->sf_action_reason = ACTION_BYPASS_DUE_INVALID_SF_MAC; - chaining->chaining_used++; - sff_param_free(sff_param); - sf_param_free(sf_param); - continue; - } - } chaining->chaining_used++; sf_param_free(sf_param); diff --git a/resource/sce.json b/resource/sce.json index e2ccbe6..262fed2 100644 --- a/resource/sce.json +++ b/resource/sce.json @@ -3,8 +3,8 @@ { "table_name": "SERVICE_FUNCTION_PROFILE", "table_content": [ - "1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\",\"dest_mac\":\"AA:AA:AA:AA:AA:AA\"}\t{\"method\":\"none\"}\t1", - "2\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"2.2.2.2\",\"dest_mac\":\"BB:BB:BB:BB:BB:BB\"}\t{\"method\":\"bfd\",\"interval_ms\":100,\"retires\":5}\t1", + "1\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"none\"}\t1", + "2\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"2.2.2.2\"}\t{\"method\":\"bfd\",\"interval_ms\":100,\"retires\":5}\t1", "3\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"in_band_bfd\",\"address\":\"1.2.3.4\",\"port\":\"10000\",\"interval_ms\":100,\"retires\":5}\t1", "4\tdevice_group_a\t1\t{\"method\":\"vxlan_g\",\"dest_ip\":\"1.1.1.1\"}\t{\"method\":\"http\",\"url\":\"http://192.168.100.1:8080/health_check.index\",\"interval_ms\":100,\"retires\":5}\t1", "5\tdevice_group_a\t1\t{\"method\":\"layer2_switch\",\"int_vlan_tag\":10,\"ext_vlan_tag\":5}\t{\"method\":\"none\"}\t1",