From 5590a80e2566d378be955f61c287a63fb3bdf329 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Fri, 20 Oct 2023 12:40:27 +0200 Subject: [PATCH] config: fix incompatible with jshn network-device entry On parsing jshn "normalize" the entry of any non alphanumeric char to '_'. This resulted in the secanrio where the data passed by board.json with entry 'network-device' being converted to 'network_device', and the system still expecting data with the original 'network-device'. To fix this, changes needs to be done in multiple place. Any function in core uci-defaults.sh that expect 'network-device' needs to be changed to 'network_device' and here in netifd core, we need to switch to use 'network_device' directly to prevent any conflict with jshn conversion. The issue was exposed by commit 4ebba8a05d09 ("realtek: add support for HPE 1920-8g-poe+") in openwrt core where board_config_load call from 03_gpio introduced the key normalization by jshn. board.json is not considered stable and is not migrated on sysupgrade but actually recreated with up to date data, hence no migration or special handling are needed and the entry can be directly changed. Ref: https://forum.openwrt.org/t/57875/2589 Ref: https://github.com/openwrt/openwrt/pull/13622 Reported-by: Michael 'ASAP' Weinrich Fixes: 42c48866f1c1 ("config: parse default mac address from board.json") Signed-off-by: Christian Marangi --- config.c | 2 +- config/board.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index dbf4425..b4724b5 100644 --- a/config.c +++ b/config.c @@ -732,7 +732,7 @@ config_init_board(void) free(board_netdevs); board_netdevs = NULL; - cur = config_find_blobmsg_attr(b.head, "network-device", + cur = config_find_blobmsg_attr(b.head, "network_device", BLOBMSG_TYPE_TABLE); if (!cur) return; diff --git a/config/board.json b/config/board.json index 112a511..96f2380 100644 --- a/config/board.json +++ b/config/board.json @@ -20,7 +20,7 @@ "macaddr": "be:a5:11:16:76:d7" } }, - "network-device": { + "network_device": { "eth0": { "macaddr": "bc:a5:11:16:76:d7" }, -- 2.30.2