Skip to content
Snippets Groups Projects
Verified Commit cc1d993b authored by Suvendhu Hansa's avatar Suvendhu Hansa :speech_balloon: Committed by IOPSYS Dev
Browse files

Fix unnamed uci section usages

parent 19c4b31e
Branches
No related tags found
1 merge request!37Fix bug#16201 align section/instance handling
Pipeline #191754 passed
......@@ -188,36 +188,27 @@ static int addObjQoSClassification(char *refparam, struct dmctx *ctx, void *data
static int delObjQoSClassification(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *stmp = NULL;
char *curr_order = NULL;
switch (del_action) {
case DEL_INST:
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "order", &curr_order);
qos_update_order(curr_order, true);
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "order", &curr_order);
qos_update_order(curr_order, true);
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections_safe("qos", "classify", stmp, s) {
struct uci_section *dmmap_qos = NULL;
get_dmmap_section_of_config_section("dmmap_qos", "classify", section_name(s), &dmmap_qos);
dmuci_delete_by_section(dmmap_qos, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
return 0;
}
static int addObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct uci_section *dmmap = NULL, *s = NULL;
char s_name[16] = {0};
snprintf(s_name, sizeof(s_name), "policer_%s", *instance);
dmuci_add_section("qos", "policer", &s);
dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enable", "0");
dmuci_set_value_by_section(s, "committed_rate", "0");
dmuci_set_value_by_section(s, "committed_burst_size", "0");
......@@ -225,59 +216,45 @@ static int addObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char
dmuci_set_value_by_section(s, "peak_rate", "0");
dmuci_set_value_by_section(s, "peak_burst_size", "0");
dmuci_set_value_by_section(s, "meter_type", "0");
dmuci_set_value_by_section(s, "name", section_name(s));
dmuci_set_value_by_section(s, "name", s_name);
dmuci_add_section_bbfdm("dmmap_qos", "policer", &dmmap);
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
dmuci_set_value_by_section(dmmap, "section_name", s_name);
dmuci_set_value_by_section(dmmap, "policer_instance", *instance);
return 0;
}
static int delObjQoSPolicer(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *stmp = NULL, *sec = NULL;
struct uci_section *sec = NULL;
char *p_name = NULL;
switch (del_action) {
case DEL_INST:
// store section name to update corresponding classification
// section if any
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &p_name);
// Set the Classification.Policer to blank if corresponding
// Policer instance has been deleted
uci_foreach_option_eq("qos", "classify", "policer", p_name, sec) {
dmuci_set_value_by_section(sec, "policer", "");
}
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections_safe("qos", "policer", stmp, s) {
struct uci_section *dmmap_section = NULL;
// store section name to update corresponding classification
// section if any
dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &p_name);
get_dmmap_section_of_config_section("dmmap_qos", "policer", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
// Set the Classification.Policer to blank if corresponding
// Policer instance has been deleted
uci_foreach_option_eq("qos", "classify", "policer", p_name, sec) {
dmuci_set_value_by_section(sec, "policer", "");
}
dmuci_delete_by_section(s, NULL, NULL);
}
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
// Since all policer have been deleted, we can safely set the
// value of all Classification.Policer params to empty
uci_foreach_sections("qos", "classify", sec) {
dmuci_set_value_by_section(sec, "policer", "");
}
break;
}
return 0;
}
static int addObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct uci_section *dmmap = NULL, *s = NULL;
char s_name[16] = {0};
snprintf(s_name, sizeof(s_name), "queue_%s", *instance);
dmuci_add_section("qos", "queue", &s);
dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enable", "false");
dmuci_set_value_by_section(s, "weight", "0");
dmuci_set_value_by_section(s, "precedence", "1");
......@@ -286,31 +263,16 @@ static int addObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char **
dmuci_set_value_by_section(s, "rate", "-1");
dmuci_add_section_bbfdm("dmmap_qos", "queue", &dmmap);
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
dmuci_set_value_by_section(dmmap, "section_name", s_name);
dmuci_set_value_by_section(dmmap, "queueinstance", *instance);
return 0;
}
static int delObjQoSQueue(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *stmp = NULL;
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections_safe("qos", "queue", stmp, s) {
struct uci_section *dmmap_section = NULL;
get_dmmap_section_of_config_section("dmmap_qos", "queue", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
return 0;
}
......@@ -325,56 +287,36 @@ static int addObjQoSQueueStats(char *refparam, struct dmctx *ctx, void *data, ch
static int delObjQoSQueueStats(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *stmp = NULL;
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
break;
case DEL_ALL:
uci_path_foreach_sections_safe(bbfdm, "dmmap_qstats", "queue_stats", stmp, s) {
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
return 0;
}
static int addObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct uci_section *dmmap = NULL, *s = NULL;
char s_name[16] = {0};
snprintf(s_name, sizeof(s_name), "shaper_%s", *instance);
dmuci_add_section("qos", "shaper", &s);
dmuci_rename_section_by_section(s, s_name);
dmuci_set_value_by_section(s, "enable", "0");
dmuci_set_value_by_section(s, "burst_size", "0");
dmuci_set_value_by_section(s, "rate", "0");
dmuci_add_section_bbfdm("dmmap_qos", "shaper", &dmmap);
dmuci_set_value_by_section(dmmap, "section_name", section_name(s));
dmuci_set_value_by_section(dmmap, "section_name", s_name);
dmuci_set_value_by_section(dmmap, "shaperinstance", *instance);
return 0;
}
static int delObjQoSShaper(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *stmp = NULL;
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections_safe("qos", "shaper", stmp, s) {
struct uci_section *dmmap_section = NULL;
dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
get_dmmap_section_of_config_section("dmmap_qos", "shaper", section_name(s), &dmmap_section);
dmuci_delete_by_section(dmmap_section, NULL, NULL);
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
return 0;
}
......@@ -1330,22 +1272,25 @@ static int set_QoSClassification_Policer(char *refparam, struct dmctx *ctx, void
{
struct uci_section *dmmap_s = NULL;
char *linker = NULL;
char link_inst[8] = {0};
int inst = 0;
switch (action) {
case VALUECHECK:
if (bbfdm_validate_string(ctx, value, -1, 64, NULL, NULL))
if (bbfdm_validate_string(ctx, value, -1, 256, NULL, NULL))
return FAULT_9007;
if (match(value, "Device.QoS.Policer.", 0, NULL) == false)
return FAULT_9007;
break;
case VALUESET:
if (DM_LSTRNCMP(value, "Device.QoS.Policer.", 19) == 0 && strlen(value) >= 20) {
char link_inst[8] = {0};
sscanf(value, "Device.QoS.Policer.%d.", &inst);
snprintf(link_inst, sizeof(link_inst), "%d", inst);
snprintf(link_inst, sizeof(link_inst), "%c", value[19]);
get_dmmap_section_of_config_section_eq("dmmap_qos", "policer", "policer_instance", link_inst, &dmmap_s);
dmuci_get_value_by_section_string(dmmap_s, "section_name", &linker);
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "policer", linker);
get_dmmap_section_of_config_section_eq("dmmap_qos", "policer", "policer_instance", link_inst, &dmmap_s);
dmuci_get_value_by_section_string(dmmap_s, "section_name", &linker);
dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "policer", linker);
}
break;
}
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment