From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from svn.comics.unina.it (unknown [143.225.229.147]) by huchra.bufferbloat.net (Postfix) with ESMTP id 64D90201AF7 for ; Fri, 13 May 2011 06:31:28 -0700 (PDT) Received: from www-data by svn.comics.unina.it with local (Exim 4.69) (envelope-from ) id 1QKsfF-0001PP-6E for bismark-commits@lists.bufferbloat.net; Fri, 13 May 2011 15:44:21 +0200 To: bismark-commits@lists.bufferbloat.net From: walter@svn.comics.unina.it Message-Id: Date: Fri, 13 May 2011 15:44:21 +0200 Subject: [Bismark-commits] rev 334 - trunk/device/OpenWrt_common/etc trunk/device/OpenWrt_common/scripts X-BeenThere: bismark-commits@lists.bufferbloat.net X-Mailman-Version: 2.1.13 Precedence: list List-Id: Commit log for the bismark source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2011 13:31:28 -0000 Author: walter Date: 2011-05-13 15:44:21 +0200 (Fri, 13 May 2011) New Revision: 334 Modified: trunk/device/OpenWrt_common/etc/bismark.conf trunk/device/OpenWrt_common/scripts/bismark-probe trunk/device/OpenWrt_common/scripts/bismark-rshell Log: recovery tunnel management fixed added round-robin multi-port probing Modified: trunk/device/OpenWrt_common/etc/bismark.conf =================================================================== --- trunk/device/OpenWrt_common/etc/bismark.conf 2011-05-13 13:33:46 UTC (rev 333) +++ trunk/device/OpenWrt_common/etc/bismark.conf 2011-05-13 13:44:21 UTC (rev 334) @@ -7,7 +7,7 @@ SERVER=143.215.131.215 USER=bismark SSH_KEY=/etc/bismark/bismark_key -PROBE_PORT=53 +PROBE_PORTS="53 1028 1234 5353 54321" LOCALTIME=America/New_York # Bismark Proxy Server Modified: trunk/device/OpenWrt_common/scripts/bismark-probe =================================================================== --- trunk/device/OpenWrt_common/scripts/bismark-probe 2011-05-13 13:33:46 UTC (rev 333) +++ trunk/device/OpenWrt_common/scripts/bismark-probe 2011-05-13 13:44:21 UTC (rev 334) @@ -24,11 +24,12 @@ # Create status files [ -e /tmp/bismark/var/faults ] || echo 0 > /tmp/bismark/var/faults [ -e /tmp/bismark/var/proxy ] || echo 0 > /tmp/bismark/var/proxy +[ -e /tmp/bismark/var/port_counter ] || echo 0 > /tmp/bismark/var/port_counter # Check faults count -faults=$(cat /tmp/bismark/var/faults) +read faults < /tmp/bismark/var/faults if [ $faults -ge 20 ]; then - proxy=$(cat /tmp/bismark/var/proxy) + read proxy < /tmp/bismark/var/proxy echo $(( (proxy + 1) % 2 )) > /tmp/bismark/var/proxy echo 0 > /tmp/bismark/var/faults faults=0 @@ -37,6 +38,10 @@ # Random delay wait sleep $(random 0 $MAX_SLEEP) +# Select probe port +read port_counter < /tmp/bismark/var/port_counter +PROBE_PORT=$(echo $PROBE_PORTS | awk '{print $'$((port_counter + 1))'}') + # Send probe and store reply if [ $(cat /tmp/bismark/var/proxy) -eq 1 ]; then msg | nc -u $NC_OPTS $PROXY $PROXY_PORT > /tmp/bismark/var/reply @@ -44,12 +49,18 @@ msg | nc -u $NC_OPTS $SERVER $PROBE_PORT > /tmp/bismark/var/reply fi -# Refresh faults count +# Faults control if [ "`cat /tmp/bismark/var/reply`" ]; then - echo 0 > /tmp/faults + # Reset faults count + echo 0 > /tmp/bismark/var/faults #event uplink up else - echo $((++faults)) > /tmp/faults + # Update faults count + echo $((++faults)) > /tmp/bismark/var/faults + + # Cycle server port + ports=$(echo $PROBE_PORTS | awk '{print NF}') + echo $(( (port_counter + 1) % ports )) > /tmp/bismark/var/port_counter #event uplink down fi Modified: trunk/device/OpenWrt_common/scripts/bismark-rshell =================================================================== --- trunk/device/OpenWrt_common/scripts/bismark-rshell 2011-05-13 13:33:46 UTC (rev 333) +++ trunk/device/OpenWrt_common/scripts/bismark-rshell 2011-05-13 13:44:21 UTC (rev 334) @@ -15,15 +15,16 @@ # Start new tunnel if last timestamp is more than 5 minutes old if [ $((`date +%s` - `cat /tmp/bismark/var/server_last`)) -gt 300 ]; then - if [ -e /tmp/tunnel ]; then + if [ -e /tmp/bismark/var/tunnel ]; then # Check pre-existing recovery tunnel - pid=$(cat /tmp/bismark/var/tunnel) + read pid < /tmp/bismark/var/tunnel ps $pid >/dev/null || rm /tmp/bismark/var/tunnel else # Create new recovery tunnel port=$(random $BASE_PORT $MAX_PORT) - #ssh -i $SSH_KEY $USER@$SERVER "bin/bdm settunnel $DEVICE_ID $port" ( ssh $KEEP_ALIVE -N -i $SSH_KEY -R $port:127.0.0.1:22 $USER@$SERVER >/dev/null 2>&1 & ) + sleep 2 + ssh -i $SSH_KEY $USER@$SERVER "bin/bdm updatetunnels" echo $! > /tmp/bismark/var/tunnel fi fi