From 4fb67a7a61762c6b071c63bdf606fae91bc9b79e Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Mon, 8 Aug 2022 10:33:26 +0000 Subject: [PATCH] T#8433: IPv6Enable does not disable ipv6 for the required interface (cherry picked from commit 2ea3d2b52ee663ec6048c5632e3fca73af6a30f3) --- dmtree/json/tr181.json | 2 +- dmtree/tr181/ip.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dmtree/json/tr181.json b/dmtree/json/tr181.json index 487e0f92..4b6eb956 100644 --- a/dmtree/json/tr181.json +++ b/dmtree/json/tr181.json @@ -50515,7 +50515,7 @@ "uci": { "file": "network", "section": { - "type": "interface", + "type": "device", "index": "@i-1" }, "option": { diff --git a/dmtree/tr181/ip.c b/dmtree/tr181/ip.c index e133bd54..4e4062c0 100644 --- a/dmtree/tr181/ip.c +++ b/dmtree/tr181/ip.c @@ -1232,15 +1232,24 @@ static int set_IPInterface_IPv4Enable(char *refparam, struct dmctx *ctx, void *d return 0; } -/*#Device.IP.Interface.{i}.IPv6Enable!UCI:network/interface,@i-1/ipv6*/ +/*#Device.IP.Interface.{i}.IPv6Enable!UCI:network/device,@i-1/ipv6*/ static int get_IPInterface_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = dmuci_get_value_by_section_fallback_def((struct uci_section *)data, "ipv6", "1"); + char *device = NULL; + + dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device); + if (DM_STRLEN(device)) { + struct uci_section *device_s = get_dup_section_in_config_opt("network", "device", "name", device); + *value = device_s ? dmuci_get_value_by_section_fallback_def(device_s, "ipv6", "1") : "1"; + } else { + *value = "1"; + } return 0; } static int set_IPInterface_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + char *device = NULL; bool b; switch (action) { @@ -1250,7 +1259,11 @@ static int set_IPInterface_IPv6Enable(char *refparam, struct dmctx *ctx, void *d break; case VALUESET: string_to_bool(value, &b); - dmuci_set_value_by_section((struct uci_section *)data, "ipv6", b ? "1" : "0"); + dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device); + if (DM_STRLEN(device)) { + struct uci_section *device_s = get_dup_section_in_config_opt("network", "device", "name", device); + if (device_s) dmuci_set_value_by_section(device_s, "ipv6", b ? "1" : "0"); + } break; } return 0;