From 880f57a01be85285a1ded0c5a335bf31f61cc0b9 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Sat, 2 Apr 2005 13:02:53 +0000 Subject: Initial IPv6 install/upgrade support. ok deraadt@ --- distrib/miniroot/install.sub | 122 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 11 deletions(-) (limited to 'distrib/miniroot') diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 4ac41b987a3..e39f2d5260b 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,4 +1,4 @@ -# $OpenBSD: install.sub,v 1.368 2005/03/27 15:13:50 krw Exp $ +# $OpenBSD: install.sub,v 1.369 2005/04/02 13:02:52 krw Exp $ # $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1997-2005 Todd Miller, Theo de Raadt, Ken Westerback @@ -462,14 +462,16 @@ makedev() { } # Create an entry in the hosts file. If an entry with the -# same symbolic name already exists, delete it. -# $1 - IP address +# same symbolic name and address family already exists, delete it. +# $1 - IP address (v6 if it contains ':', else v4) # $2 - symbolic name addhostent() { - sed "/ $2\$/d" /tmp/hosts > /tmp/hosts.new + local _addr=$1 _name=$2 + + sed "/^[0-9a-fA-F]*[:.].* $_name\$/d" /tmp/hosts >/tmp/hosts.new mv /tmp/hosts.new /tmp/hosts - echo "$1 $2" >> /tmp/hosts + echo "$_addr $_name" >>/tmp/hosts } # Show list of available sets and let the user select which sets to install. @@ -567,6 +569,7 @@ __EOT rm -f $_hn v4_config "$_ifs" "$_media" "$_name" "$_hn" + v6_config "$_ifs" "$_media" "$_name" "$_hn" [[ -f $_hn ]] && _IFDEVS=$(rmel "$_ifs" $_IFDEVS) done @@ -583,6 +586,18 @@ v4_info() { /inet/s///p' } +# Obtain and output the inet6 information related to the given +# interface. Should output ' '. +# +# $1 == interface +v6_info() { + ifconfig $1 inet6 | sed -n ' + 1s/.* $_hn + echo "dhcp NONE NONE NONE $_media" >> $_hn fi ;; *) _addr=$resp @@ -670,6 +685,45 @@ v4_config() { esac } +v6_config() { + local _ifs=$1 _media=$2 _name=$3 _hn=$4 _addr _prefixlen _prompt + + ifconfig lo0 inet6 >/dev/null 2>&1 || return + + set -- $(v6_info $_ifs) + [[ -n $2 ]] && { _addr=$2; _prefixlen=$3; } + + [[ -x /sbin/rtsol ]] && _prompt="or 'rtsol' " + _prompt="IPv6 address for $_ifs? (${_prompt}or 'none')" + ask_until "$_prompt" "$_addr" + + case $resp in + none) return + ;; + rtsol) if [[ ! -x /sbin/rtsol ]]; then + echo "rtsol not possible - no /sbin/rtsol." + return + fi + ifconfig $_ifs up + rtsol -F $_ifs + addhostent "::1" "$_name" + echo "up\nrtsol $media" >>$_hn + return + ;; + esac + + _addr=$resp + ask_until "IPv6 prefix length for $_ifs?" "${_prefixlen:=64}" + ifconfig $_ifs inet6 $_addr prefixlen $resp up || return + echo "inet6 $_addr $resp $media" >>$_hn + addhostent "$_addr" "$_name" + + v6_defroute $_ifs + [[ $resp == none ]] && return + route -n add -inet6 -host default "$resp" || return + echo "!route -n add -host -inet6 default $resp" >>$_hn +} + v4_defroute() { local _dr _prompt=" or 'none'" @@ -689,6 +743,35 @@ v4_defroute() { done } +v6_defroute() { + local _if=$1 _routers _oifs + + if [[ -z $(route -n show -inet6 | sed -ne '/^default */{s///; s/ .*//; p;}') ]]; then + resp=none + return + fi + + if [[ -x /sbin/ping6 ]]; then + _routers=$(ping6 -n -c 2 ff02::2%$_if 2>&1 | sed -n \ + -e '/bytes from/{s/^.*from //;s/,.*$//;p;}') + fi + + _oifs=$IFS + IFS= + PS3="IPv6 default router? (list #, IPv6 address or 'none'): " + select i in $_routers; do + case $i in + "") resp=$REPLY + [[ -n $resp ]] && break + ;; + *) resp=$i + break + ;; + esac + done + IFS=$_oifs +} + # Much of this is gratuitously stolen from /etc/netstart. enable_network() { local _netfile @@ -729,9 +812,9 @@ enable_network() { # $af can be "dhcp", "up", "rtsol", an address family, commands, or # a comment. case $af in - "#"*|"!"*|"bridge"|""|"rtsol") + "#"*|"!"*|"bridge"|"") # skip comments, user commands, bridges, - # IPv6 rtsol and empty lines + # and empty lines continue ;; "dhcp") [ "$name" = "NONE" ] && name= @@ -740,6 +823,11 @@ enable_network() { ifconfig $if $name $mask $bcaddr $ext1 $ext2 down cmd="dhclient $if" ;; + "rtsol") + ifconfig $if $name $mask $bcaddr $ext1 $ext2 up + rtsif="$rtsif $if" + cmd= + ;; "up") # The only one of these guaranteed to be set is $if # the remaining ones exist so that media controls work @@ -777,8 +865,8 @@ enable_network() { [ "$alias" ] && rtcmd="; route -qn add -host $name 127.0.0.1" ;; inet6) - # Ignore IPv6 setup - continue + [ "$mask" ] && cmd="$cmd prefixlen $mask" + cmd="$cmd $bcaddr" ;; *) cmd="$cmd $mask $bcaddr" esac @@ -789,6 +877,8 @@ enable_network() { done /tmp/sysctl.conf + /mnt/etc/sysctl.conf >/tmp/sysctl.conf + cp /tmp/sysctl.conf /mnt/etc/sysctl.conf fi fi @@ -1514,6 +1608,12 @@ finish_up() { done /tmp/sysctl.conf + cp /tmp/sysctl.conf /mnt/etc/sysctl.conf + fi + echo -n "Making all device nodes..." cd /mnt/dev sh MAKEDEV all -- cgit v1.2.3