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