From: Álvaro Fernández Rojas Date: Tue, 13 Jan 2026 17:19:48 +0000 (+0100) Subject: base-files: introduce a function to generate IAID X-Git-Tag: v25.12.0-rc3~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5d094635118ba1e9cc89abbbabd7e267bd7af3a;p=thirdparty%2Fopenwrt.git base-files: introduce a function to generate IAID Add new function "network_generate_iface_iaid()" to generate a stable IAID from an interface name. (cherry picked from commit e1f2b666ff94f2b8a50ca000d69f5b5f0b89a27c) Link: https://github.com/openwrt/openwrt/pull/21489 Signed-off-by: Álvaro Fernández Rojas --- diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 4851a5817ad..54ca7b00d49 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -24,6 +24,17 @@ __network_ifstatus() { eval "$__tmp" } +# determine the IAID of the given logical interface +# 1: destination variable +# 2: interface +network_generate_iface_iaid() { + local __iaid + + __iaid=$(printf '%s' "$2" | md5sum | cut -c 1-8) + + export "$1=$__iaid" +} + # determine first IPv4 address of given logical interface # 1: destination variable # 2: interface