summaryrefslogtreecommitdiff
path: root/shaping/src
diff options
context:
space:
mode:
authorroot <[email protected]>2024-01-09 08:20:21 +0000
committerroot <[email protected]>2024-01-09 08:20:21 +0000
commit5f4d71b683d3d460bb0785a9426a4f12c81d99c9 (patch)
treead90f13e0866045d6a7afe5aa45f5ecad71b1c9d /shaping/src
parent7c599b8c88ecc009651062eddbff0b07909b8928 (diff)
TSG-18176:对于一个session,当同一个profile多次作为primary profile出现时,按规则匹配顺序,只执行匹配的第一条rule,使用被执行的rule配置的fair-factor。
当同一个profile作为borrow多次出现时,暂时忽略此情况不处理
Diffstat (limited to 'shaping/src')
-rw-r--r--shaping/src/shaper.cpp5
-rw-r--r--shaping/src/shaper_maat.cpp16
-rw-r--r--shaping/src/shaper_stat.cpp4
3 files changed, 24 insertions, 1 deletions
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp
index 5a53232..6ea2afe 100644
--- a/shaping/src/shaper.cpp
+++ b/shaping/src/shaper.cpp
@@ -729,8 +729,11 @@ 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) {
sf->check_rule_time = curr_time;
if (shaper_rule_is_enabled(ctx, rule->id) != 1) {
diff --git a/shaping/src/shaper_maat.cpp b/shaping/src/shaper_maat.cpp
index f159c2f..f48f68e 100644
--- a/shaping/src/shaper_maat.cpp
+++ b/shaping/src/shaper_maat.cpp
@@ -358,6 +358,20 @@ 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;
@@ -399,6 +413,8 @@ 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 db5b5f7..24edc08 100644
--- a/shaping/src/shaper_stat.cpp
+++ b/shaping/src/shaper_stat.cpp
@@ -276,6 +276,10 @@ 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);
}