gre: introduce 'nohostroute' option
[openwrt/openwrt.git] / package / network / config / gre / files / gre.sh
index 2bb1010b76aa30ecd07082e81c756089eb1273a3..3414ed304796ea35911ecb8b27f397d530ad7405 100755 (executable)
@@ -56,7 +56,7 @@ gre_setup() {
        local remoteip
 
        local ipaddr peeraddr
-       json_get_vars df ipaddr peeraddr tunlink
+       json_get_vars df ipaddr peeraddr tunlink nohostroute
 
        [ -z "$peeraddr" ] && {
                proto_notify_error "$cfg" "MISSING_PEER_ADDRESS"
@@ -76,7 +76,9 @@ gre_setup() {
                break
        done
 
-       ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" )
+       if [ "${nohostroute}" != "1" ]; then
+               ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" )
+       fi
 
        [ -z "$ipaddr" ] && {
                local wanif="$tunlink"
@@ -133,7 +135,7 @@ grev6_setup() {
        local remoteip6
 
        local ip6addr peer6addr weakif
-       json_get_vars ip6addr peer6addr tunlink weakif encaplimit
+       json_get_vars ip6addr peer6addr tunlink weakif encaplimit nohostroute
 
        [ -z "$peer6addr" ] && {
                proto_notify_error "$cfg" "MISSING_PEER_ADDRESS"
@@ -153,7 +155,9 @@ grev6_setup() {
                break
        done
 
-       ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" )
+       if [ "${nohostroute}" != "1" ]; then
+               ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" )
+       fi
 
        [ -z "$ip6addr" ] && {
                local wanif="$tunlink"
@@ -262,6 +266,7 @@ proto_gre_init_config() {
        proto_config_add_string "ipaddr"
        proto_config_add_string "peeraddr"
        proto_config_add_boolean "df"
+       proto_config_add_boolean "nohostroute"
 }
 
 proto_gretap_init_config() {
@@ -275,6 +280,7 @@ proto_grev6_init_config() {
        proto_config_add_string "peer6addr"
        proto_config_add_string "weakif"
        proto_config_add_string "encaplimit"
+       proto_config_add_boolean "nohostroute"
 }
 
 proto_grev6tap_init_config() {