[PATCH] base-files: migrate old UCI network sections defining bridges
Paul Oranje (BB)
p.oranje.beterburen at gmail.com
Sun May 16 03:10:26 PDT 2021
I like this setup. Just some questions and a tiny nit pick.
Paul
Op 15 mei 2021, om 23:11 heeft Rafał Miłecki <zajec5 at gmail.com> het volgende geschreven:
>
> From: Rafał Miłecki <rafal at milecki.pl>
>
> Old "interface" sections for bridges were mixing layer 2 and layer 3.
> Migrate them to the new styles that has:
> 1. "device" UCI section for L2 bridge
> 2. "interface" UCI section for L3 interface
IIUC for a non-bridge ifname refers to a netdev that will implicitly be created without an explicit UCI device section.
IIUC a device (L2 bridge) can have a VLAN as port (e.g. when converting interface.ifname=eth1.10).
IIUC for a bridge with an empty ifname a device section without ports will be created.
You probably also considered renaming the interface option ifname (devname). What made you decide to stick with ifname ?
> Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
> ---
> .../files/etc/uci-defaults/11_network-bridge | 29 +++++++++++++++++++
> 1 file changed, 29 insertions(+)
> create mode 100644 package/base-files/files/etc/uci-defaults/11_network-bridge
>
> diff --git a/package/base-files/files/etc/uci-defaults/11_network-bridge b/package/base-files/files/etc/uci-defaults/11_network-bridge
> new file mode 100644
> index 0000000000..7a53e8e355
> --- /dev/null
> +++ b/package/base-files/files/etc/uci-defaults/11_network-bridge
> @@ -0,0 +1,29 @@
> +. /lib/functions.sh
> +
> +migrate_bridge() {
> + local config="$1"
interface i.s.o. config ?
> + 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-$1'
$config i.s.o. $1
> + 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.$1.type
> + set network.$1.ifname='br-$1'
$config i.s.o. $1
> + EOF
> +}
> +
> +config_load network
> +config_foreach migrate_bridge interface
> +uci commit network
> +
> +exit 0
> --
> 2.26.2
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list