xref: /netbsd-src/external/mpl/dhcp/dist/client/scripts/netbsd (revision 6fb29d29285c26a62fae51364e3aa9f51d403424)
1*6fb29d29Schristos#!/bin/sh
2*6fb29d29Schristos
3*6fb29d29Schristosmake_resolv_conf() {
4*6fb29d29Schristos  if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
5*6fb29d29Schristos    cat /dev/null > /etc/resolv.conf.dhclient
6*6fb29d29Schristos    if [ "x$new_domain_search" != x ]; then
7*6fb29d29Schristos      echo search $new_domain_search >> /etc/resolv.conf.dhclient
8*6fb29d29Schristos    elif [ "x$new_domain_name" != x ]; then
9*6fb29d29Schristos      # Note that the DHCP 'Domain Name Option' is really just a domain
10*6fb29d29Schristos      # name, and that this practice of using the domain name option as
11*6fb29d29Schristos      # a search path is both nonstandard and deprecated.
12*6fb29d29Schristos      echo search $new_domain_name >> /etc/resolv.conf.dhclient
13*6fb29d29Schristos    fi
14*6fb29d29Schristos    for nameserver in $new_domain_name_servers; do
15*6fb29d29Schristos      echo nameserver $nameserver >>/etc/resolv.conf.dhclient
16*6fb29d29Schristos    done
17*6fb29d29Schristos
18*6fb29d29Schristos    mv /etc/resolv.conf.dhclient /etc/resolv.conf
19*6fb29d29Schristos  elif [ "x${new_dhcp6_name_servers}" != x ] ; then
20*6fb29d29Schristos    cat /dev/null > /etc/resolv.conf.dhclient6
21*6fb29d29Schristos    chmod 644 /etc/resolv.conf.dhclient6
22*6fb29d29Schristos
23*6fb29d29Schristos    if [ "x${new_dhcp6_domain_search}" != x ] ; then
24*6fb29d29Schristos      echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
25*6fb29d29Schristos    fi
26*6fb29d29Schristos    for nameserver in ${new_dhcp6_name_servers} ; do
27*6fb29d29Schristos      # If the nameserver has a link-local address
28*6fb29d29Schristos      # add a <zone_id> (interface name) to it.
29*6fb29d29Schristos      case $nameserver in
30*6fb29d29Schristos	fe80:*) zone_id="%$interface";;
31*6fb29d29Schristos	FE80:*) zone_id="%$interface";;
32*6fb29d29Schristos	*)      zone_id="";;
33*6fb29d29Schristos      esac
34*6fb29d29Schristos      echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
35*6fb29d29Schristos    done
36*6fb29d29Schristos
37*6fb29d29Schristos    mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
38*6fb29d29Schristos  fi
39*6fb29d29Schristos}
40*6fb29d29Schristos
41*6fb29d29Schristos# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
42*6fb29d29Schristosexit_with_hooks() {
43*6fb29d29Schristos  exit_status=$1
44*6fb29d29Schristos  if [ -f /etc/dhclient-exit-hooks ]; then
45*6fb29d29Schristos    . /etc/dhclient-exit-hooks
46*6fb29d29Schristos  fi
47*6fb29d29Schristos# probably should do something with exit status of the local script
48*6fb29d29Schristos  exit $exit_status
49*6fb29d29Schristos}
50*6fb29d29Schristos
51*6fb29d29Schristos# This function was largely borrowed from dhclient-script that
52*6fb29d29Schristos# ships with Centos, authored by Jiri Popelka and David Cantrell
53*6fb29d29Schristos# of Redhat. Thanks guys.
54*6fb29d29Schristosadd_ipv6_addr_with_DAD() {
55*6fb29d29Schristos    ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} alias
56*6fb29d29Schristos
57*6fb29d29Schristos    if [ ${dad_wait_time} -le 0 ]
58*6fb29d29Schristos    then
59*6fb29d29Schristos        # if we're not waiting for DAD, assume we're good
60*6fb29d29Schristos        return 0
61*6fb29d29Schristos    fi
62*6fb29d29Schristos
63*6fb29d29Schristos    # Repeatedly test whether newly added address passed
64*6fb29d29Schristos    # duplicate address detection (DAD)
65*6fb29d29Schristos    for i in $(seq 1 ${dad_wait_time}); do
66*6fb29d29Schristos        sleep 1 # give the DAD some time
67*6fb29d29Schristos
68*6fb29d29Schristos        addr=$(ifconfig ${interface} \
69*6fb29d29Schristos            | grep "${new_ip6_address} prefixlen ${new_ip6_prefixlen}")
70*6fb29d29Schristos
71*6fb29d29Schristos        # tentative flag == DAD is still not complete
72*6fb29d29Schristos        tentative=$(echo "${addr}" | grep tentative)
73*6fb29d29Schristos        # dadfailed flag == address is already in use somewhere else
74*6fb29d29Schristos        dadfailed=$(echo "${addr}" | grep duplicated)
75*6fb29d29Schristos
76*6fb29d29Schristos        if [ -n "${dadfailed}" ] ; then
77*6fb29d29Schristos            # dad failed, remove the address
78*6fb29d29Schristos            ifconfig ${interface} inet6 ${new_ip6_address}/${new_ip6_prefixlen} -alias
79*6fb29d29Schristos            exit_with_hooks 3
80*6fb29d29Schristos        fi
81*6fb29d29Schristos
82*6fb29d29Schristos        if [ -z "${tentative}" ] ; then
83*6fb29d29Schristos            if [ -n "${addr}" ]; then
84*6fb29d29Schristos                # DAD is over
85*6fb29d29Schristos                return 0
86*6fb29d29Schristos            else
87*6fb29d29Schristos                # address was auto-removed (or not added at all)
88*6fb29d29Schristos                exit_with_hooks 3
89*6fb29d29Schristos            fi
90*6fb29d29Schristos        fi
91*6fb29d29Schristos    done
92*6fb29d29Schristos
93*6fb29d29Schristos    return 0
94*6fb29d29Schristos}
95*6fb29d29Schristos
96*6fb29d29Schristos# Invoke the local dhcp client enter hooks, if they exist.
97*6fb29d29Schristosif [ -f /etc/dhclient-enter-hooks ]; then
98*6fb29d29Schristos  exit_status=0
99*6fb29d29Schristos  . /etc/dhclient-enter-hooks
100*6fb29d29Schristos  # allow the local script to abort processing of this state
101*6fb29d29Schristos  # local script must set exit_status variable to nonzero.
102*6fb29d29Schristos  if [ $exit_status -ne 0 ]; then
103*6fb29d29Schristos    exit $exit_status
104*6fb29d29Schristos  fi
105*6fb29d29Schristosfi
106*6fb29d29Schristos
107*6fb29d29Schristosif [ x$new_network_number != x ]; then
108*6fb29d29Schristos   echo New Network Number: $new_network_number
109*6fb29d29Schristosfi
110*6fb29d29Schristos
111*6fb29d29Schristosif [ x$new_broadcast_address != x ]; then
112*6fb29d29Schristos echo New Broadcast Address: $new_broadcast_address
113*6fb29d29Schristos  new_broadcast_arg="broadcast $new_broadcast_address"
114*6fb29d29Schristosfi
115*6fb29d29Schristosif [ x$old_broadcast_address != x ]; then
116*6fb29d29Schristos  old_broadcast_arg="broadcast $old_broadcast_address"
117*6fb29d29Schristosfi
118*6fb29d29Schristosif [ x$new_subnet_mask != x ]; then
119*6fb29d29Schristos  new_netmask_arg="netmask $new_subnet_mask"
120*6fb29d29Schristosfi
121*6fb29d29Schristosif [ x$old_subnet_mask != x ]; then
122*6fb29d29Schristos  old_netmask_arg="netmask $old_subnet_mask"
123*6fb29d29Schristosfi
124*6fb29d29Schristosif [ x$alias_subnet_mask != x ]; then
125*6fb29d29Schristos  alias_subnet_arg="netmask $alias_subnet_mask"
126*6fb29d29Schristosfi
127*6fb29d29Schristos if [ x$new_interface_mtu != x ]; then
128*6fb29d29Schristos   mtu_arg="mtu $new_interface_mtu"
129*6fb29d29Schristos fi
130*6fb29d29Schristosif [ x$IF_METRIC != x ]; then
131*6fb29d29Schristos  metric_arg="metric $IF_METRIC"
132*6fb29d29Schristosfi
133*6fb29d29Schristos
134*6fb29d29Schristosif [ x$reason = xMEDIUM ]; then
135*6fb29d29Schristos  eval "ifconfig $interface $medium"
136*6fb29d29Schristos  eval "ifconfig $interface inet -alias 0.0.0.0 $medium" >/dev/null 2>&1
137*6fb29d29Schristos  sleep 1
138*6fb29d29Schristos  exit_with_hooks 0
139*6fb29d29Schristosfi
140*6fb29d29Schristos
141*6fb29d29Schristos###
142*6fb29d29Schristos### DHCPv4 Handlers
143*6fb29d29Schristos###
144*6fb29d29Schristos
145*6fb29d29Schristosif [ x$reason = xPREINIT ]; then
146*6fb29d29Schristos  if [ x$alias_ip_address != x ]; then
147*6fb29d29Schristos    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
148*6fb29d29Schristos    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
149*6fb29d29Schristos  fi
150*6fb29d29Schristos  ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
151*6fb29d29Schristos		broadcast 255.255.255.255 up
152*6fb29d29Schristos  exit_with_hooks 0
153*6fb29d29Schristosfi
154*6fb29d29Schristos
155*6fb29d29Schristosif [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
156*6fb29d29Schristos  exit_with_hooks 0
157*6fb29d29Schristosfi
158*6fb29d29Schristos
159*6fb29d29Schristosif [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
160*6fb29d29Schristos   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
161*6fb29d29Schristos  current_hostname=`hostname`
162*6fb29d29Schristos  if [ x$current_hostname = x ] || \
163*6fb29d29Schristos     [ x$current_hostname = x$old_host_name ]; then
164*6fb29d29Schristos    if [ x$current_hostname = x ] || \
165*6fb29d29Schristos       [ x$new_host_name != x$old_host_name ]; then
166*6fb29d29Schristos      hostname $new_host_name
167*6fb29d29Schristos    fi
168*6fb29d29Schristos  fi
169*6fb29d29Schristos
170*6fb29d29Schristos  if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
171*6fb29d29Schristos		[ x$alias_ip_address != x$old_ip_address ]; then
172*6fb29d29Schristos    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
173*6fb29d29Schristos    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
174*6fb29d29Schristos  fi
175*6fb29d29Schristos  if [ x$old_ip_address != x ] && [ x$old_ip_address != x$new_ip_address ]
176*6fb29d29Schristos   then
177*6fb29d29Schristos    eval "ifconfig $interface inet -alias $old_ip_address $medium"
178*6fb29d29Schristos    route delete $old_ip_address 127.1 >/dev/null 2>&1
179*6fb29d29Schristos    for router in $old_routers; do
180*6fb29d29Schristos      route delete default $router >/dev/null 2>&1
181*6fb29d29Schristos    done
182*6fb29d29Schristos    if [ "$old_static_routes" != "" ]; then
183*6fb29d29Schristos      set $old_static_routes
184*6fb29d29Schristos      while [ $# -gt 1 ]; do
185*6fb29d29Schristos	route delete $1 $2
186*6fb29d29Schristos	shift; shift
187*6fb29d29Schristos      done
188*6fb29d29Schristos    fi
189*6fb29d29Schristos    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' |sh
190*6fb29d29Schristos  fi
191*6fb29d29Schristos  if [ x$old_ip_address = x ] || [ x$old_ip_address != x$new_ip_address ] || \
192*6fb29d29Schristos     [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
193*6fb29d29Schristos    eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
194*6fb29d29Schristos			$new_broadcast_arg $mtu_arg $metric_arg $medium"
195*6fb29d29Schristos    route add $new_ip_address 127.1 >/dev/null 2>&1
196*6fb29d29Schristos    for router in $new_routers; do
197*6fb29d29Schristos      route add default $router >/dev/null 2>&1
198*6fb29d29Schristos    done
199*6fb29d29Schristos    if [ "$new_static_routes" != "" ]; then
200*6fb29d29Schristos      set $new_static_routes
201*6fb29d29Schristos      while [ $# -gt 1 ]; do
202*6fb29d29Schristos	route add $1 $2
203*6fb29d29Schristos	shift; shift
204*6fb29d29Schristos      done
205*6fb29d29Schristos    fi
206*6fb29d29Schristos  else
207*6fb29d29Schristos    # we haven't changed the address, have we changed other options
208*6fb29d29Schristos    # that we wish to update?
209*6fb29d29Schristos    if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
210*6fb29d29Schristos      # if we've changed routers delete the old and add the new.
211*6fb29d29Schristos      $LOGGER "New Routers: $new_routers"
212*6fb29d29Schristos      for router in $old_routers; do
213*6fb29d29Schristos        route delete default $router >/dev/null 2>&1
214*6fb29d29Schristos      done
215*6fb29d29Schristos      for router in $new_routers; do
216*6fb29d29Schristos        route add default $router >/dev/null 2>&1
217*6fb29d29Schristos      done
218*6fb29d29Schristos    fi
219*6fb29d29Schristos  fi
220*6fb29d29Schristos  if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
221*6fb29d29Schristos   then
222*6fb29d29Schristos    ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
223*6fb29d29Schristos    route add $alias_ip_address 127.0.0.1
224*6fb29d29Schristos  fi
225*6fb29d29Schristos  make_resolv_conf
226*6fb29d29Schristos  exit_with_hooks 0
227*6fb29d29Schristosfi
228*6fb29d29Schristos
229*6fb29d29Schristosif [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xRELEASE ] \
230*6fb29d29Schristos   || [ x$reason = xSTOP ]; then
231*6fb29d29Schristos  if [ x$alias_ip_address != x ]; then
232*6fb29d29Schristos    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
233*6fb29d29Schristos    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
234*6fb29d29Schristos  fi
235*6fb29d29Schristos  if [ x$old_ip_address != x ]; then
236*6fb29d29Schristos    eval "ifconfig $interface inet -alias $old_ip_address $medium"
237*6fb29d29Schristos    route delete $old_ip_address 127.1 >/dev/null 2>&1
238*6fb29d29Schristos    for router in $old_routers; do
239*6fb29d29Schristos      route delete default $router >/dev/null 2>&1
240*6fb29d29Schristos    done
241*6fb29d29Schristos    if [ "$old_static_routes" != "" ]; then
242*6fb29d29Schristos      set $old_static_routes
243*6fb29d29Schristos      while [ $# -gt 1 ]; do
244*6fb29d29Schristos	route delete $1 $2
245*6fb29d29Schristos	shift; shift
246*6fb29d29Schristos      done
247*6fb29d29Schristos    fi
248*6fb29d29Schristos    arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
249*6fb29d29Schristos						|sh >/dev/null 2>&1
250*6fb29d29Schristos  fi
251*6fb29d29Schristos  if [ x$alias_ip_address != x ]; then
252*6fb29d29Schristos    ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
253*6fb29d29Schristos    route add $alias_ip_address 127.0.0.1
254*6fb29d29Schristos  fi
255*6fb29d29Schristos  exit_with_hooks 0
256*6fb29d29Schristosfi
257*6fb29d29Schristos
258*6fb29d29Schristosif [ x$reason = xTIMEOUT ]; then
259*6fb29d29Schristos  if [ x$alias_ip_address != x ]; then
260*6fb29d29Schristos    ifconfig $interface inet -alias $alias_ip_address > /dev/null 2>&1
261*6fb29d29Schristos    route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
262*6fb29d29Schristos  fi
263*6fb29d29Schristos  eval "ifconfig $interface inet $new_ip_address $new_netmask_arg \
264*6fb29d29Schristos			$new_broadcast_arg $mtu_arg $metric_arg $medium"
265*6fb29d29Schristos  sleep 1
266*6fb29d29Schristos  if [ "$new_routers" != "" ]; then
267*6fb29d29Schristos    set $new_routers
268*6fb29d29Schristos    if ping -q -c 1 -w 1 $1; then
269*6fb29d29Schristos      if [ x$new_ip_address != x$alias_ip_address ] && \
270*6fb29d29Schristos			[ x$alias_ip_address != x ]; then
271*6fb29d29Schristos	ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
272*6fb29d29Schristos	route add $alias_ip_address 127.0.0.1
273*6fb29d29Schristos      fi
274*6fb29d29Schristos      route add $new_ip_address 127.1 >/dev/null 2>&1
275*6fb29d29Schristos      for router in $new_routers; do
276*6fb29d29Schristos	route add default $router >/dev/null 2>&1
277*6fb29d29Schristos      done
278*6fb29d29Schristos      set $new_static_routes
279*6fb29d29Schristos      while [ $# -gt 1 ]; do
280*6fb29d29Schristos	route add $0 $1
281*6fb29d29Schristos	shift; shift
282*6fb29d29Schristos      done
283*6fb29d29Schristos      make_resolv_conf
284*6fb29d29Schristos      exit_with_hooks 0
285*6fb29d29Schristos    fi
286*6fb29d29Schristos  fi
287*6fb29d29Schristos  eval "ifconfig $interface inet -alias $new_ip_address $medium"
288*6fb29d29Schristos  for router in $old_routers; do
289*6fb29d29Schristos    route delete default $router >/dev/null 2>&1
290*6fb29d29Schristos  done
291*6fb29d29Schristos  if [ "$old_static_routes" != "" ]; then
292*6fb29d29Schristos    set $old_static_routes
293*6fb29d29Schristos    while [ $# -gt 1 ]; do
294*6fb29d29Schristos      route delete $1 $2
295*6fb29d29Schristos      shift; shift
296*6fb29d29Schristos    done
297*6fb29d29Schristos  fi
298*6fb29d29Schristos  arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -n -d \1/p' \
299*6fb29d29Schristos							|sh >/dev/null 2>&1
300*6fb29d29Schristos  exit_with_hooks 1
301*6fb29d29Schristosfi
302*6fb29d29Schristos
303*6fb29d29Schristos###
304*6fb29d29Schristos### DHCPv6 Handlers
305*6fb29d29Schristos###
306*6fb29d29Schristos
307*6fb29d29Schristosif [ ${reason} = PREINIT6 ] ; then
308*6fb29d29Schristos  # Ensure interface is up.
309*6fb29d29Schristos  ifconfig ${interface} up
310*6fb29d29Schristos
311*6fb29d29Schristos  # XXX: Remove any stale addresses from aborted clients.
312*6fb29d29Schristos
313*6fb29d29Schristos  # We need to give the kernel some time to active interface
314*6fb29d29Schristos  interface_up_wait_time=5
315*6fb29d29Schristos  for i in $(seq 0 ${interface_up_wait_time})
316*6fb29d29Schristos  do
317*6fb29d29Schristos      ifconfig ${interface} | grep inactive >/dev/null 2>&1
318*6fb29d29Schristos      if [ $? -ne 0 ]; then
319*6fb29d29Schristos          break;
320*6fb29d29Schristos      fi
321*6fb29d29Schristos      sleep 1
322*6fb29d29Schristos  done
323*6fb29d29Schristos
324*6fb29d29Schristos  # Wait for duplicate address detection for this interface if the
325*6fb29d29Schristos  # --dad-wait-time parameter has been specified and is greater than
326*6fb29d29Schristos  # zero.
327*6fb29d29Schristos  if [ ${dad_wait_time} -gt 0 ]; then
328*6fb29d29Schristos      # Check if any IPv6 address on this interface is marked as
329*6fb29d29Schristos      # tentative.
330*6fb29d29Schristos      ifconfig ${interface} | grep inet6 | grep tentative \
331*6fb29d29Schristos          >/dev/null 2>&1
332*6fb29d29Schristos      if [ $? -eq 0 ]; then
333*6fb29d29Schristos          # Wait for duplicate address detection to complete or for
334*6fb29d29Schristos          # the timeout specified as --dad-wait-time.
335*6fb29d29Schristos          for i in $(seq 0 $dad_wait_time)
336*6fb29d29Schristos          do
337*6fb29d29Schristos              # We're going to poll for the tentative flag every second.
338*6fb29d29Schristos              sleep 1
339*6fb29d29Schristos              ifconfig ${interface} | grep inet6 | grep tentative \
340*6fb29d29Schristos                  >/dev/null 2>&1
341*6fb29d29Schristos              if [ $? -ne 0 ]; then
342*6fb29d29Schristos                  break;
343*6fb29d29Schristos              fi
344*6fb29d29Schristos          done
345*6fb29d29Schristos      fi
346*6fb29d29Schristos  fi
347*6fb29d29Schristos
348*6fb29d29Schristos  exit_with_hooks 0
349*6fb29d29Schristosfi
350*6fb29d29Schristos
351*6fb29d29Schristosif [ x${old_ip6_prefix} != x ] || [ x${new_ip6_prefix} != x ] ; then
352*6fb29d29Schristos    echo Prefix ${reason} old=${old_ip6_prefix} new=${new_ip6_prefix}
353*6fb29d29Schristos
354*6fb29d29Schristos    exit_with_hooks 0
355*6fb29d29Schristosfi
356*6fb29d29Schristos
357*6fb29d29Schristosif [ ${reason} = BOUND6 ] ; then
358*6fb29d29Schristos  if [ x${new_ip6_address} = x ] || [ x${new_ip6_prefixlen} = x ] ; then
359*6fb29d29Schristos    exit_with_hooks 2;
360*6fb29d29Schristos  fi
361*6fb29d29Schristos
362*6fb29d29Schristos  # Add address to interface, check for DAD if dad_wait_time > 0
363*6fb29d29Schristos  add_ipv6_addr_with_DAD
364*6fb29d29Schristos
365*6fb29d29Schristos  # Check for nameserver options.
366*6fb29d29Schristos  make_resolv_conf
367*6fb29d29Schristos
368*6fb29d29Schristos  exit_with_hooks 0
369*6fb29d29Schristosfi
370*6fb29d29Schristos
371*6fb29d29Schristosif [ ${reason} = RENEW6 ] || [ ${reason} = REBIND6 ] ; then
372*6fb29d29Schristos  # Make sure nothing has moved around on us.
373*6fb29d29Schristos
374*6fb29d29Schristos  # Nameservers/domains/etc.
375*6fb29d29Schristos  if [ "x${new_dhcp6_name_servers}" != "x${old_dhcp6_name_servers}" ] ||
376*6fb29d29Schristos     [ "x${new_dhcp6_domain_search}" != "x${old_dhcp6_domain_search}" ] ; then
377*6fb29d29Schristos    make_resolv_conf
378*6fb29d29Schristos  fi
379*6fb29d29Schristos
380*6fb29d29Schristos  exit_with_hooks 0
381*6fb29d29Schristosfi
382*6fb29d29Schristos
383*6fb29d29Schristosif [ ${reason} = DEPREF6 ] ; then
384*6fb29d29Schristos  if [ x${new_ip6_prefixlen} = x ] ; then
385*6fb29d29Schristos    exit_with_hooks 2;
386*6fb29d29Schristos  fi
387*6fb29d29Schristos
388*6fb29d29Schristos  # XXX:
389*6fb29d29Schristos  # There doesn't appear to be a way to update an addr to indicate
390*6fb29d29Schristos  # preference.
391*6fb29d29Schristos
392*6fb29d29Schristos  exit_with_hooks 0
393*6fb29d29Schristosfi
394*6fb29d29Schristos
395*6fb29d29Schristosif [ ${reason} = EXPIRE6 -o ${reason} = RELEASE6 -o ${reason} = STOP6 ] ; then
396*6fb29d29Schristos  if [ x${old_ip6_address} = x ] || [ x${old_ip6_prefixlen} = x ] ; then
397*6fb29d29Schristos    exit_with_hooks 2;
398*6fb29d29Schristos  fi
399*6fb29d29Schristos
400*6fb29d29Schristos  ifconfig ${interface} inet6 -alias ${old_ip6_address}/${old_ip6_prefixlen}
401*6fb29d29Schristos
402*6fb29d29Schristos  exit_with_hooks 0
403*6fb29d29Schristosfi
404*6fb29d29Schristos
405*6fb29d29Schristosexit_with_hooks 0
406