summaryrefslogtreecommitdiff
path: root/package/network/services/relayd
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2017-02-25 20:07:27 +0800
committerYousong Zhou <yszhou4tech@gmail.com>2017-02-26 14:38:25 +0800
commitef5cb964b170d369e971371fe4644d17cf1b3c60 (patch)
treedce345a4c6a5bcdb669656e8024f37a464c6aeea /package/network/services/relayd
parent77fb98ee41930d96e3c5a6bdb9341df20ae3afcb (diff)
downloadmtk-20170518-ef5cb964b170d369e971371fe4644d17cf1b3c60.zip
mtk-20170518-ef5cb964b170d369e971371fe4644d17cf1b3c60.tar.gz
mtk-20170518-ef5cb964b170d369e971371fe4644d17cf1b3c60.tar.bz2
relayd: fix making incomplete instance json data
Defer procd_open_instance only after validity check passed. Fixes FS#541 Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'package/network/services/relayd')
-rw-r--r--package/network/services/relayd/Makefile2
-rw-r--r--package/network/services/relayd/files/relay.init19
2 files changed, 14 insertions, 7 deletions
diff --git a/package/network/services/relayd/Makefile b/package/network/services/relayd/Makefile
index 25c56d4..dcb69a1 100644
--- a/package/network/services/relayd/Makefile
+++ b/package/network/services/relayd/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=relayd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE_URL=$(LEDE_GIT)/project/relayd.git
PKG_SOURCE_PROTO:=git
diff --git a/package/network/services/relayd/files/relay.init b/package/network/services/relayd/files/relay.init
index ac10f48..5c7a0f9 100644
--- a/package/network/services/relayd/files/relay.init
+++ b/package/network/services/relayd/files/relay.init
@@ -19,8 +19,7 @@ validate_proto_relayd()
resolve_ifname() {
grep -qs "^ *$1:" /proc/net/dev && {
- procd_append_param command -I "$1"
- procd_append_param netdev "$1"
+ append resolved_ifnames "$1"
}
}
@@ -34,6 +33,7 @@ resolve_network() {
start_relay() {
local cfg="$1"
+ local proto disabled
config_get proto "$cfg" proto
[ "$proto" = "relay" ] || return 0
@@ -41,9 +41,7 @@ start_relay() {
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -gt 0 ] && return 0
- procd_open_instance
- procd_set_param command "$PROG"
-
+ local resolved_ifnames
local net networks
config_get networks "$cfg" network
for net in $networks; do
@@ -55,9 +53,18 @@ start_relay() {
local ifn ifnames
config_get ifnames "$cfg" ifname
for ifn in $ifnames; do
- resolve_ifname "$ifn"
+ resolve_ifname "$ifn" || {
+ return 1
+ }
done
+ procd_open_instance
+ procd_set_param command "$PROG"
+
+ for ifn in $resolved_ifnames; do
+ procd_append_param command -I "$ifn"
+ procd_append_param netdev "$ifn"
+ done
local ipaddr
config_get ipaddr "$cfg" ipaddr
[ -n "$ipaddr" ] && procd_append_param command -L "$ipaddr"