diff mbox

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

Message ID 1458658563-1348-1-git-send-email-helmut.schaa@googlemail.com
State Changes Requested
Headers show

Commit Message

Helmut Schaa March 22, 2016, 2:56 p.m. UTC
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@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 mbox

Patch

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; }