map: add sleep work-around for lw4o6 race-condition
[openwrt/staging/chunkeey.git] / package / network / ipv6 / map / files / map.sh
index 83de4cc4dc52d49413429ee702fb7b41dfa585fe..98a493dd5714f3f3d8ce0c9e5d291afac588ba9d 100755 (executable)
@@ -39,6 +39,9 @@ proto_map_setup() {
 
        ( proto_add_host_dependency "$cfg" "::" "$tunlink" )
 
+       # fixme: handle RA/DHCPv6 address race for LW
+       [ "$type" = lw4o6 ] && sleep 5
+
        if [ -z "$rule" ]; then
                rule="type=$type,ipv6prefix=$ip6prefix,prefix6len=$ip6prefixlen,ipv4prefix=$ipaddr,prefix4len=$ip4prefixlen"
                [ -n "$psid" ] && rule="$rule,psid=$psid"
@@ -52,6 +55,7 @@ proto_map_setup() {
                fi
        fi
 
+       echo "rule=$rule" > /tmp/map-$cfg.rules
        RULE_DATA=$(mapcalc ${tunlink:-\*} $rule)
        if [ "$?" != 0 ]; then
                proto_notify_error "$cfg" "INVALID_MAP_RULE"
@@ -59,8 +63,9 @@ proto_map_setup() {
                return
        fi
 
+       echo "$RULE_DATA" >> /tmp/map-$cfg.rules
        eval $RULE_DATA
-       
+
        if [ -z "$RULE_BMR" ]; then
                proto_notify_error "$cfg" "NO_MATCHING_PD"
                proto_block_restart "$cfg"
@@ -71,7 +76,7 @@ proto_map_setup() {
        if [ "$type" = "lw4o6" -o "$type" = "map-e" ]; then
                proto_init_update "$link" 1
                proto_add_ipv4_address $(eval "echo \$RULE_${k}_IPV4ADDR") "" "" ""
-       
+
                proto_add_tunnel
                json_add_string mode ipip6
                json_add_int mtu "${mtu:-1280}"
@@ -174,7 +179,7 @@ proto_map_setup() {
 
        if [ "$type" = "lw4o6" -o "$type" = "map-e" ]; then
                json_init
-               json_add_string name "${cfg}_local"
+               json_add_string name "${cfg}_"
                json_add_string ifname "@$(eval "echo \$RULE_${k}_PD6IFACE")"
                json_add_string proto "static"
                json_add_array ip6addr
@@ -187,11 +192,12 @@ proto_map_setup() {
 
 proto_map_teardown() {
        local cfg="$1"
-       ifdown "${cfg}_local"
+       ifdown "${cfg}_"
+       rm -f /tmp/map-$cfg.rules
 }
 
 proto_map_init_config() {
-       no_device=1             
+       no_device=1
        available=1
 
        proto_config_add_string "rule"