From eaa72adeab3acab147eb1a0bf376a499b734d6c2 Mon Sep 17 00:00:00 2001
From: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
Date: Fri, 13 Sep 2024 10:41:43 +0200
Subject: [PATCH] Pipeline improvements

---
 .gitignore                        |   2 +
 .gitlab-ci.yml                    |  13 +-
 gitlab-ci/compile.sh              |  15 ---
 gitlab-ci/install-dependencies.sh |   7 +
 gitlab-ci/shared.sh               |   2 +-
 src/common.c                      |  10 +-
 src/common.h                      |   6 +-
 src/gre.c                         |  79 ++++-------
 src/interfacestack.c              |   8 +-
 src/ip.c                          | 214 +++++++++---------------------
 src/ppp.c                         | 101 +++++++-------
 src/routeradvertisement.c         |  49 ++-----
 src/routing.c                     | 157 ++++++++--------------
 13 files changed, 228 insertions(+), 435 deletions(-)
 create mode 100644 .gitignore
 delete mode 100755 gitlab-ci/compile.sh
 create mode 100755 gitlab-ci/install-dependencies.sh

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..857e06f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+src/*.o
+src/*.so
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 51d6ec4..1515e60 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,15 +1,12 @@
+variables:
+  SOURCE_FOLDER: "src"
+  CPPCHECK_OPTIONS: "--suppress=cert-MSC24-C -DBBF_VENDOR_PREFIX=X_IOPSYS_EU_"
+
 include:
   - project: 'iopsys/gitlab-ci-pipeline'
     file: '/static-code-analysis.yml'
-    ref: '0.32'
+    ref: '1.2'
 
 stages:
     - static_code_analysis
 
-variables:
-  DEBUG: 'TRUE'
-  SOURCE_FOLDER: "./src"
-  FLAWFINDER_OPTIONS: "-m 4 --error-level=5"
-  CPPCHECK_OPTIONS: "--enable=all --error-exitcode=1"
-  COMPILE: "./gitlab-ci/compile.sh"
-
diff --git a/gitlab-ci/compile.sh b/gitlab-ci/compile.sh
deleted file mode 100755
index 06b73c6..0000000
--- a/gitlab-ci/compile.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-echo "Install dependencies"
-ROOT="${PWD}"
-
-source ./gitlab-ci/shared.sh
-
-# install bbfdm
-install_bbfdm
-
-# compile
-echo "build stage"
-cd ${ROOT}/src/
-
-make all
diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh
new file mode 100755
index 0000000..285cc18
--- /dev/null
+++ b/gitlab-ci/install-dependencies.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+echo "install dependencies for tests"
+source ./gitlab-ci/shared.sh
+
+# install bbfdm
+install_bbfdm
diff --git a/gitlab-ci/shared.sh b/gitlab-ci/shared.sh
index f098751..dc60651 100644
--- a/gitlab-ci/shared.sh
+++ b/gitlab-ci/shared.sh
@@ -13,7 +13,7 @@ function exec_cmd()
 
 function install_bbfdm()
 {
-	[ -d "/opt/dev/bbfdm" ] && rm -rf /opt/dev/bbfdm
+	[ -d "/opt/dev/bbfdm" ] && return 0
 
 	if [ -n "${BBFDM_BRANCH}" ]; then
 		exec_cmd git clone -b ${BBFDM_BRANCH} https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm
diff --git a/src/common.c b/src/common.c
index 07dd6bf..83200fb 100644
--- a/src/common.c
+++ b/src/common.c
@@ -48,7 +48,7 @@ void ppp___reset_options(struct uci_section *ppp_s)
 	dmuci_set_value_by_section(ppp_s, "ac", "");
 }
 
-void firewall__create_zone_section(char *s_name)
+void firewall__create_zone_section(const char *s_name)
 {
 	struct uci_section *s = NULL;
 	char *input = NULL;
@@ -74,7 +74,7 @@ void gre___get_tunnel_system_name(struct uci_section *iface_section, char *devic
 {
 	char *proto = NULL;
 
-	if (!iface_section || !device_str_size)
+	if (!iface_section || !device_str || !device_str_size)
 		return;
 
 	dmuci_get_value_by_section_string(iface_section, "proto", &proto);
@@ -135,7 +135,7 @@ bool ip___is_ip_interface_instance_exists(const char *sec_name, const char *devi
 	return false;
 }
 
-void ip___update_child_interfaces(char *device, char *option_name, char *option_value)
+void ip___update_child_interfaces(const char *device, const char *option_name, const char *option_value)
 {
 	struct uci_section *s = NULL;
 
@@ -147,7 +147,7 @@ void ip___update_child_interfaces(char *device, char *option_name, char *option_
 	}
 }
 
-static void ip___Update_IP_Interface_Layer(char *path, char *linker)
+static void ip___Update_IP_Interface_Layer(const char *path, const char *linker)
 {
 	struct uci_section *dmmap_s = NULL;
 
@@ -175,7 +175,7 @@ static void ip___Update_IP_Interface_Layer(char *path, char *linker)
 	}
 }
 
-void ppp___Update_PPP_Interface_Top_Layers(char *path, char *linker)
+void ppp___Update_PPP_Interface_Top_Layers(const char *path, const char *linker)
 {
 	char *p = DM_STRRCHR(path, '.');
 	if (p) *p = 0;
diff --git a/src/common.h b/src/common.h
index c6cc50d..7661902 100644
--- a/src/common.h
+++ b/src/common.h
@@ -18,12 +18,12 @@ void gre___get_tunnel_system_name(struct uci_section *iface_section, char *devic
 
 bool ip___is_gre_protocols(const char *proto);
 bool ip___is_ip_interface_instance_exists(const char *sec_name, const char *device);
-void ip___update_child_interfaces(char *device, char *option_name, char *option_value);
+void ip___update_child_interfaces(const char *device, const char *option_name, const char *option_value);
 
 void ppp___update_sections(struct uci_section *s_from, struct uci_section *s_to);
 void ppp___reset_options(struct uci_section *ppp_s);
-void ppp___Update_PPP_Interface_Top_Layers(char *path, char *linker);
+void ppp___Update_PPP_Interface_Top_Layers(const char *path, const char *linker);
 
-void firewall__create_zone_section(char *s_name);
+void firewall__create_zone_section(const char *s_name);
 
 #endif //__DMLAYER_H__
diff --git a/src/gre.c b/src/gre.c
index 28ce8ba..493e4aa 100644
--- a/src/gre.c
+++ b/src/gre.c
@@ -39,7 +39,7 @@ static char *get_tunnel_dev_proto_family(struct uci_section *tunnel_section)
 }
 
 /* delete sections from both main UCI and dmmap UCI */
-static void delete_all_sections_with_opt_eq(char *package, char *section_type, char *option, char *value)
+static void delete_all_sections_with_opt_eq(const char *package, const char *section_type, const char *option, const char *value)
 {
 	struct uci_section *s = NULL, *stmp = NULL, *dmmap_section = NULL;
 
@@ -58,7 +58,7 @@ static void delete_all_sections_with_opt_eq(char *package, char *section_type, c
 }
 
 /* set value in all sections in main UCI */
-static void set_all_sections_with_opt_eq(char *package, char *section_type, char *option, char *value, char *set_option, char *set_value)
+static void set_all_sections_with_opt_eq(const char *package, const char *section_type, const char *option, const char *value, const char *set_option, const char *set_value)
 {
 	struct uci_section *s = NULL;
 
@@ -77,7 +77,7 @@ static void set_all_sections_with_opt_eq(char *package, char *section_type, char
 }
 
 /* update interface sections corresponding to Tunnel.Interface.LowerLayer, as changed proto leads to changed dev name*/
-static void update_all_interface_upper_layers(char *tunnel_dev_name, bool is_current_ipv6)
+static void update_all_interface_upper_layers(const char *tunnel_dev_name, bool is_current_ipv6)
 {
 	struct uci_section *s = NULL, *s_lower = NULL;
 
@@ -109,7 +109,7 @@ static void update_all_interface_upper_layers(char *tunnel_dev_name, bool is_cur
 	}
 }
 
-static char *get_gre_tunnel_interface_statistics(json_object *json_stats, char *key)
+static char *get_gre_tunnel_interface_statistics(json_object *json_stats, const char *key)
 {
 	char *value = NULL;
 	if (!json_stats || !key) {
@@ -135,7 +135,7 @@ static void empty_all_upper_layers_of_interface(struct uci_section *iface_sectio
 	set_all_sections_with_opt_eq("network", "interface", "device", tunnel_system_name, "device", "");
 }
 
-static void remove_all_interfaces_of_tunnel(char *tunnel_dev_name)
+static void remove_all_interfaces_of_tunnel(const char *tunnel_dev_name)
 {
 	if (!tunnel_dev_name || !DM_STRLEN(tunnel_dev_name)) {
 		return;
@@ -177,19 +177,6 @@ static void remove_tunnel(struct uci_section *tunnel_section, struct uci_section
 	dmuci_delete_by_section(tunnel_section, NULL, NULL);
 }
 
-static void remove_all_tunnels(void)
-{
-	struct uci_section *s = NULL, *stmp = NULL;
-
-	uci_foreach_option_eq_safe("network", "device", "mode", "greip", stmp, s) {
-		remove_tunnel(s, NULL);
-	}
-
-	s = NULL, stmp = NULL;
-	uci_foreach_option_eq_safe("network", "device", "mode", "greip6", stmp, s) {
-		remove_tunnel(s, NULL);
-	}
-}
 /*************************************************************
 * ENTRY METHOD
 *************************************************************/
@@ -279,14 +266,7 @@ static int addObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *
 
 static int delObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	switch (del_action) {
-		case DEL_INST:
-			remove_tunnel(((struct dm_data *)data)->config_section, ((struct dm_data *)data)->dmmap_section);
-			break;
-		case DEL_ALL:
-			remove_all_tunnels();
-			break;
-	}
+	remove_tunnel(((struct dm_data *)data)->config_section, ((struct dm_data *)data)->dmmap_section);
 	return 0;
 }
 
@@ -326,22 +306,13 @@ static int addObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *dat
 
 static int delObjGRETunnelInterface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	char *tunnel_dev_name = NULL;
+	empty_all_upper_layers_of_interface(((struct dm_data *)data)->config_section);
 
-	switch (del_action) {
-		case DEL_INST:
-			empty_all_upper_layers_of_interface(((struct dm_data *)data)->config_section);
-			// Remove interface section in network UCI
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			// Remove interface section in dmmap_gre
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
+	// Remove interface section in network UCI
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
 
-			break;
-		case DEL_ALL:
-			tunnel_dev_name = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "name", "");
-			remove_all_interfaces_of_tunnel(tunnel_dev_name);
-			break;
-	}
+	// Remove interface section in dmmap_gre
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -361,9 +332,9 @@ static int get_GRETunnel_Enable(char *refparam, struct dmctx *ctx, void *data, c
 	char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
 
 	if (!DM_STRCMP(disabled, "0") || !DM_STRCMP(disabled, "false"))
-		*value = "1";
+		*value = dmstrdup("1");
 	else
-		*value = "0";
+		*value = dmstrdup("0");
 
 	return 0;
 }
@@ -395,9 +366,9 @@ static int get_GRETunnel_Status(char *refparam, struct dmctx *ctx, void *data, c
 	char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
 
 	if (!DM_STRCMP(disabled, "0") || !DM_STRCMP(disabled, "false")) {
-		*value = "Enabled";
+		*value = dmstrdup("Enabled");
 	} else {
-		*value = "Disabled";
+		*value = dmstrdup("Disabled");
 	}
 
 	return 0;
@@ -421,9 +392,9 @@ static int get_GRETunnel_DeliveryHeaderProtocol(char *refparam, struct dmctx *ct
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "mode", &proto);
 
 	if (proto && !DM_LSTRCMP(proto, "greip6")) {
-		*value = "IPv6";
+		*value = dmstrdup("IPv6");
 	} else {
-		*value = "IPv4";
+		*value = dmstrdup("IPv4");
 	}
 	return 0;
 }
@@ -546,9 +517,9 @@ static int get_GRETunnelInterface_Enable(char *refparam, struct dmctx *ctx, void
 	char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
 
 	if (!DM_STRCMP(disabled, "0") || !DM_STRCMP(disabled, "false")) {
-		*value = "1";
+		*value = dmstrdup("1");
 	} else {
-		*value = "0";
+		*value = dmstrdup("0");
 	}
 
 	return 0;
@@ -579,7 +550,7 @@ static int get_GRETunnelInterface_Status(char *refparam, struct dmctx *ctx, void
 	char *disabled = dmuci_get_value_by_section_fallback_def(((struct dm_data *)data)->config_section, "disabled", "0");
 
 	if (!DM_STRCMP(disabled, "1") || !DM_STRCMP(disabled, "true")) {
-		*value = "Down";
+		*value = dmstrdup("Down");
 		return 0;
 	}
 
@@ -612,7 +583,7 @@ static int get_GRETunnelInterface_LastChange(char *refparam, struct dmctx *ctx,
 
 	char *if_name = section_name(((struct dm_data *)data)->config_section);
 	dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-	DM_ASSERT(res, *value = "0");
+	DM_ASSERT(res, *value = dmstrdup("0"));
 	*value = dmjson_get_value(res, 1, "uptime");
 	return 0;
 }
@@ -670,9 +641,9 @@ static int get_GRETunnelInterface_UseChecksum(char *refparam, struct dmctx *ctx,
 	dmuci_get_value_by_section_string(iface_section, "ocsum", &ocsum);
 	if (ocsum) {
 		if (!DM_STRCMP(ocsum, "1") || !DM_STRCMP(ocsum, "true"))
-			*value = "1";
+			*value = dmstrdup("1");
 		else
-			*value = "0";
+			*value = dmstrdup("0");
 	}
 
 	return 0;
@@ -704,9 +675,9 @@ static int get_GRETunnelInterface_UseSequenceNumber(char *refparam, struct dmctx
 	dmuci_get_value_by_section_string(iface_section, "oseqno", &oseqno);
 	if (oseqno) {
 		if (!DM_STRCMP(oseqno, "1") || !DM_STRCMP(oseqno, "true"))
-			*value = "1";
+			*value = dmstrdup("1");
 		else
-			*value = "0";
+			*value = dmstrdup("0");
 	}
 
 	return 0;
diff --git a/src/interfacestack.c b/src/interfacestack.c
index ff633dd..d0d238c 100644
--- a/src/interfacestack.c
+++ b/src/interfacestack.c
@@ -21,7 +21,7 @@ struct interfacestack_data
 /*************************************************************
 * COMMON FUNCTIONS
 **************************************************************/
-static struct uci_section *get_bridge_management_port_section(char *instance)
+static struct uci_section *get_bridge_management_port_section(const char *instance)
 {
 	struct uci_section *s = NULL;
 	char *management = NULL;
@@ -39,7 +39,7 @@ static struct uci_section *get_bridge_management_port_section(char *instance)
 static char *get_lower_alias_value(const char *path)
 {
 	struct uci_section *s = NULL;
-	char *alias_value = "";
+	char *alias_value = NULL;
 
 	if (DM_STRLEN(path) == 0)
 		return "";
@@ -105,12 +105,12 @@ static char *get_lower_alias_value(const char *path)
 		dmuci_get_value_by_section_string(s, "mac_vlan_alias", &alias_value);
 	}
 
-	return alias_value;
+	return alias_value ? alias_value : "";
 }
 
 static int create_interface_stack_instance(struct dmctx *dmctx, DMNODE *parent_node,
 		struct interfacestack_data *data, struct uci_section *s,
-		char *path, char *inst_number, char *inst_alias, int *curr_inst)
+		const char *path, const char *inst_number, const char *inst_alias, int *curr_inst)
 {
 	struct dm_data curr_data = {0};
 	char *instance = NULL, *inst = NULL;
diff --git a/src/ip.c b/src/ip.c
index 00004d9..060b7e8 100644
--- a/src/ip.c
+++ b/src/ip.c
@@ -16,11 +16,11 @@
 #define STATUS_SIZE 16
 
 typedef struct {
-	char local_ip[INET6_ADDRSTRLEN];
 	uint16_t local_port;
-	char remote_ip[INET6_ADDRSTRLEN];
 	uint16_t remote_port;
 	unsigned int state;
+	char local_ip[INET6_ADDRSTRLEN];
+	char remote_ip[INET6_ADDRSTRLEN];
 } ActivePort;
 
 /*************************************************************
@@ -38,7 +38,7 @@ static void format_ipv6_address(const char *hex_str_ip, char *ipv6_addr)
 	inet_ntop(AF_INET6, &addr, ipv6_addr, INET6_ADDRSTRLEN);
 }
 
-static void parse_tcp_line(const char* line, int is_ipv6, ActivePort* port)
+static void parse_tcp_line(const char *line, int is_ipv6, ActivePort *port)
 {
 	unsigned int local_port, remote_port;
 	unsigned int state;
@@ -124,7 +124,7 @@ static int get_sysctl_disable_ipv6_per_device(const char *device, char **value)
 	char file[256];
 	char val[32] = {0};
 
-	*value = "0";
+	*value = dmstrdup("0");
 
 	if (DM_STRLEN(device) == 0)
 		return -1;
@@ -186,7 +186,7 @@ static int set_sysctl_disable_ipv6_per_device(const char *device, bool value)
 	return 0;
 }
 
-static int get_ip_iface_sysfs(const struct uci_section *data, const char *name, char **value)
+static int get_ip_iface_sysfs(void *data, const char *name, char **value)
 {
 	return get_net_iface_sysfs(section_name(((struct dm_data *)data)->config_section), name, value);
 }
@@ -207,7 +207,7 @@ static bool is_main_interface_sec(void *data)
 	return !DM_STRCMP(parent_section, current_section);
 }
 
-static void add_network_to_firewall_zone_network_list(char *zone_name, char *interface_name)
+static void add_network_to_firewall_zone_network_list(const char *zone_name, const char *interface_name)
 {
 	struct uci_section *s = NULL;
 
@@ -217,7 +217,7 @@ static void add_network_to_firewall_zone_network_list(char *zone_name, char *int
 	}
 }
 
-static bool proc_intf6_line_exists(char *parent_section, char *address)
+static bool proc_intf6_line_exists(const char *parent_section, const char *address)
 {
 	struct uci_section *s = NULL;
 
@@ -234,7 +234,7 @@ static bool proc_intf6_line_exists(char *parent_section, char *address)
 	return false;
 }
 
-static void dmmap_synchronize_ipv6_address_link_local(char *parent_section)
+static void dmmap_synchronize_ipv6_address_link_local(const char *parent_section)
 {
 	struct uci_section *s = NULL, *stmp = NULL;
 	char buf[512] = {0}, ipstr[64] = {0};
@@ -296,7 +296,7 @@ static void dmmap_synchronize_ipv6_address_link_local(char *parent_section)
 	fclose(fp);
 }
 
-static struct uci_section *check_dmmap_network_interface_ipv4(char *dmmap_file_name, char *dmmap_sec_name, char *parent_section, char *section_name)
+static struct uci_section *check_dmmap_network_interface_ipv4(const char *dmmap_file_name, const char *dmmap_sec_name, const char *parent_section, const char *section_name)
 {
 	struct uci_section *dmmap_section = NULL;
 	char *sec_name;
@@ -310,7 +310,8 @@ static struct uci_section *check_dmmap_network_interface_ipv4(char *dmmap_file_n
 	return NULL;
 }
 
-static struct uci_section *add_dmmap_network_interface_ipv4(char *dmmap_file_name, char *dmmap_sec_name, char *parent_section, char *section_name, char *addr, char *mask, const char *disabled)
+static struct uci_section *add_dmmap_network_interface_ipv4(const char *dmmap_file_name, const char *dmmap_sec_name, const char *parent_section,
+		const char *section_name, const char *addr, const char *mask, const char *disabled)
 {
 	struct uci_section *dmmap_section = NULL;
 
@@ -324,7 +325,8 @@ static struct uci_section *add_dmmap_network_interface_ipv4(char *dmmap_file_nam
 	return dmmap_section;
 }
 
-static struct uci_section *update_dmmap_network_interface(char *dmmap_file_name, char *dmmap_sec_name, char *parent_section, char *section_name, char *option, char *value, bool assign)
+static struct uci_section *update_dmmap_network_interface(const char *dmmap_file_name, const char *dmmap_sec_name,
+		const char *parent_section, const char *section_name, const char *option, const char *value, bool assign)
 {
 	struct uci_section *dmmap_section = NULL;
 	char *sec_name, *opt_value;
@@ -578,55 +580,24 @@ static void delete_ip_intertace_instance(struct uci_section *s)
 	}
 }
 
-static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, char *dmmap_file_name, char *section_type, char *option_name)
+static int delObjIPInterfaceIPv6(void *data, unsigned char del_action, const char *option_name)
 {
-	struct uci_section *s = NULL, *stmp = NULL, *dmmap_s = NULL;
-	char *proto = NULL, *assign = NULL, *link_local = NULL, *device = NULL, *iface_dev = NULL;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "assign", &assign);
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "link_local", &link_local);
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
+	char *proto = NULL, *assign = NULL, *link_local = NULL;
 
-			if ((DM_LSTRCMP(assign, "1") == 0) || (DM_LSTRCMP(link_local, "1") == 0) || DM_LSTRCMP(proto, "static") != 0)
-				return FAULT_9001;
-
-			if (!is_main_interface_sec(data)) {
-				dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			} else {
-				dmuci_set_value_by_section(((struct dm_data *)data)->config_section, option_name, "");
-			}
-
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
-			if (DM_LSTRCMP(proto, "static") != 0)
-				return FAULT_9001;
-
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "device", &iface_dev);
-
-			uci_foreach_sections_safe("network", "interface", stmp, s) {
-
-				dmuci_get_value_by_section_string(s, "device", &device);
-
-				if (strcmp(section_name(s), section_name(((struct dm_data *)data)->config_section)) == 0) {
-					dmuci_set_value_by_section(s, option_name, "");
+	dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "assign", &assign);
+	dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "link_local", &link_local);
+	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
 
-					get_dmmap_section_of_config_section(dmmap_file_name, section_type, section_name(s), &dmmap_s);
-					dmuci_delete_by_section(dmmap_s, NULL, NULL);
-				} else if (DM_STRCMP(device, iface_dev) == 0) {
-					get_dmmap_section_of_config_section(dmmap_file_name, section_type, section_name(s), &dmmap_s);
-					dmuci_delete_by_section(dmmap_s, NULL, NULL);
+	if ((DM_LSTRCMP(assign, "1") == 0) || (DM_LSTRCMP(link_local, "1") == 0) || DM_LSTRCMP(proto, "static") != 0)
+		return FAULT_9001;
 
-					dmuci_delete_by_section(s, NULL, NULL);
-				} else {
-					continue;
-				}
-			}
-			break;
+	if (!is_main_interface_sec(data)) {
+		dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	} else {
+		dmuci_set_value_by_section(((struct dm_data *)data)->config_section, option_name, "");
 	}
+
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -944,29 +915,7 @@ static int addObjIPInterface(char *refparam, struct dmctx *ctx, void *data, char
 
 static int delObjIPInterface(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:
-			delete_ip_intertace_instance(((struct dm_data *)data)->config_section);
-			break;
-		case DEL_ALL:
-			uci_foreach_sections_safe("network", "interface", stmp, s) {
-				char *proto, *device;
-				dmuci_get_value_by_section_string(s, "proto", &proto);
-				dmuci_get_value_by_section_string(s, "device", &device);
-
-				if (strcmp(section_name(s), "loopback") == 0 ||
-					DM_STRLEN(proto) == 0 ||
-					ip___is_gre_protocols(proto) ||
-					DM_STRCHR(device, '@') ||
-					ip___is_ip_interface_instance_exists(section_name(s), device))
-					continue;
-
-				delete_ip_intertace_instance(s);
-			}
-			break;
-	}
+	delete_ip_intertace_instance(((struct dm_data *)data)->config_section);
 	return 0;
 }
 
@@ -999,52 +948,20 @@ static int addObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void
 
 static int delObjIPInterfaceIPv4Address(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *s = NULL, *stmp = NULL, *dmmap_s = NULL;
-	char *proto, *device, *iface_dev;
-
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
-			if (DM_LSTRCMP(proto, "static") != 0)
-				return FAULT_9001;
-
-			if (!is_main_interface_sec(data)) {
-				dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			} else {
-				dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ipaddr", "");
-				dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "netmask", "");
-			}
-
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
-			if (DM_LSTRCMP(proto, "static") != 0)
-				return FAULT_9001;
-
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "device", &iface_dev);
-
-			uci_foreach_sections_safe("network", "interface", stmp, s) {
-
-				dmuci_get_value_by_section_string(s, "device", &device);
-
-				if (strcmp(section_name(s), section_name(((struct dm_data *)data)->config_section)) == 0) {
-					dmuci_set_value_by_section(s, "ipaddr", "");
-					dmuci_set_value_by_section(s, "netmask", "");
+	char *proto = NULL;
 
-					get_dmmap_section_of_config_section("dmmap_network_ipv4", "intf_ipv4", section_name(s), &dmmap_s);
-					dmuci_delete_by_section(dmmap_s, NULL, NULL);
-				} else if (DM_STRCMP(device, iface_dev) == 0) {
-					get_dmmap_section_of_config_section("dmmap_network_ipv4", "intf_ipv4", section_name(s), &dmmap_s);
-					dmuci_delete_by_section(dmmap_s, NULL, NULL);
+	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
+	if (DM_LSTRCMP(proto, "static") != 0)
+		return FAULT_9001;
 
-					dmuci_delete_by_section(s, NULL, NULL);
-				} else {
-					continue;
-				}
-			}
-			break;
+	if (!is_main_interface_sec(data)) {
+		dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	} else {
+		dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "ipaddr", "");
+		dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "netmask", "");
 	}
+
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -1077,7 +994,7 @@ static int addObjIPInterfaceIPv6Address(char *refparam, struct dmctx *ctx, void
 
 static int delObjIPInterfaceIPv6Address(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	return delObjIPInterfaceIPv6(data, del_action, "dmmap_network_ipv6", "intf_ipv6", "ip6addr");
+	return delObjIPInterfaceIPv6(data, del_action, "ip6addr");
 }
 
 static int addObjIPInterfaceIPv6Prefix(char *refparam, struct dmctx *ctx, void *data, char **instance)
@@ -1109,7 +1026,7 @@ static int addObjIPInterfaceIPv6Prefix(char *refparam, struct dmctx *ctx, void *
 
 static int delObjIPInterfaceIPv6Prefix(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	return delObjIPInterfaceIPv6(data, del_action, "dmmap_network_ipv6_prefix", "intf_ipv6_prefix", "ip6prefix");
+	return delObjIPInterfaceIPv6(data, del_action, "ip6prefix");
 }
 
 /*************************************************************
@@ -1123,7 +1040,7 @@ static int get_IP_IPv4Capable(char *refparam, struct dmctx *ctx, void *data, cha
 
 static int get_IP_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
 	return 0;
 }
 
@@ -1143,7 +1060,7 @@ static int set_IP_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char
 
 static int get_IP_IPv4Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "Enabled";
+	*value = dmstrdup("Enabled");
 	return 0;
 }
 
@@ -1227,7 +1144,7 @@ static int get_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data,
 	struct uci_section *s = NULL;
 	char *device = NULL;
 
-	*value = "0";
+	*value = dmstrdup("0");
 
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "device", &device);
 
@@ -1237,7 +1154,7 @@ static int get_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data,
 		dmuci_get_value_by_section_string(s, "disabled", &disabled);
 
 		if (DM_STRCMP(disabled, "1") != 0) {
-			*value = "1";
+			*value = dmstrdup("1");
 			break;
 		}
 	}
@@ -1266,7 +1183,7 @@ static int set_IPInterface_Enable(char *refparam, struct dmctx *ctx, void *data,
 
 static int get_IPInterface_IPv4Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
 	return 0;
 }
 
@@ -1366,7 +1283,7 @@ static int get_IPInterface_LastChange(char *refparam, struct dmctx *ctx, void *d
 
 	char *if_name = section_name(((struct dm_data *)data)->config_section);
 	dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-	DM_ASSERT(res, *value = "0");
+	DM_ASSERT(res, *value = dmstrdup("0"));
 	*value = dmjson_get_value(res, 1, "uptime");
 	return 0;
 }
@@ -1406,10 +1323,9 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
 
 static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
 {
-	char eth_mac_vlan[] = "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN";
 	char *allowed_objects[] = {
 			"Device.PPP.Interface.",
-			eth_mac_vlan,
+			"Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN",
 			"Device.Ethernet.VLANTermination.",
 			"Device.Ethernet.Link.",
 			"Device.GRE.Tunnel.*.Interface.",
@@ -1549,7 +1465,7 @@ static int set_IPInterface_Router(char *refparam, struct dmctx *ctx, void *data,
 
 static int get_IPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -1611,13 +1527,13 @@ static int set_IPInterface_MaxMTUSize(char *refparam, struct dmctx *ctx, void *d
 
 static int get_IPInterface_Type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "Normal";
+	*value = dmstrdup("Normal");
 	return 0;
 }
 
 static int get_IPInterface_Loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -1802,11 +1718,11 @@ static int get_IPInterfaceIPv4Address_AddressingType(char *refparam, struct dmct
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
 
 	if (DM_LSTRCMP(proto, "static") == 0)
-		*value = "Static";
+		*value = dmstrdup("Static");
 	else if (DM_LSTRNCMP(proto, "ppp", 3) == 0)
-		*value = "IPCP";
+		*value = dmstrdup("IPCP");
 	else
-		*value = "DHCP";
+		*value = dmstrdup("DHCP");
 	return 0;
 }
 
@@ -1819,7 +1735,7 @@ static int get_IPInterfaceIPv6Address_Enable(char *refparam, struct dmctx *ctx,
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "link_local", &link_local);
 
 	if ((DM_LSTRCMP(assign, "1") == 0) || (DM_LSTRCMP(link_local, "1") == 0)) {
-		*value = "1";
+		*value = dmstrdup("1");
 	} else {
 		char *disabled = NULL;
 
@@ -1931,7 +1847,7 @@ static int get_IPInterfaceIPv6Address_Origin(char *refparam, struct dmctx *ctx,
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "link_local", &link_local);
 
 	if ((DM_LSTRCMP(assign, "1") == 0) || (DM_LSTRCMP(link_local, "1") == 0)) {
-		*value = "AutoConfigured";
+		*value = dmstrdup("AutoConfigured");
 	} else {
 		char *proto;
 		dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
@@ -2143,7 +2059,7 @@ static int get_IPInterfaceIPv6Prefix_Origin(char *refparam, struct dmctx *ctx, v
 
 	dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "assign", &assign);
 	if (DM_LSTRCMP(assign, "1") == 0) {
-		*value = "AutoConfigured";
+		*value = dmstrdup("AutoConfigured");
 	} else {
 		char *proto = NULL;
 		dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "proto", &proto);
@@ -2294,13 +2210,13 @@ static int get_IPInterfaceStats_ErrorsReceived(char *refparam, struct dmctx *ctx
 
 static int get_IPInterfaceStats_UnicastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
 static int get_IPInterfaceStats_UnicastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -2318,7 +2234,7 @@ static int get_IPInterfaceStats_DiscardPacketsReceived(char *refparam, struct dm
 
 static int get_IPInterfaceStats_MulticastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -2330,19 +2246,19 @@ static int get_IPInterfaceStats_MulticastPacketsReceived(char *refparam, struct
 
 static int get_IPInterfaceStats_BroadcastPacketsSent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
 static int get_IPInterfaceStats_BroadcastPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
 static int get_IPInterfaceStats_UnknownProtoPacketsReceived(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -2376,13 +2292,13 @@ static int get_IP_ActivePort_Status(char *refparam, struct dmctx *ctx, void *dat
 
 	switch (state) {
 		case 1:
-			*value = "ESTABLISHED";
+			*value = dmstrdup("ESTABLISHED");
 			break;
 		case 10:
-			*value = "LISTEN";
+			*value = dmstrdup("LISTEN");
 			break;
 		default:
-			*value = "";
+			*value = dmstrdup("");
 			break;
 	}
 
diff --git a/src/ppp.c b/src/ppp.c
index daab521..3293b71 100644
--- a/src/ppp.c
+++ b/src/ppp.c
@@ -18,7 +18,7 @@
 /*************************************************************
 * COMMON FUNCTIONS
 **************************************************************/
-static bool is_ppp_section_exist(char *sec_name)
+static bool is_ppp_section_exist(const char *sec_name)
 {
 	struct uci_section *s = NULL;
 
@@ -128,22 +128,16 @@ static int add_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char
 
 static int delete_ppp_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	switch (del_action) {
-		case DEL_INST:
-			if (((struct dm_data *)data)->config_section) {
-				dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", "none");
-				ppp___reset_options(((struct dm_data *)data)->config_section);
-			}
+	if (((struct dm_data *)data)->config_section) {
+		dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "proto", "none");
+		ppp___reset_options(((struct dm_data *)data)->config_section);
+	}
 
-			// Update PPP Interface Top Layers
-			ppp___Update_PPP_Interface_Top_Layers(refparam, "");
+	// Update PPP Interface Top Layers
+	ppp___Update_PPP_Interface_Top_Layers(refparam, "");
 
-			// Remove dmmap section
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			break;
-	}
+	// Remove dmmap section
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -208,17 +202,17 @@ static int get_PPPInterface_LastChange(char *refparam, struct dmctx *ctx, void *
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "0");
+		DM_ASSERT(res, *value = dmstrdup("0"));
 		*value = dmjson_get_value(res, 1, "uptime");
 	} else {
-		*value = "0";
+		*value = dmstrdup("0");
 	}
 	return 0;
 }
 
 static int get_PPPInterface_Reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "false";
+	*value = dmstrdup("false");
 	return 0;
 }
 
@@ -256,7 +250,7 @@ static int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *i
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "Unconfigured");
+		DM_ASSERT(res, *value = dmstrdup("Unconfigured"));
 		jobj = dmjson_get_obj(res, 1, "up");
 		if (jobj) {
 			status = dmjson_get_value(res, 1, "up");
@@ -268,13 +262,13 @@ static int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *i
 			}
 		}
 		if (uptime && DM_STRTOL(uptime) > 0)
-			*value = "Connected";
+			*value = dmstrdup("Connected");
 		else if (pending && bpend)
-			*value = "Pending Disconnect";
+			*value = dmstrdup("Pending Disconnect");
 		else
-			*value = "Disconnected";
+			*value = dmstrdup("Disconnected");
 	} else {
-		*value = "Unconfigured";
+		*value = dmstrdup("Unconfigured");
 	}
 	return 0;
 }
@@ -288,40 +282,40 @@ static int get_PPPInterface_LastConnectionError(char *refparam, struct dmctx *ct
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "ERROR_NONE");
+		DM_ASSERT(res, *value = dmstrdup("ERROR_NONE"));
 		char *status = dmjson_get_value(res, 2, "data", "lastconnectionerror");
 
 		switch (DM_STRTOL(status)) {
 			case 0:
-				*value = "ERROR_NONE";
+				*value = dmstrdup("ERROR_NONE");
 				break;
 			case 1: case 10: case 13: case 14: case 17: case 18: case 20: case 22:
-				*value = "ERROR_UNKNOWN";
+				*value = dmstrdup("ERROR_UNKNOWN");
 				break;
 			case 2: case 3: case 4: case 6: case 7: case 9:
-				*value = "ERROR_COMMAND_ABORTED";
+				*value = dmstrdup("ERROR_COMMAND_ABORTED");
 				break;
 			case 5: case 15:
-				*value = "ERROR_USER_DISCONNECT";
+				*value = dmstrdup("ERROR_USER_DISCONNECT");
 				break;
 			case 8:
-				*value = "ERROR_IP_CONFIGURATION";
+				*value = dmstrdup("ERROR_IP_CONFIGURATION");
 				break;
 			case 11: case 19: case 21:
-				*value = "ERROR_AUTHENTICATION_FAILURE";
+				*value = dmstrdup("ERROR_AUTHENTICATION_FAILURE");
 				break;
 			case 12:
-				*value = "ERROR_IDLE_DISCONNECT";
+				*value = dmstrdup("ERROR_IDLE_DISCONNECT");
 				break;
 			case 16:
-				*value = "ERROR_ISP_DISCONNECT";
+				*value = dmstrdup("ERROR_ISP_DISCONNECT");
 				break;
 			default:
-				*value = "ERROR_NONE";
+				*value = dmstrdup("ERROR_NONE");
 				break;
 			}
 	} else {
-		*value = "ERROR_NONE";
+		*value = dmstrdup("ERROR_NONE");
 	}
 	return 0;
 }
@@ -388,7 +382,7 @@ static int get_PPPInterface_MaxMRUSize(char *refparam, struct dmctx *ctx, void *
 
 	dmuci_get_value_by_section_string(ppp->config_section ? ppp->config_section : ppp->dmmap_section, "pppd_options", &pppd_opt);
 	if (pppd_opt && *pppd_opt == '\0') {
-		*value = "1500";
+		*value = dmstrdup("1500");
 		return 0;
 	}
 
@@ -408,7 +402,7 @@ static int get_PPPInterface_MaxMRUSize(char *refparam, struct dmctx *ctx, void *
 	}
 
 	if (*value && (*value)[0] == '\0') {
-		*value = "1500";
+		*value = dmstrdup("1500");
 	}
 
 	return 0;
@@ -499,7 +493,7 @@ static int get_PPPInterface_LCPEcho(char *refparam, struct dmctx *ctx, void *dat
 
 		dmuci_get_value_by_section_string(ppp_s, "keepalive", &lcp_echo);
 		if (lcp_echo && *lcp_echo == '\0') {
-			*value = "1";
+			*value = dmstrdup("1");
 			return 0;
 		}
 
@@ -523,7 +517,7 @@ static int get_PPPInterface_LCPEchoRetry(char *refparam, struct dmctx *ctx, void
 
 		dmuci_get_value_by_section_string(ppp_s, "keepalive", &lcp_retry);
 		if (!lcp_retry || *lcp_retry == '\0') {
-			*value = "5";
+			*value = dmstrdup("5");
 		} else {
 			token = DM_STRCHR(lcp_retry , ' ');
 			if (NULL != token) {
@@ -537,7 +531,7 @@ static int get_PPPInterface_LCPEchoRetry(char *refparam, struct dmctx *ctx, void
 	return 0;
 }
 
-static int configure_supported_ncp_options(struct uci_section *ss, char *value, char *option)
+static int configure_supported_ncp_options(struct uci_section *ss, const char *value, const char *option)
 {
 	char *proto, *pppd_opt = NULL;
 	char list_options[1024] = {0};
@@ -690,7 +684,7 @@ static int get_PPPInterfacePPPoE_SessionID(char *refparam, struct dmctx *ctx, vo
 {
 	FILE *fp = fopen("/proc/net/pppoe" ,"r");
 	if (NULL == fp) {
-		*value  = "1";
+		*value = dmstrdup("1");
 	} else {
 		char session_id[20] = {0};
 		char path[1024] = {0};
@@ -704,7 +698,7 @@ static int get_PPPInterfacePPPoE_SessionID(char *refparam, struct dmctx *ctx, vo
 				memset(session_id, '\0', sizeof(session_id));
 				snprintf(session_id, sizeof(session_id), "%d", number);
 				if ('\0' == session_id[0]) {
-					*value = "1";
+					*value = dmstrdup("1");
 				} else {
 					*value = dmstrdup(session_id);
 				}
@@ -725,7 +719,7 @@ static int get_PPPInterfaceIPCP_LocalIPAddress(char *refparam, struct dmctx *ctx
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "");
+		DM_ASSERT(res, *value = dmstrdup(""));
 		json_object *ipv4_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
 		*value = dmjson_get_value(ipv4_obj, 1, "address");
 	}
@@ -741,7 +735,7 @@ static int get_PPPInterfaceIPCP_RemoteIPAddress(char *refparam, struct dmctx *ct
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "");
+		DM_ASSERT(res, *value = dmstrdup(""));
 		json_object *ipv4_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
 		*value = dmjson_get_value(ipv4_obj, 1, "ptpaddress");
 		if (**value == '\0') {
@@ -761,7 +755,7 @@ static int get_PPPInterfaceIPCP_DNSServers(char *refparam, struct dmctx *ctx, vo
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "");
+		DM_ASSERT(res, *value = dmstrdup(""));
 		*value = dmjson_get_value_array_all(res, ",", 1, "dns-server");
 	}
 	return 0;
@@ -776,7 +770,7 @@ static int get_PPPInterfaceIPv6CP_LocalInterfaceIdentifier(char *refparam, struc
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "");
+		DM_ASSERT(res, *value = dmstrdup(""));
 		json_object *ipv4_obj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
 		*value = dmjson_get_value(ipv4_obj, 1, "address");
 	}
@@ -792,7 +786,7 @@ static int get_PPPInterfaceIPv6CP_RemoteInterfaceIdentifier(char *refparam, stru
 
 		char *if_name = section_name(ppp_s);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-		DM_ASSERT(res, *value = "");
+		DM_ASSERT(res, *value = dmstrdup(""));
 		*value = dmjson_get_value(res, 2, "data", "llremote");
 	}
 	return 0;
@@ -802,7 +796,7 @@ static int ppp_read_sysfs(void *data, const char *name, char **value)
 {
 	struct uci_section *ppp_s = ((struct dm_data *)data)->config_section;
 
-	*value = "0";
+	*value = dmstrdup("0");
 
 	if (ppp_s) {
 		char *proto;
@@ -824,7 +818,7 @@ static int get_PPPInterfaceStats_MulticastPacketsSent(char *refparam, struct dmc
  * The stats pertaining to Multicast recv/xmit are irrelevant to ppp interfaces.
  * Hence the value of this stats marked ZERO.
  */
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -835,7 +829,7 @@ static int get_PPPInterfaceStats_BroadcastPacketsSent(char *refparam, struct dmc
  * The stats pertaining to broadcast recv/xmit are irrelevant to ppp interfaces.
  * Hence the value of this stats marked ZERO.
  */
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -846,7 +840,7 @@ static int get_PPPInterfaceStats_BroadcastPacketsReceived(char *refparam, struct
  * The stats pertaining to broadcast recv/xmit are irrelevant to ppp interfaces.
  * Hence the value of this stats marked ZERO.
  */
-	*value = "0";
+	*value = dmstrdup("0");
 	return 0;
 }
 
@@ -863,7 +857,7 @@ static int get_PPPInterfaceStats_MulticastPacketsReceived(char *refparam, struct
  * The stats pertaining to Multicast recv/xmit are irrelevant for ppp interfaces.
  * Hence the value of this stats marked ZERO.
  */
-	*value = "0";
+	*value = dmstrdup("0");
         return 0;
 }
 
@@ -978,9 +972,8 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch
 static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
 {
 	struct dm_data *ppp = (struct dm_data *)data;
-	char eth_mac_vlan[] = "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN";
 	char *allowed_objects[] = {
-			eth_mac_vlan,
+			"Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN",
 			"Device.Ethernet.VLANTermination.",
 			"Device.Ethernet.Link.",
 			NULL};
@@ -1028,7 +1021,7 @@ static int get_PPP_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, v
 
 static int get_PPP_SupportedNCPs(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "IPCP,IPv6CP";
+	*value = dmstrdup("IPCP,IPv6CP");
 	return 0;
 }
 
diff --git a/src/routeradvertisement.c b/src/routeradvertisement.c
index dc17da1..92c2925 100644
--- a/src/routeradvertisement.c
+++ b/src/routeradvertisement.c
@@ -28,7 +28,7 @@ char *get_dhcp_dnsmasq_section_name(void)
 	return "";
 }
 
-static int radv_get_option_value(struct uci_section *s, char *option_list, const char *option_value, char **value)
+static int radv_get_option_value(struct uci_section *s, const char *option_list, const char *option_value, char **value)
 {
 	struct uci_list *uci_list = NULL;
 
@@ -37,17 +37,17 @@ static int radv_get_option_value(struct uci_section *s, char *option_list, const
 	return 0;
 }
 
-static int radv_set_option_value(struct uci_section *s, char *option_list, const char *option_value, bool b)
+static int radv_set_option_value(struct uci_section *s, const char *option_list, const char *option_value, bool b)
 {
 	struct uci_list *uci_list = NULL;
 
 	dmuci_get_value_by_section_list(s, option_list, &uci_list);
 	if (b) {
 		if (!value_exists_in_uci_list(uci_list, option_value))
-			dmuci_add_list_value_by_section(s, option_list, (char *)option_value);
+			dmuci_add_list_value_by_section(s, option_list, option_value);
 	} else {
 		if (value_exists_in_uci_list(uci_list, option_value))
-			dmuci_del_list_value_by_section(s, option_list, (char *)option_value);
+			dmuci_del_list_value_by_section(s, option_list, option_value);
 	}
 	return 0;
 }
@@ -140,24 +140,8 @@ static int addObjRouterAdvertisementInterfaceSetting(char *refparam, struct dmct
 
 static int delObjRouterAdvertisementInterfaceSetting(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("dhcp", "dhcp", stmp, s) {
-				struct uci_section *dmmap_section = NULL;
-
-				get_dmmap_section_of_config_section("dmmap_radv", "dhcp", section_name(s), &dmmap_section);
-				dmuci_delete_by_section(dmmap_section, NULL, NULL);
-
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			break;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -174,24 +158,13 @@ static int addObjRouterAdvertisementInterfaceSettingOption(char *refparam, struc
 
 static int delObjRouterAdvertisementInterfaceSettingOption(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *s = NULL, *stmp = NULL;
 	struct uci_list *dns_list = NULL;
 
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dns", &dns_list);
-			if (value_exists_in_uci_list(dns_list, ((struct dm_data *)data)->additional_data))
-				dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dns", ((struct dm_data *)data)->additional_data);
+	dmuci_get_value_by_section_list(((struct dm_data *)data)->config_section, "dns", &dns_list);
+	if (value_exists_in_uci_list(dns_list, ((struct dm_data *)data)->additional_data))
+		dmuci_del_list_value_by_section(((struct dm_data *)data)->config_section, "dns", ((struct dm_data *)data)->additional_data);
 
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			dmuci_set_value_by_section(((struct dm_data *)data)->config_section, "dns", "");
-			uci_path_foreach_sections_safe(bbfdm, "dmmap_radv", "radv_option", stmp, s) {
-				dmuci_delete_by_section(s, NULL, NULL);
-			}
-			break;
-	}
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -635,7 +608,7 @@ static int set_RouterAdvertisementInterfaceSettingOption_Alias(char *refparam, s
 
 static int get_RouterAdvertisementInterfaceSettingOption_Tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "23";
+	*value = dmstrdup("23");
 	return 0;
 }
 
diff --git a/src/routing.c b/src/routing.c
index 548664c..7757ed6 100644
--- a/src/routing.c
+++ b/src/routing.c
@@ -88,7 +88,7 @@ static bool is_route6_in_config(struct route6_args *route6)
 	return false;
 }
 
-static void parse_route_line(char *line, struct route_args *route)
+static void parse_route_line(const char *line, struct route_args *route)
 {
 	size_t length = 0;
 
@@ -125,10 +125,10 @@ static void parse_route_line(char *line, struct route_args *route)
 	}
 
 	if (route->metric == NULL)
-		route->metric = "0";
+		route->metric = dmstrdup("0");
 
 	if (route->iface == NULL)
-		route->iface = "";
+		route->iface = dmstrdup("");
 }
 
 static int parse_route6_line(const char *line, struct route6_args *route6)
@@ -167,10 +167,10 @@ static int parse_route6_line(const char *line, struct route6_args *route6)
 	}
 
 	if (route6->metric == NULL)
-		route6->metric = "0";
+		route6->metric = dmstrdup("0");
 
 	if (route6->iface == NULL)
-		route6->iface = "";
+		route6->iface = dmstrdup("");
 
 	return 0;
 }
@@ -193,7 +193,7 @@ static void dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DM
 		dmuci_get_value_by_section_string(s, "target", &target);
 		dmuci_get_value_by_section_string(s, "device", &iface);
 
-		pp = popen(cmd, "r");
+		pp = popen(cmd, "r"); // flawfinder: ignore
 		if (pp != NULL) {
 			bool found = false;
 
@@ -213,7 +213,7 @@ static void dmmap_synchronizeRoutingRouterIPv4Forwarding(struct dmctx *dmctx, DM
 		}
 	}
 
-	pp = popen(cmd, "r");
+	pp = popen(cmd, "r"); // flawfinder: ignore
 	if (pp != NULL) {
 		while (fgets(line, MAX_ROUTE_LEN, pp) != NULL) {
 			remove_new_line(line);
@@ -262,7 +262,7 @@ static void dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DM
 		dmuci_get_value_by_section_string(s, "target", &target);
 		dmuci_get_value_by_section_string(s, "device", &iface);
 
-		pp = popen(cmd, "r");
+		pp = popen(cmd, "r"); // flawfinder: ignore
 		if (pp != NULL) {
 			bool found = false;
 
@@ -285,7 +285,7 @@ static void dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DM
 		}
 	}
 
-	pp = popen(cmd, "r");
+	pp = popen(cmd, "r"); // flawfinder: ignore
 	if (pp != NULL) {
 		while (fgets(line, MAX_ROUTE_LEN, pp) != NULL) {
 			remove_new_line(line);
@@ -317,7 +317,7 @@ static void dmmap_synchronizeRoutingRouterIPv6Forwarding(struct dmctx *dmctx, DM
 	}
 }
 
-static void create_routing_route_section(char *rt_table)
+static void create_routing_route_section(const char *rt_table)
 {
 	if (!is_dmmap_section_exist_eq("dmmap_routing", "router", "rt_table", rt_table)) {
 		struct uci_section *s = NULL;
@@ -498,13 +498,13 @@ static int browseRoutingRouteInformationInterfaceSettingInst(struct dmctx *dmctx
 **************************************************************/
 static int get_router_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
 	return 0;
 }
 
 static int get_RoutingRouter_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
 	return 0;
 }
 
@@ -523,7 +523,7 @@ static int set_RoutingRouter_Enable(char *refparam, struct dmctx *ctx, void *dat
 
 static int get_RoutingRouter_Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "Enabled";
+	*value = dmstrdup("Enabled");
 	return 0;
 }
 
@@ -546,7 +546,7 @@ static int get_RoutingRouter_IPv6ForwardingNumberOfEntries(char *refparam, struc
 static int get_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
 	if (((struct dm_data *)data)->config_section == NULL) { // Dynamic route
-		*value = "1";
+		*value = dmstrdup("1");
 	} else { //Static route
 		char *disabled = NULL;
 
@@ -676,14 +676,14 @@ static int set_router_ipv4forwarding_forwarding_policy(char *refparam, struct dm
 static int get_router_ipv4forwarding_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
 	if (((struct dm_data *)data)->config_section)
-		*value = "Static";
+		*value = dmstrdup("Static");
 	else {
 		json_object *res = NULL;
 		char *interface;
 
 		dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "interface", &interface);
 		dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", interface, String}}, 1, &res);
-		DM_ASSERT(res, *value = "DHCPv4");
+		DM_ASSERT(res, *value = dmstrdup("DHCPv4"));
 		char *proto = dmjson_get_value(res, 1, "proto");
 		*value = (proto && DM_LSTRNCMP(proto, "ppp", 3) == 0) ? "IPCP" : "DHCPv4";
 	}
@@ -776,7 +776,7 @@ static int set_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, v
 static int get_RoutingRouterIPv6Forwarding_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
 	if (((struct dm_data *)data)->config_section == NULL) { // Dynamic route
-		*value = "1";
+		*value = dmstrdup("1");
 	} else {
 		char *disabled = NULL;
 
@@ -930,13 +930,13 @@ static int set_RoutingRouterIPv6Forwarding_ForwardingMetric(char *refparam, stru
 
 static int get_RoutingRouterIPv6Forwarding_ExpirationTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "9999-12-31T23:59:59Z";
+	*value = dmstrdup("9999-12-31T23:59:59Z");
 	return 0;
 }
 
 static int get_RoutingRouteInformation_Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "1";
+	*value = dmstrdup("1");
 	return 0;
 }
 
@@ -968,7 +968,7 @@ static int get_RoutingRouteInformation_InterfaceSettingNumberOfEntries(char *ref
 
 			char *if_name = section_name(s);
 			dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", if_name, String}}, 1, &res);
-			DM_ASSERT(res, *value = "0");
+			DM_ASSERT(res, *value = dmstrdup("0"));
 			json_object_object_get_ex(res, "route", &routes);
 			nbre_routes = (routes) ? json_object_array_length(routes) : 0;
 		}
@@ -982,7 +982,7 @@ static int get_RoutingRouteInformationInterfaceSetting_Status(char *refparam, st
 	struct uci_section *s = NULL;
 	char *target, *mask, *nexthop, *gateway, *ip_target, buf[64];
 
-	*value = "NoForwardingEntry";
+	*value = dmstrdup("NoForwardingEntry");
 	target = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "target");
 	mask = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "mask");
 	snprintf(buf, sizeof(buf), "%s/%s", target, mask);
@@ -991,7 +991,7 @@ static int get_RoutingRouteInformationInterfaceSetting_Status(char *refparam, st
 		dmuci_get_value_by_section_string(s, "target", &ip_target);
 		dmuci_get_value_by_section_string(s, "gateway", &gateway);
 		if(DM_STRCMP(ip_target, buf) == 0 && DM_STRCMP(nexthop, gateway) == 0) {
-			*value = "ForwardingEntryCreated";
+			*value = dmstrdup("ForwardingEntryCreated");
 			return 0;
 		}
 	}
@@ -1049,7 +1049,7 @@ static int get_RoutingRouteInformationInterfaceSetting_SourceRouter(char *refpar
 
 static int get_RoutingRouteInformationInterfaceSetting_RouteLifetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
 {
-	*value = "0001-01-01T00:00:00Z";
+	*value = dmstrdup("0001-01-01T00:00:00Z");
 
 	char *valid = dmjson_get_value(((struct dm_data *)data)->json_object, 1, "valid");
 	if (valid && *valid != '\0' && DM_STRTOL(valid) > 0) {
@@ -1131,28 +1131,21 @@ static int delete_router(char *refparam, struct dmctx *ctx, void *data, char *in
 	struct uci_section *s = NULL;
 	char *rt_table = NULL;
 
-	switch (del_action) {
-		case DEL_INST:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "rt_table", &rt_table);
-			if(DM_LSTRCMP(rt_table, "254") == 0) {
-				bbfdm_set_fault_message(ctx, "It's not allowed to delete the main '254' routing table.");
-				return FAULT_9003;
-			}
+	dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "rt_table", &rt_table);
+	if(DM_LSTRCMP(rt_table, "254") == 0) {
+		bbfdm_set_fault_message(ctx, "It's not allowed to delete the main '254' routing table.");
+		return FAULT_9003;
+	}
 
-			uci_foreach_sections("network", "interface", s) {
-				char *curr_rt_table = NULL;
+	uci_foreach_sections("network", "interface", s) {
+		char *curr_rt_table = NULL;
 
-				dmuci_get_value_by_section_string(s, "ip4table", &curr_rt_table);
-				if (DM_STRCMP(curr_rt_table, rt_table) == 0)
-					dmuci_set_value_by_section(s, "ip4table", "");
-			}
+		dmuci_get_value_by_section_string(s, "ip4table", &curr_rt_table);
+		if (DM_STRCMP(curr_rt_table, rt_table) == 0)
+			dmuci_set_value_by_section(s, "ip4table", "");
+	}
 
-			dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			bbfdm_set_fault_message(ctx, "It's not allowed to delete all routing tables since there are some routing tables defined by the system '/etc/iproute2/rt_tables'.");
-			return FAULT_9005;
-		}
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 	return 0;
 }
 
@@ -1178,39 +1171,17 @@ static int add_ipv4forwarding(char *refparam, struct dmctx *ctx, void *data, cha
 
 static int delete_ipv4forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *route_s = NULL, *stmp = NULL, *dmmap_section = NULL;
-	char *rt_table = NULL;
-
-	switch (del_action) {
-		case DEL_INST:
-			// Return 9008 error if the removed route is dynamic
-			if (((struct dm_data *)data)->config_section == NULL) { // Dynamic route
-				bbfdm_set_fault_message(ctx, "This is a dynamic 'route' instance, therefore it's not permitted to delete it.");
-				return FAULT_9008;
-			}
-
-			// Remove dmmap section
-			get_dmmap_section_of_config_section("dmmap_routing", "route", section_name(((struct dm_data *)data)->config_section), &dmmap_section);
-			dmuci_delete_by_section(dmmap_section, NULL, NULL);
-
-			// Remove config section
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "rt_table", &rt_table);
-
-			// Remove all static routes
-			uci_foreach_option_eq_safe("network", "route", "rt_table", rt_table, stmp, route_s) {
+	// Return 9008 error if the removed route is dynamic
+	if (((struct dm_data *)data)->config_section == NULL) { // Dynamic route
+		bbfdm_set_fault_message(ctx, "This is a dynamic 'route' instance, therefore it's not permitted to delete it.");
+		return FAULT_9008;
+	}
 
-				// Remove dmmap section
-				get_dmmap_section_of_config_section("dmmap_routing", "route", section_name(route_s), &dmmap_section);
-				dmuci_delete_by_section(dmmap_section, NULL, NULL);
+	// Remove dmmap section
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 
-				// Remove config section
-				dmuci_delete_by_section(route_s, NULL, NULL);
-			}
-			break;
-		}
+	// Remove config section
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
 	return 0;
 }
 
@@ -1236,39 +1207,17 @@ static int add_ipv6Forwarding(char *refparam, struct dmctx *ctx, void *data, cha
 
 static int delete_ipv6Forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
 {
-	struct uci_section *route6_s = NULL, *stmp = NULL, *dmmap_section = NULL;
-	char *rt_table = NULL;
-
-	switch (del_action) {
-		case DEL_INST:
-			// Return 9008 error if the removed route6 is dynamic
-			if (((struct dm_data *)data)->config_section == NULL) { // Dynamic route
-				bbfdm_set_fault_message(ctx, "This is a dynamic 'route' instance, therefore it's not permitted to delete it.");
-				return FAULT_9008;
-			}
-
-			// Remove dmmap section
-			get_dmmap_section_of_config_section("dmmap_routing", "route6", section_name(((struct dm_data *)data)->config_section), &dmmap_section);
-			dmuci_delete_by_section(dmmap_section, NULL, NULL);
-
-			// Remove config section
-			dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
-			break;
-		case DEL_ALL:
-			dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "rt_table", &rt_table);
-
-			// Remove all static enable routes
-			uci_foreach_option_eq_safe("network", "route6", "rt_table", rt_table, stmp, route6_s) {
+	// Return 9008 error if the removed route6 is dynamic
+	if (((struct dm_data *)data)->config_section == NULL) { // Dynamic route
+		bbfdm_set_fault_message(ctx, "This is a dynamic 'route' instance, therefore it's not permitted to delete it.");
+		return FAULT_9008;
+	}
 
-				// Remove dmmap section
-				get_dmmap_section_of_config_section("dmmap_routing", "route6", section_name(route6_s), &dmmap_section);
-				dmuci_delete_by_section(dmmap_section, NULL, NULL);
+	// Remove dmmap section
+	dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL);
 
-				// Remove config section
-				dmuci_delete_by_section(route6_s, NULL, NULL);
-			}
-			break;
-	}
+	// Remove config section
+	dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL);
 	return 0;
 }
 
-- 
GitLab