diff options
| author | 刘畅 <[email protected]> | 2024-01-11 06:15:25 +0000 |
|---|---|---|
| committer | 刘畅 <[email protected]> | 2024-01-11 06:15:25 +0000 |
| commit | 44245c94530345efbd1445af837fa469f55924de (patch) | |
| tree | fc619dc01717e6facf3e6488d116b0afec734358 | |
| parent | 969082ccf054b6a087ef22513b48dd5d53a9a519 (diff) | |
| parent | c2dff5b069cbc7567d406493c65d63381122bc60 (diff) | |
Merge branch 'bugfix_revert_dup_primary_profile_process' into 'rel'
revert dup primary profile process
See merge request tango/shaping-engine!72
| -rw-r--r-- | shaping/include/shaper.h | 1 | ||||
| -rw-r--r-- | shaping/src/shaper.cpp | 3 | ||||
| -rw-r--r-- | shaping/src/shaper_maat.cpp | 16 | ||||
| -rw-r--r-- | shaping/src/shaper_stat.cpp | 4 | ||||
| -rw-r--r-- | shaping/test/gtest_shaper.cpp | 56 | ||||
| -rw-r--r-- | shaping/test/gtest_shaper_maat.cpp | 49 |
6 files changed, 0 insertions, 129 deletions
diff --git a/shaping/include/shaper.h b/shaping/include/shaper.h index b7741a3..33eb103 100644 --- a/shaping/include/shaper.h +++ b/shaping/include/shaper.h @@ -113,7 +113,6 @@ struct shaping_rule_info { int vsys_id; int id;//rule_id int fair_factor; - int has_dup_profile; struct shaping_profile_info primary; struct shaping_profile_info borrowing[SHAPING_REF_PROFILE_NUM_MAX]; int borrowing_num; diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp index 9f99ffd..9ca8a28 100644 --- a/shaping/src/shaper.cpp +++ b/shaping/src/shaper.cpp @@ -728,9 +728,6 @@ static int shaper_token_consume(struct shaping_thread_ctx *ctx, struct shaping_f } struct shaping_rule_info *rule = &sf->matched_rule_infos[sf->anchor]; - if (rule->has_dup_profile) { - return SHAPER_TOKEN_GET_PASS;//dup profile, don't need to get token and forward packet - } time_t curr_time = time(NULL); if (curr_time - sf->check_rule_time >= ctx->conf.check_rule_enable_interval_sec) { diff --git a/shaping/src/shaper_maat.cpp b/shaping/src/shaper_maat.cpp index f48f68e..f159c2f 100644 --- a/shaping/src/shaper_maat.cpp +++ b/shaping/src/shaper_maat.cpp @@ -358,20 +358,6 @@ static int shaper_rules_dup_remove(struct shaping_flow *sf, long long *rule_comp return rule_num_remove_dup; } -static void shaper_rules_dup_profile_check(struct shaping_flow *sf) -{ - for (int i = 0; i < sf->rule_num; i++) { - for (int j = i + 1; j < sf->rule_num; j++) { - if (sf->matched_rule_infos[i].primary.id == sf->matched_rule_infos[j].primary.id) { - sf->matched_rule_infos[j].has_dup_profile = 1; - LOG_INFO("%s: shaping rule %d and %d have same primary profile %d", LOG_TAG_MAAT, sf->matched_rule_infos[i].id, sf->matched_rule_infos[j].id, sf->matched_rule_infos[i].primary.id); - } - } - } - - return; -} - void shaper_rules_update(struct shaping_thread_ctx *ctx, struct shaping_flow *sf, long long *rule_compile_ids, int rule_num) { int i, j; @@ -413,8 +399,6 @@ void shaper_rules_update(struct shaping_thread_ctx *ctx, struct shaping_flow *sf sf->rule_num += rule_num_remove_dup; shaper_profiles_priority_update(sf); - shaper_rules_dup_profile_check(sf); - return; } diff --git a/shaping/src/shaper_stat.cpp b/shaping/src/shaper_stat.cpp index 656d2af..c0b67d1 100644 --- a/shaping/src/shaper_stat.cpp +++ b/shaping/src/shaper_stat.cpp @@ -278,10 +278,6 @@ void shaper_stat_forward_all_rule_inc(struct shaping_stat *stat, struct shaping_ for (i = 0; i < sf->rule_num; i++) { rule = &sf->matched_rule_infos[i]; - if (rule->has_dup_profile || !rule->is_enabled) { - continue; - } - shaper_stat_forward_inc(&rule->primary.stat, direction, pkt_len, thread_id); } diff --git a/shaping/test/gtest_shaper.cpp b/shaping/test/gtest_shaper.cpp index 4b0cda6..58afc4a 100644 --- a/shaping/test/gtest_shaper.cpp +++ b/shaping/test/gtest_shaper.cpp @@ -1731,62 +1731,6 @@ TEST(two_sessions, primary_profile_priority_blocked_by_borrow_profile) /*session1 match rule1 rule1: - profile_a - rule2: - profile_a - - profile_a(id 0): limit 1000 -*/ -TEST(single_session, dup_primary_profile)//dup primary profile, just process the first rule and ignore others -{ - struct stub_pkt_queue expec_tx_queue; - struct stub_pkt_queue *actual_tx_queue; - struct shaping_ctx *ctx = NULL; - struct shaping_flow *sf = NULL; - long long rule_ids[] = {1, 2}; - int profile_nums[] = {1, 1}; - int prioritys[] = {1, 2}; - int profile_id[][MAX_REF_PROFILE] = {{0}, {0}}; - - - TAILQ_INIT(&expec_tx_queue); - stub_init(); - - ctx = shaping_engine_init(); - ASSERT_TRUE(ctx != NULL); - sf = shaping_flow_new(&ctx->thread_ctx[0]); - ASSERT_TRUE(sf != NULL); - - stub_set_matched_shaping_rules(2, rule_ids, prioritys, profile_nums, profile_id); - - stub_set_token_bucket_avl_per_sec(0, 1000, SHAPING_DIR_OUT); - actual_tx_queue = stub_get_tx_queue(); - shaper_rules_update(&ctx->thread_ctx[0], sf, rule_ids, 2); - - /*******send packets***********/ - send_packets(&ctx->thread_ctx[0], sf, 100, 100, SHAPING_DIR_OUT, &expec_tx_queue, 2, 0); - ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10)); - ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue)); - - while (!TAILQ_EMPTY(&expec_tx_queue)) {//last 90 packets - stub_refresh_token_bucket(0); - for (int i = 0; i < 20; i++) { - polling_entry(ctx->thread_ctx[0].sp, ctx->thread_ctx[0].stat, &ctx->thread_ctx[0]); - stub_curr_time_ns_inc(STUB_TIME_INC_FOR_PACKET); - } - ASSERT_EQ(0, judge_packet_eq(&expec_tx_queue, actual_tx_queue, 10)); - ASSERT_TRUE(TAILQ_EMPTY(actual_tx_queue)); - } - - shaping_flow_free(&ctx->thread_ctx[0], sf); - fieldstat_global_disable_prometheus_endpoint(); - shaper_thread_resource_clear(); - shaping_engine_destroy(ctx); - stub_clear_matched_shaping_rules(); -} - -/*session1 match rule1 - rule1: profile: limit 1000*/ TEST(statistics, udp_drop_pkt) { diff --git a/shaping/test/gtest_shaper_maat.cpp b/shaping/test/gtest_shaper_maat.cpp index 25d8dee..ff94efe 100644 --- a/shaping/test/gtest_shaper_maat.cpp +++ b/shaping/test/gtest_shaper_maat.cpp @@ -178,55 +178,6 @@ TEST(shaping_flow, update_rule_dup) free(ctx.maat_info); } -TEST(shaping_flow, update_primary_profile_dup) -{ - struct shaping_thread_ctx ctx; - struct shaping_flow sf; - struct shaping_rule_info *rule_info; - long long rule_ids[] = {1, 2, 3}; - int prioritys[] = {1, 2, 3}; - int profile_nums[] = {1, 1, 1}; - int profile_ids[][MAX_REF_PROFILE] = {{1}, {1}, {1}}; - - stub_init(); - - stub_set_matched_shaping_rules(3, rule_ids, prioritys, profile_nums, profile_ids); - - ctx.maat_info = (struct shaping_maat_info *)calloc(1, sizeof(struct shaping_maat_info)); - ctx.maat_info->rule_table_id = STUB_MAAT_SHAPING_RULE_TABLE_ID; - ctx.maat_info->profile_table_id = STUB_MAAT_SHAPING_PROFILE_TABLE_ID; - - memset(&sf, 0, sizeof(sf)); - sf.priority = SHAPING_PRIORITY_NUM_MAX; - - shaper_rules_update(&ctx, &sf, rule_ids, 3); - - EXPECT_EQ(sf.rule_num, 3); - - rule_info = &sf.matched_rule_infos[0]; - EXPECT_EQ(rule_info->id, 1); - EXPECT_EQ(rule_info->primary.id, 1); - EXPECT_EQ(rule_info->primary.priority, 1); - EXPECT_EQ(rule_info->borrowing_num, 0); - EXPECT_EQ(rule_info->has_dup_profile, 0); - - rule_info = &sf.matched_rule_infos[1]; - EXPECT_EQ(rule_info->id, 2); - EXPECT_EQ(rule_info->primary.id, 1); - EXPECT_EQ(rule_info->primary.priority, 1); - EXPECT_EQ(rule_info->borrowing_num, 0); - EXPECT_EQ(rule_info->has_dup_profile, 1); - - rule_info = &sf.matched_rule_infos[2]; - EXPECT_EQ(rule_info->id, 3); - EXPECT_EQ(rule_info->primary.id, 1); - EXPECT_EQ(rule_info->primary.priority, 1); - EXPECT_EQ(rule_info->borrowing_num, 0); - EXPECT_EQ(rule_info->has_dup_profile, 1); - - free(ctx.maat_info); -} - TEST(shaping_flow, update_rule_after_priority_confirmed) { struct shaping_thread_ctx ctx; |
