#!/bin/sh #---------------------------------------------------------------------------- # /etc/ppp/addrv6-down - called whenever a circuit loses a local IPv6 address # # Input: # $1 = network interface # $2 = circuit identifier # $3 = local IPv6 address # $4 = if non-empty, we are called from within ipv6-down # # Last Update: $Id$ #---------------------------------------------------------------------------- . /etc/boot.d/forking.inc . /etc/boot.d/lazy.inc . /etc/boot.d/locking.inc . /etc/boot.d/networking.inc script_name="$(basename $0)" script="$script_name[$$]" facility=$circuit_logfacility logmsgprio=$facility.notice . /usr/share/logfunc.sh export PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin interface=$1 circ_id=$2 address=$3 ipdown=$4 { fork_call_handlers sync_lock_resource addrv6updown-$circ_id "$script" echo "$circ_id[$interface]: IPv6 address $address has disappeared" is_default_route=no circuit_read_field $circ_id circ_nets_ipv6_n for i in $(seq 1 $circ_nets_ipv6_n) do circuit_read_field $circ_id circ_nets_ipv6_$i net if [ "$net" = "::/0" ] then is_default_route=yes break fi done if [ "$is_default_route" = yes ] then # a local address connected to a gateway is assumed to be externally # visible, so remove it from dynamic.ipv6 regex=$(echo $address | sed 's/\./\\./g;s,/,\\/,g') sync_lock_resource dynamic.ipv6 addrv6-down sed -i "/^$regex$/d" /var/run/dynamic.ipv6 [ -s /var/run/dynamic.ipv6 ] || rm -f /var/run/dynamic.ipv6 sync_unlock_resource dynamic.ipv6 addrv6-down fi circuit_deregister_local_address $circ_id ipv6 $address setup-dynamic-ip6tables.sh # Call all custom addrv6-downs lazy_begin for j in /etc/ppp/addrv6-down[0-9][0-9][0-9].* do if [ -f $j ] then echo "executing $j" . $j fi done lazy_end cur_addresses=$(circuit_get_local_addresses $circ_id ipv6) if [ -z "$cur_addresses" -a -z "$ipdown" ] then # call ipv6-down when the last address is about to disappear /etc/ppp/ipv6-down $interface /dev/null 0 $address "" $circ_id 1 & fi sync_unlock_resource addrv6updown-$circ_id "$script" } 2>&1 | logmsg "$script" $logmsgprio