From 9c5cbc030ffcd683cf61c7aef8e7995a2b4848d8 Mon Sep 17 00:00:00 2001 From: Amin Ben Romdhane Date: Tue, 23 Apr 2024 03:41:56 +0000 Subject: [PATCH] IP.Interface: setting 'mtu' option in device section instead of interface section --- libbbfdm/dmtree/tr181/ip.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libbbfdm/dmtree/tr181/ip.c b/libbbfdm/dmtree/tr181/ip.c index e3a7ffcd..830b748c 100644 --- a/libbbfdm/dmtree/tr181/ip.c +++ b/libbbfdm/dmtree/tr181/ip.c @@ -1438,13 +1438,28 @@ static int get_IPInterface_MaxMTUSize(char *refparam, struct dmctx *ctx, void *d static int set_IPInterface_MaxMTUSize(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { + char *device = NULL; + struct uci_section *s = NULL; + switch (action) { case VALUECHECK: if (bbfdm_validate_unsignedInt(ctx, value, RANGE_ARGS{{"64","65535"}}, 1)) return FAULT_9007; break; case VALUESET: - dmuci_set_value_by_section((struct uci_section *)data, "mtu", value); + /* find the device section for this interface */ + dmuci_get_value_by_section_string((struct uci_section *)data, "device", &device); + + /* check if device is empty */ + if ((device)[0] == '\0') { + return FAULT_9002; + } + + /* set option MTU in device section */ + uci_foreach_option_eq("network", "device", "name", device, s) { + dmuci_set_value_by_section(s, "mtu", value); + break; + } break; } return 0;