X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=package%2Fnetwork%2Fconfig%2Fgre%2Ffiles%2Fgre.sh;h=a6b4ba85f6c762c4d61197aa126fc49d6ee7c71e;hb=3a5bacdc7dfb0a34074f0ac93d9bc90e94ba2b71;hp=4483a087871126c2a6e524e58f12871ea9ef6d28;hpb=6e2262898f1ce420be6156e806f3e4854209ac7e;p=openwrt%2Fopenwrt.git diff --git a/package/network/config/gre/files/gre.sh b/package/network/config/gre/files/gre.sh index 4483a08787..a6b4ba85f6 100755 --- a/package/network/config/gre/files/gre.sh +++ b/package/network/config/gre/files/gre.sh @@ -13,10 +13,11 @@ gre_generic_setup() { local local="$3" local remote="$4" local link="$5" - local mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno - json_get_vars mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno + local mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast + json_get_vars mtu ttl tos zone ikey okey icsum ocsum iseqno oseqno multicast [ -z "$zone" ] && zone="wan" + [ -z "$multicast" ] && multicast=1 proto_init_update "$link" 1 @@ -24,12 +25,22 @@ gre_generic_setup() { json_add_string mode "$mode" json_add_int mtu "${mtu:-1280}" [ -n "$df" ] && json_add_boolean df "$df" - json_add_int ttl "${ttl:-64}" + [ -n "ttl" ] && json_add_int ttl "$ttl" [ -n "$tos" ] && json_add_string tos "$tos" + json_add_boolean multicast "$multicast" json_add_string local "$local" json_add_string remote "$remote" [ -n "$tunlink" ] && json_add_string link "$tunlink" - json_add_string info "${ikey:-0},${okey:-0},${icsum:-0},${ocsum:-0},${iseqno:-0},${oseqno:-0}" + + json_add_object 'data' + [ -n "$ikey" ] && json_add_int ikey "$ikey" + [ -n "$okey" ] && json_add_int okey "$okey" + [ -n "$icsum" ] && json_add_boolean icsum "$icsum" + [ -n "$ocsum" ] && json_add_boolean ocsum "$ocsum" + [ -n "$iseqno" ] && json_add_boolean iseqno "$iseqno" + [ -n "$oseqno" ] && json_add_boolean oseqno "$oseqno" + json_close_object + proto_close_tunnel proto_add_data @@ -42,16 +53,29 @@ gre_generic_setup() { gre_setup() { local cfg="$1" local mode="$2" + local remoteip local ipaddr peeraddr json_get_vars df ipaddr peeraddr tunlink [ -z "$peeraddr" ] && { - proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" proto_block_restart "$cfg" exit } + remoteip=$(resolveip -t 10 -4 "$peeraddr") + + if [ -z "$remoteip" ]; then + proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" + exit + fi + + for ip in $remoteip; do + peeraddr=$ip + break + done + ( proto_add_host_dependency "$cfg" "$peeraddr" "$tunlink" ) [ -z "$ipaddr" ] && { @@ -69,7 +93,14 @@ gre_setup() { [ -z "$df" ] && df="1" - gre_generic_setup $cfg $mode $ipaddr $peeraddr "gre-$cfg" + case "$mode" in + gretapip) + gre_generic_setup $cfg $mode $ipaddr $peeraddr "gre4t-$cfg" + ;; + *) + gre_generic_setup $cfg $mode $ipaddr $peeraddr "gre4-$cfg" + ;; + esac } proto_gre_setup() { @@ -87,7 +118,7 @@ proto_gretap_setup() { gre_setup $cfg "gretapip" json_init - json_add_string name "gre-$cfg" + json_add_string name "gre4t-$cfg" json_add_boolean link-ext 0 json_close_object @@ -99,16 +130,29 @@ proto_gretap_setup() { grev6_setup() { local cfg="$1" local mode="$2" + local remoteip6 local ip6addr peer6addr weakif json_get_vars ip6addr peer6addr tunlink weakif [ -z "$peer6addr" ] && { - proto_notify_error "$cfg" "MISSING_ADDRESS" + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" proto_block_restart "$cfg" exit } + remoteip6=$(resolveip -t 10 -6 "$peer6addr") + + if [ -z "$remoteip6" ]; then + proto_notify_error "$cfg" "PEER_RESOLVE_FAIL" + exit + fi + + for ip6 in $remoteip6; do + peer6addr=$ip6 + break + done + ( proto_add_host_dependency "$cfg" "$peer6addr" "$tunlink" ) [ -z "$ip6addr" ] && { @@ -127,7 +171,14 @@ grev6_setup() { fi } - gre_generic_setup $cfg $mode $ip6addr $peer6addr "grev6-$cfg" + case "$mode" in + gretapip6) + gre_generic_setup $cfg $mode $ip6addr $peer6addr "gre6t-$cfg" + ;; + *) + gre_generic_setup $cfg $mode $ip6addr $peer6addr "gre6-$cfg" + ;; + esac } proto_grev6_setup() { @@ -145,7 +196,7 @@ proto_grev6tap_setup() { grev6_setup $cfg "gretapip6" json_init - json_add_string name "grev6-$cfg" + json_add_string name "gre6t-$cfg" json_add_boolean link-ext 0 json_close_object @@ -175,7 +226,7 @@ proto_gre_teardown() { proto_gretap_teardown() { local cfg="$1" - gretap_generic_teardown "gre-$cfg" + gretap_generic_teardown "gre4t-$cfg" } proto_grev6_teardown() { @@ -185,7 +236,7 @@ proto_grev6_teardown() { proto_grev6tap_teardown() { local cfg="$1" - gretap_generic_teardown "grev6-$cfg" + gretap_generic_teardown "gre6t-$cfg" } gre_generic_init_config() { @@ -203,6 +254,7 @@ gre_generic_init_config() { proto_config_add_boolean "ocsum" proto_config_add_boolean "iseqno" proto_config_add_boolean "oseqno" + proto_config_add_boolean "multicast" } proto_gre_init_config() {