X-Git-Url: https://git.nirgal.com/?p=source-route.git;a=blobdiff_plain;f=source-route;h=1845c8c1fcacc7fa6abef07708d5531d9521b2bb;hp=b8410d83cdc9ba4deab07b7fe74a0ca805c16200;hb=648a36374b3de66d3a004fdb58c884733b1121f4;hpb=dc99a5e637e337142519aa9f4a2a87663cd7d436 diff --git a/source-route b/source-route index b8410d8..1845c8c 100755 --- a/source-route +++ b/source-route @@ -17,43 +17,38 @@ #set -x RTTABLE=from$IFACE -LOGGER="logger -t source-route" +LOGGER="logger -t source-route -s" if test "$VERBOSITY" = 1 then - echo " IFACE=$IFACE LOGICAL=$LOGICAL ADDRFAM=$ADDRFAM METHOD=$METHOD MODE=$MODE PHASE=$PHASE VERBOSITY=$VERBOSITY PATH=$PATH" >&2 - $LOGGER -- IFACE=$IFACE LOGICAL=$LOGICAL ADDRFAM=$ADDRFAM METHOD=$METHOD MODE=$MODE PHASE=$PHASE VERBOSITY=$VERBOSITY PATH=$PATH + $LOGGER -p user.debug -- IFACE=$IFACE LOGICAL=$LOGICAL ADDRFAM=$ADDRFAM METHOD=$METHOD MODE=$MODE PHASE=$PHASE VERBOSITY=$VERBOSITY PATH=$PATH fi -critical_log() { - $LOGGER -- "$@" - echo "$@" >&2 -} if ! which ipv4calc >/dev/null then - critical_log "ipv4calc not found: apt-get install libnetwork-ipv4addr-perl" - exit 2 + $LOGGER -p user.crit -- "ipv4calc not found: apt-get install libnetwork-ipv4addr-perl" + exit 2 fi if ! which ipv6calc >/dev/null then - critical_log "ipv6calc not found: apt-get install ipv6calc" - exit 2 + $LOGGER -p user.crit -- "ipv6calc not found: apt-get install ipv6calc" + exit 2 fi if test -z "$IFACE" then - critical_log "\$IFACE var is empty. Are you really running from /etc/network/interfaces ?" - exit 2 + $LOGGER -p user.crit -- "\$IFACE is empty. Are you really running from /etc/network/interfaces ?" + exit 2 fi if test "$PHASE" != "post-up" then - critical_log "Invalid \$PHASE. $0 is only valid in 'post-up'." - exit 2 + $LOGGER -p user.error -- "Invalid \$PHASE. $0 is only valid in 'post-up'. Ignoring." + exit 0 # Soft failure fi RT_TABLES=/etc/iproute2/rt_tables if ! grep -q $RTTABLE /etc/iproute2/rt_tables then - critical_log "$RT_TABLES does not have $RTTABLE entry." + $LOGGER -p user.crit -- "$RT_TABLES does not have $RTTABLE entry." exit 2 fi @@ -65,8 +60,8 @@ inet6) IPFLAG=-6 ;; *) - echo \$ADDRFAM must be inet or inet6. Ignoring. >&2 - exit 0 + $LOGGER -p user.error -- "\$ADDRFAM must be inet or inet6. Ignoring." + exit 0 # Soft failure ;; esac IPADDR=$(ip $IPFLAG -o addr show $IFACE | grep -w $ADDRFAM | grep global | sed -re "s/.*$ADDRFAM (.*)\/.*/\1/") @@ -85,20 +80,19 @@ else fi if test -z "$IPGW" then - critical_log "Could not find the gateway." - exit 2 + $LOGGER -p user.crit "Could not find the gateway and none was given." + exit 2 fi # Setting up source routing on $IFACE, so that packets from $IFACE don't get answered on another interface -echo "Setting up source routing on $IFACE: from $IPADDR -> route $IPNET via $IPGW" >&2 $LOGGER -- "Setting up source routing on $IFACE: from $IPADDR -> route $IPNET via $IPGW" if ! ip $IPFLAG route show table $RTTABLE | grep -q default # Once only then if test "$VERBOSITY" = 1 then - $LOGGER -- ip $IPFLAG route add $IPNET dev "$IFACE" scope link table $RTTABLE - $LOGGER -- ip $IPFLAG route add default via "$IPGW" dev "$IFACE" table $RTTABLE + $LOGGER -p user.debug -- ip $IPFLAG route add $IPNET dev "$IFACE" scope link table $RTTABLE + $LOGGER -p user.debug -- ip $IPFLAG route add default via "$IPGW" dev "$IFACE" table $RTTABLE fi ip $IPFLAG route add $IPNET dev "$IFACE" scope link table $RTTABLE ip $IPFLAG route add default via "$IPGW" dev "$IFACE" table $RTTABLE @@ -107,7 +101,7 @@ if ! ip $IPFLAG rule show | grep -q $RTTABLE # Once only then if test "$VERBOSITY" = 1 then - $LOGGER -- ip $IPFLAG rule add from $IPADDR table $RTTABLE + $LOGGER -p user.debug -- ip $IPFLAG rule add from $IPADDR table $RTTABLE fi ip $IPFLAG rule add from $IPADDR table $RTTABLE fi