[PATCH] base-files: migrate old UCI network sections defining bridges
Adrian Schmutzler
mail at adrianschmutzler.de
Sun May 23 02:10:01 PDT 2021
Hi,
> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Rafal Milecki
> Sent: Dienstag, 18. Mai 2021 23:42
> To: Jo-Philipp Wich <jo at mein.io>; Hans Dedecker <dedeckeh at gmail.com>;
> John Crispin <john at phrozen.org>; Felix Fietkau <nbd at nbd.name>;
> openwrt-devel at lists.openwrt.org
> Cc: Rafał Miłecki <rafal at milecki.pl>
> Subject: [PATCH] base-files: migrate old UCI network sections defining
> bridges
>
> From: Rafał Miłecki <rafal at milecki.pl>
>
> Old "interface" sections for bridges were mixing layer 2 and layer 3.
> That syntax got deprecated and UCI section "device" is used for bridge
> configuration now.
>
> Backward compatibility may be dropped from netifd soon now so migrate old
> configs using uci-defaults script.
>
> Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
> ---
> That "soon" is relative, I'm not planning to push this patch yet. We may give
> updated /etc/config/network few months to receive proper testing.
> ---
> .../uci-defaults/11_network-migrate-bridges | 24 +++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/package/base-files/files/etc/uci-defaults/11_network-migrate-
> bridges b/package/base-files/files/etc/uci-defaults/11_network-migrate-
> bridges
> index 745648531f..7188c06ce3 100644
> --- a/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges
> +++ b/package/base-files/files/etc/uci-defaults/11_network-migrate-bridg
> +++ es
> @@ -17,7 +17,31 @@ migrate_ports() {
> uci delete network.$config.ifname
> }
>
> +migrate_bridge() {
> + local config="$1"
> + local type ifname
> +
> + config_get type "$config" type
> + [ "$type" != "bridge" ] && return
> +
> + config_get ifname "$config" ifname
> +
> + uci -q batch <<-EOF
> + add network device
> + set network. at device[-1].name='br-$config'
> + set network. at device[-1].type='bridge'
> + EOF
> + for port in $ifname; do uci add_list
> +network. at device[-1].ports="$port"; done
> +
> + uci -q batch <<-EOF
> + delete network.$config.type
> + set network.$config.ifname='br-$config'
> + EOF
> +}
> +
> config_load network
> config_foreach migrate_ports device
> +config_foreach migrate_bridge interface uci commit network
>
> exit 1
Just to document it somewhere on the list as well:
I don't think putting "exit 1" here is a good solution. The uci-defaults script are by design meant to be run only once and then deleted.
We should either choose a "big" number for the uci-defaults file name, so the script is run _after_ the others and deals with custom config, or use some init.d/rc.d-based script instead that runs for every boot.
From a conceptual perspective, I'd prefer uci-defaults since we should be able to do the migration "in one step" for practical reasons and consistency.
Apart from that, thanks for taking care of this subject and trying to make network config more understandable.
Best
Adrian
> --
> 2.26.2
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20210523/6e5e0411/attachment.sig>
More information about the openwrt-devel
mailing list