[OpenWrt-Devel] [PATCH] base-files: fix __network_ifstatus with lots of interfaces

Helmut Schaa helmut.schaa at googlemail.com
Tue Mar 22 10:56:03 EDT 2016


Having hundrets of interfaces configured with netifd makes __network_ifstatus
go busted with "jsonfilter: Argument list too long".

Fix this by removing the __NETWORK_CACHE environment variable.

The network_flush_cache function is kept so it can be reused later for
per-interface caching or similar things.

Signed-off-by: Helmut Schaa <helmut.schaa at googlemail.com>
---

FYI I've tried using a temp-file as cache but no real speed-up
could be observed. Hence, it might make sense to look into per-interface
caching instead.

 package/base-files/files/lib/functions/network.sh | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh
index 1b0c717..42057ba 100644
--- a/package/base-files/files/lib/functions/network.sh
+++ b/package/base-files/files/lib/functions/network.sh
@@ -6,10 +6,7 @@
 __network_ifstatus() {
 	local __tmp
 
-	[ -z "$__NETWORK_CACHE" ] && \
-		export __NETWORK_CACHE="$(ubus call network.interface dump)"
-
-	__tmp="$(jsonfilter ${4:+-F "$4"} ${5:+-l "$5"} -s "$__NETWORK_CACHE" -e "$1=@.interface${2:+[@.interface='$2']}$3")"
+	__tmp="$(ubus call network.interface dump | jsonfilter ${4:+-F "$4"} ${5:+-l "$5"} -e "$1=@.interface${2:+[@.interface='$2']}$3")"
 
 	[ -z "$__tmp" ] && \
 		unset "$1" && \
@@ -265,4 +262,4 @@ network_ready_device()
 }
 
 # flush the internal value cache to force re-reading values from ubus
-network_flush_cache() { unset __NETWORK_CACHE; }
+network_flush_cache() { true; }
-- 
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list