config: fix incompatible with jshn network-device entry
authorChristian Marangi <ansuelsmth@gmail.com>
Fri, 20 Oct 2023 10:40:27 +0000 (12:40 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 20 Oct 2023 10:49:53 +0000 (12:49 +0200)
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 <michael@a5ap.net>
Fixes: 42c48866f1c1 ("config: parse default mac address from board.json")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
config.c
config/board.json

index dbf44257cce205189666fb2b7b682acfc12a7691..b4724b5c956649f9e9e74a6d535d7427287a0d89 100644 (file)
--- 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;
index 112a511936a64e5d4598bed1c4491b9bb020c636..96f2380260bc67fa5d93488f00304174b8391167 100644 (file)
@@ -20,7 +20,7 @@
             "macaddr": "be:a5:11:16:76:d7"
         }
     },
-    "network-device": {
+    "network_device": {
         "eth0": {
             "macaddr": "bc:a5:11:16:76:d7"
         },