]> git.lizzy.rs Git - plan9front.git/commitdiff
ipv6 autoconfiguration on ethernet
authorcinap_lenrek <cinap_lenrek@felloff.net>
Wed, 15 Aug 2018 19:39:30 +0000 (21:39 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Wed, 15 Aug 2018 19:39:30 +0000 (21:39 +0200)
for ip autoconfiguration, setup ipv6 link local addresses
and do SLAAC in parallel to DHCP.

rc/bin/cpurc
rc/bin/inst/configether
rc/bin/inst/ndbsetup
rc/bin/inst/startether
rc/bin/termrc
sys/src/9/boot/net.rc

index 404f494ff2539d09609f79a8fce8fce4988eef91..f1d4dfd996c4f07abc7c4a9f628d129c3009cbbc 100755 (executable)
@@ -62,9 +62,13 @@ if(test -r /net/ipselftab){
                                addr=`{cat $ether/addr}
                                switch($addr){
                                case $addrs
-                                       # try /lib/ndb first, then do dhcp
-                                       ip/ipconfig -N ether $ether >[2]/dev/null \
-                                       || ip/ipconfig -h $sysname ether $ether
+                                       # try /lib/ndb first, then do dhcp/slaac
+                                       ip/ipconfig -6 ether $ether
+                                       ip/ipconfig -N ether $ether >[2]/dev/null || @{
+                                               ip/ipconfig ether $ether ra6 recvra 1 &
+                                               ip/ipconfig -h $sysname ether $ether &
+                                               wait
+                                       }
                                }
                        }
                }
index f61d464c417fbed221c4ae1b5896765cf72883f0..d3568c18d3c71f06a8f8002fb1664cfd89e93d75 100755 (executable)
@@ -8,10 +8,10 @@ case go
        echo 'Please choose a method for configuring your ethernet connection.'
        echo
        echo '  manual - specify IP address, network mask, gateway IP address'
-       echo '  dhcp - use DHCP to automatically configure'
+       echo '  automatic - use DHCP and SLAAC to automatically configure'
        echo
        
-       prompt -d dhcp 'Configuration method' manual dhcp
+       prompt -d automatic 'Configuration method' manual automatic
        ethermethod=$rd
        gwaddr=xxx
        ipaddr=xxx
@@ -26,11 +26,11 @@ case go
                        export DNSSERVER
                }
        }
-       export ethermethod gwaddr ipaddr ipmask dhcphost
+       export ethermethod gwaddr ipaddr ipmask
        exec ./startether go
 
 case checkdone
-       if(! ~ $ethermethod manual dhcp) {
+       if(! ~ $ethermethod manual automatic) {
                configether=notdone
                export configether
        }
index 8c72076ef1c062e1965f9c80eeb084575df06e96..076793d539113970cf813b22f8422dc2ee0c6d7a 100755 (executable)
@@ -7,7 +7,7 @@ etheraddr=`{cat $netdev/addr >[2]/dev/null}
 
 switch($1){
 case checkready checkdone
-       if(~ $#etheraddr 1 && ~ $netisfrom ether && ~ $ethermethod dhcp manual && \
+       if(~ $#etheraddr 1 && ~ $netisfrom ether && ~ $ethermethod automatic manual && \
           ! grep -s $etheraddr /n/newfs/lib/ndb/local)
                ndbsetup=ready
        if not
@@ -33,7 +33,7 @@ case go
 
                echo
                switch($ethermethod){
-               case dhcp
+               case automatic
                        echo $se
                case manual
                        echo $se 'ip='^$ipaddr 'ipmask='^$ipmask 'ipgw='^$gwaddr
index cb38e6dbd0852e9344d80733ec3a8728c2ebb7b0..7544378edfb98c2417c837d3627318295c60c643 100755 (executable)
@@ -15,11 +15,16 @@ case go
                exit
 
        log starting ethernet $ethermethod config
+       ip/ipconfig -6
        switch($ethermethod) {
        case manual
                ip/ipconfig -g $gwaddr ether $netdev $ipaddr $ipmask >>[2]/srv/log
-       case dhcp
-               ip/ipconfig >>[2]/srv/log
+       case automatic
+               >>[2]/srv/log @{
+                       ip/ipconfig ra6 recva 1 &
+                       ip/ipconfig &
+                       wait
+               }
        }
 
 case checkdone
index f160915e6cae53771da5be606c95754c77966d40..656b6a77f51887987aa6130624484d5bf6742281 100755 (executable)
@@ -63,9 +63,13 @@ if(test -r /net/ipselftab){
                                addr=`{cat $ether/addr}
                                switch($addr){
                                case $addrs
-                                       # try /lib/ndb first, then do dhcp
-                                       ip/ipconfig -N ether $ether >[2]/dev/null \
-                                       || ip/ipconfig -h $sysname ether $ether
+                                       # try /lib/ndb first, then do dhcp/slaac
+                                       ip/ipconfig -6 ether $ether
+                                       ip/ipconfig -N ether $ether >[2]/dev/null || @{
+                                               ip/ipconfig ether $ether ra6 recvra 1 &
+                                               ip/ipconfig -h $sysname ether $ether &
+                                               wait
+                                       }
                                }
                        }
                }
index 27458081a367e64d3b0beae8b4c97b4a3ae97f3d..79c0b81fa513729a68f62dc32500bedda5a09c00 100755 (executable)
@@ -15,7 +15,16 @@ fn confignet{
                }
        }
 
-       must ip/ipconfig -p $*
+       if(~ $1 ether && ~ $#* 2) @{
+               ip/ipconfig -6 $*
+               ip/ipconfig $* ra6 recvra 1 &
+               ip/ipconfig -p $* &
+               wait
+       }
+       if not {
+               ip/ipconfig -p $*
+       }
+
        if(~ $#fs 0)
                fs=`{awk -F'=' '/^[     ]*fs=/{print $2}' /net/ndb}
        if(~ $#auth 0)
@@ -33,13 +42,13 @@ fn confignet{
                }
        }
 
-       # set bootstrap authservers for factotum
-       if(! ~ $#auth 0){
-               grep -v '^[     ]*auth=' /net/ndb >/env/x
-               cat /env/x <{echo '     auth='^$auth^'
-'} >/net/ndb
-               rm /env/x
-       }
+       # publish info in /net/ndb for factotum
+       >> /net/ndb {
+               echo
+               echo 'ipbootinfo='
+               for(i in $fs)   echo '  fs='^$i
+               for(i in $auth) echo '  auth='^$i
+       } 
 }
 
 fn connecttcp{