Add source-restricted routes
[project/netifd.git] / dummy / netifd-proto.sh
index ae5a346..6f20de9 100755 (executable)
@@ -143,8 +143,9 @@ proto_add_ipv6_route() {
        local gw="$3"
        local metric="$4"
        local valid="$5"
+       local source="$6"
 
-       append PROTO_ROUTE6 "$target/$mask/$gw/$metric/$valid"
+       append PROTO_ROUTE6 "$target/$mask/$gw/$metric/$valid/$source"
 }
 
 proto_add_ipv6_prefix() {
@@ -218,6 +219,8 @@ _proto_push_route() {
        local metric="${str%%/*}"
        str="${str#*/}"
        local valid="${str%%/*}"
+       str="${str#*/}"
+       local source="${str}"
 
        json_add_object ""
        json_add_string target "$target"
@@ -225,6 +228,7 @@ _proto_push_route() {
        [ -n "$gw" ] && json_add_string gateway "$gw"
        [ -n "$metric" ] && json_add_int metric "$metric"
        [ -n "$valid" ] && json_add_int valid "$valid"
+       [ -n "$source" ] && json_add_string source "$source"
        json_close_object
 }
 
@@ -334,6 +338,7 @@ proto_set_available() {
 proto_add_host_dependency() {
        local interface="$1"
        local host="$2"
+       local ifname="$3"
 
        # execute in subshell to not taint callers env
        # see tickets #11046, #11545, #11570
@@ -341,6 +346,7 @@ proto_add_host_dependency() {
                json_init
                json_add_int action 6
                json_add_string host "$host"
+               [ -n "$ifname" ] && json_add_string ifname "$ifname"
                _proto_notify "$interface" -S
        )
 }