[openwrt/openwrt] base-files: reduce IPv6 ULA prefix generation to a single call
LEDE Commits
lede-commits at lists.infradead.org
Thu Apr 18 03:56:04 PDT 2024
ansuel pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/27edf28b11f179eb9fc6ab159b68b2fe97ffdf1e
commit 27edf28b11f179eb9fc6ab159b68b2fe97ffdf1e
Author: Paul Donald <newtwen+github at gmail.com>
AuthorDate: Fri Mar 29 16:04:30 2024 +0100
base-files: reduce IPv6 ULA prefix generation to a single call
Reduce calls and pipes and read from urandom once directly with hexdump
for the necessary 5 bytes of random data to build the 48 bit ULA Prefix.
Fewer calls and forks; finish quicker; less memory used.
Tested on: 23.05.3
Signed-off-by: Paul Donald <newtwen+github at gmail.com>
---
package/base-files/files/etc/uci-defaults/12_network-generate-ula | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula
index 19d7ed7f2e..060d0ef640 100644
--- a/package/base-files/files/etc/uci-defaults/12_network-generate-ula
+++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula
@@ -1,11 +1,7 @@
[ "$(uci -q get network.globals.ula_prefix)" != "auto" ] && exit 0
-r1=$(dd if=/dev/urandom bs=1 count=1 |hexdump -e '1/1 "%02x"')
-r2=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"')
-r3=$(dd if=/dev/urandom bs=2 count=1 |hexdump -e '2/1 "%02x"')
-
uci -q batch <<-EOF >/dev/null
- set network.globals.ula_prefix=fd$r1:$r2:$r3::/48
+ set network.globals.ula_prefix="$(hexdump -vn 5 -e '"fd" 1/1 "%02x:" 2/2 "%x:"' /dev/urandom):/48"
commit network
EOF
More information about the lede-commits
mailing list