diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2010-04-04 22:53:51 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2010-04-04 22:53:51 +0000 |
commit | 12c344d5ee0ed4e7bcce996cce7d8b1295b6cfa8 (patch) | |
tree | d17ca16369a35e4f36430340a50e87bf1b75501c /sbin/dhclient | |
parent | cb146c4e1e0343ccf994ef3be07d0ccf965c2972 (diff) |
Add some ipv6 hooks the isc code expects for dhcpv6.
ok krw@ ramdisks checked by deraadt@
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dhclient-script | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/sbin/dhclient/dhclient-script b/sbin/dhclient/dhclient-script index dbaa5fa93e9..adc1212be75 100644 --- a/sbin/dhclient/dhclient-script +++ b/sbin/dhclient/dhclient-script @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: dhclient-script,v 1.15 2009/06/03 05:12:51 claudio Exp $ +# $OpenBSD: dhclient-script,v 1.16 2010/04/04 22:53:50 jsg Exp $ # # Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org> # @@ -28,6 +28,12 @@ delete_old_address() { fi } +ip6_delete_old_address() { + if [ -n "$old_ip6_address" ]; then + ifconfig $interface inet6 $old_ip6_address delete $medium + fi +} + add_new_address() { ifconfig $interface \ inet $new_ip_address \ @@ -39,6 +45,13 @@ add_new_address() { route add $new_ip_address 127.0.0.1 >/dev/null 2>&1 } +ip6_add_new_address() { + ifconfig $interface \ + inet6 $new_ip6_address \ + prefixlen $new_ip6_prefixlen \ + $medium +} + delete_old_alias() { if [ -n "$alias_ip_address" ]; then ifconfig $interface \ @@ -135,6 +148,47 @@ add_new_resolv_conf() { return 1 } +ip6_add_new_resolv_conf() { + # Create resolv.conf when either $new_dhcp6_name_servers or + # $new_dhcp6_domain_search are provided. + + rm -f /etc/resolv.conf.std6 + + if [ -n "$new_dhcp6_domain_search" ]; then + echo "search $new_dhcp6_domain_search" >>/etc/resolv.conf.std6 + fi + + if [ -n "$new_dhcp6_name_servers" ]; then + for nameserver in $new_dhcp6_name_servers; do + echo "nameserver $nameserver" >>/etc/resolv.conf.std6 + done + fi + + if [ -f /etc/resolv.conf.std6 ]; then + if [ -f /etc/resolv.conf.tail ]; then + cat /etc/resolv.conf.tail >>/etc/resolv.conf.std6 + fi + + # In case (e.g. during OpenBSD installs) /etc/resolv.conf + # is a symbolic link, take care to preserve the link and write + # the new data in the correct location. + + if [ -f /etc/resolv.conf ]; then + cat /etc/resolv.conf > /etc/resolv.conf.save + fi + cat /etc/resolv.conf.std6 > /etc/resolv.conf + rm -f /etc/resolv.conf.std6 + + # Try to ensure correct ownership and permissions. + chown -RL root:wheel /etc/resolv.conf + chmod -RL 644 /etc/resolv.conf + + return 0 + fi + + return 1 +} + # # Start of active code. # @@ -150,6 +204,10 @@ PREINIT) ifconfig $interface up ;; +PREINIT6) + ifconfig $interface up + ;; + ARPCHECK|ARPSEND) ;; @@ -176,6 +234,20 @@ BOUND|RENEW|REBIND|REBOOT) add_new_resolv_conf ;; +BOUND6|RENEW6|REBIND6) + if [ -n "$old_ip6_address" ]; then + if [ "$old_ip6_address" != "$new_ip6_address" ]; then + ip6_delete_old_address + fi + fi + if [ "$reason" = BOUND6 ] || + [ -z "$old_ip6_address" ] || + [ "$old_ip6_address" != "$new_ip6_address" ]; then + ip6_add_new_address + fi + ip6_add_new_resolv_conf + ;; + EXPIRE|FAIL) delete_old_alias if [ -n "$old_ip_address" ]; then @@ -189,6 +261,12 @@ EXPIRE|FAIL) fi ;; +EXPIRE6|RELEASE6|STOP6) + if [ -n "$old_ip6_address" ]; then + ip6_delete_old_address + fi + ;; + TIMEOUT) delete_old_alias add_new_address |