From b5d094635118ba1e9cc89abbbabd7e267bd7af3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 13 Jan 2026 18:19:48 +0100 Subject: [PATCH] base-files: introduce a function to generate IAID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- package/base-files/files/lib/functions/network.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 4851a5817a..54ca7b00d4 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