From 41825df451d3ccc1b8129bac03e16e47ebd602c8 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 26 Mar 2024 06:51:03 +0000 Subject: TSG-20128: Shaping Profile AQM删除enbaled开关,增加none选项值 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shaping/src/shaper_maat.cpp | 29 +++++++++++++---------------- shaping/test/gtest_shaper_maat.cpp | 2 +- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/shaping/src/shaper_maat.cpp b/shaping/src/shaper_maat.cpp index 9def069..cac0d3d 100644 --- a/shaping/src/shaper_maat.cpp +++ b/shaping/src/shaper_maat.cpp @@ -257,26 +257,23 @@ void shaper_profile_ex_new(const char *table_name, int table_id, const char *key goto END; } - tmp_obj = cJSON_GetObjectItem(json, "enabled"); + + tmp_obj = cJSON_GetObjectItem(json, "algorithm"); if (!tmp_obj) { - LOG_ERROR("%s: json parse aqm enabled failed for profile id %d, line %s", LOG_TAG_MAAT, s_pf->id, table_line); + LOG_ERROR("%s: json parse algorithm failed for profile id %d, line %s", LOG_TAG_MAAT, s_pf->id, table_line); goto END; } - if (tmp_obj->valueint == 1) { - tmp_obj = cJSON_GetObjectItem(json, "algorithm"); - if (!tmp_obj) { - LOG_ERROR("%s: json parse algorithm failed for profile id %d, line %s", LOG_TAG_MAAT, s_pf->id, table_line); - goto END; - } - if (strncmp(tmp_obj->valuestring, "blue", strlen(tmp_obj->valuestring)) == 0) { - s_pf->aqm_type = AQM_TYPE_BLUE; - } else if (strncmp(tmp_obj->valuestring, "codel", strlen(tmp_obj->valuestring)) == 0) { - s_pf->aqm_type = AQM_TYPE_CODEL; - } else { - LOG_ERROR("%s: json parse aqm type wrong for profile id %d, line %s", LOG_TAG_MAAT, s_pf->id, table_line); - goto END; - } + if (strncmp(tmp_obj->valuestring, "none", strlen(tmp_obj->valuestring)) == 0) { + s_pf->aqm_type = AQM_TYPE_NONE; + } else if (strncmp(tmp_obj->valuestring, "blue", strlen(tmp_obj->valuestring)) == 0) { + s_pf->aqm_type = AQM_TYPE_BLUE; + } else if (strncmp(tmp_obj->valuestring, "codel", strlen(tmp_obj->valuestring)) == 0) { + s_pf->aqm_type = AQM_TYPE_CODEL; + } else { + LOG_ERROR("%s: json parse aqm type wrong for profile id %d, line %s", LOG_TAG_MAAT, s_pf->id, table_line); + goto END; } + cJSON_Delete(json); //parse limits of profile diff --git a/shaping/test/gtest_shaper_maat.cpp b/shaping/test/gtest_shaper_maat.cpp index 96071e2..3b619fc 100644 --- a/shaping/test/gtest_shaper_maat.cpp +++ b/shaping/test/gtest_shaper_maat.cpp @@ -44,7 +44,7 @@ TEST(shaping_profile, parse) fair_share\t\ max_min_host_fairness\t\ [{\"direction\":\"incoming\",\"bandwidth\":1024},{\"direction\":\"outgoing\",\"bandwidth\":2048}]\t\ - {\"enabled\":1,\"algorithm\":\"codel\"}\t\ + {\"algorithm\":\"codel\"}\t\ {}\t\ 1"; struct shaping_profile *s_pf = NULL; -- cgit v1.2.3