From 3ffbe35a2030822e1877c17c9da4f12db4176cf7 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 1 May 2018 23:46:57 +0200 Subject: termrc: put #u in front for endpoint renaming to be effective, handle multipe ether= tuples in ndb --- rc/bin/cpurc | 27 +++++++++++++++++---------- rc/bin/termrc | 19 +++++++++++++------ 2 files changed, 30 insertions(+), 16 deletions(-) (limited to 'rc/bin') diff --git a/rc/bin/cpurc b/rc/bin/cpurc index a410d3dcb..31caf33a2 100755 --- a/rc/bin/cpurc +++ b/rc/bin/cpurc @@ -5,7 +5,7 @@ NPROC=`{wc -l /dev/null >[2=1] rm -f /env/i @@ -56,12 +56,19 @@ if(test -e /cfg/$sysname/cpurc) # automatic ip address setup if(test -r /net/ipselftab){ if(! grep u /net/ipselftab | grep -sv 127.0.0.1){ - ether=`{ndb/query sys $sysname ether} - if(~ $#ether 1){ - # try /lib/ndb first, then do dhcp - ip/ipconfig -N >[2]/dev/null || ip/ipconfig -h $sysname + addrs=`{ndb/query -a sys $sysname ether} + if(! ~ $#addrs 0){ + for(ether in /net/ether*){ + 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 ether $ether -h $sysname + } + } } - rm -f /env/ether + rm -f /env/ether /env/addrs /env/addr } } @@ -77,16 +84,16 @@ if(! ps|grep -s timesync){ sleep 2 } -if(~ $#auth 0){ - auth=`{ndb/query sys $sysname auth} - . <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'} -} if(test -d /cfg/$sysname/service) serviced=/cfg/$sysname/service if not if(test -d /cfg/default/service) serviced=/cfg/default/service if not serviced=/rc/bin/service +if(~ $#auth 0){ + auth=`{ndb/query sys $sysname auth} + . <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'} +} switch($auth){ case `{ echo $sysname; ndb/query sys $sysname dom if(test -r /net/ipselftab){ diff --git a/rc/bin/termrc b/rc/bin/termrc index dfc99968b..092137564 100755 --- a/rc/bin/termrc +++ b/rc/bin/termrc @@ -6,7 +6,7 @@ TIMESYNCARGS=(-rLa1000000) NPROC=`{wc -l /dev/null >[2=1] rm -f /env/i @@ -57,12 +57,19 @@ if(test -e /cfg/$sysname/termrc) # automatic ip address setup if(test -r /net/ipselftab){ if(! grep u /net/ipselftab | grep -sv 127.0.0.1){ - ether=`{ndb/query sys $sysname ether} - if(~ $#ether 1){ - # try /lib/ndb first, then do dhcp - ip/ipconfig -N >[2]/dev/null || ip/ipconfig -h $sysname + addrs=`{ndb/query -a sys $sysname ether} + if(! ~ $#addrs 0){ + for(ether in /net/ether*){ + 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 ether $ether -h $sysname + } + } } - rm -f /env/ether + rm -f /env/ether /env/addrs /env/addr } } -- cgit v1.2.3 From cedf916289e96e653160cdfc4c50a3760df4e44b Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 2 May 2018 00:03:24 +0200 Subject: termrc: fix mistake --- rc/bin/cpurc | 2 +- rc/bin/termrc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'rc/bin') diff --git a/rc/bin/cpurc b/rc/bin/cpurc index 31caf33a2..404f494ff 100755 --- a/rc/bin/cpurc +++ b/rc/bin/cpurc @@ -64,7 +64,7 @@ if(test -r /net/ipselftab){ case $addrs # try /lib/ndb first, then do dhcp ip/ipconfig -N ether $ether >[2]/dev/null \ - || ip/ipconfig ether $ether -h $sysname + || ip/ipconfig -h $sysname ether $ether } } } diff --git a/rc/bin/termrc b/rc/bin/termrc index 092137564..f160915e6 100755 --- a/rc/bin/termrc +++ b/rc/bin/termrc @@ -65,7 +65,7 @@ if(test -r /net/ipselftab){ case $addrs # try /lib/ndb first, then do dhcp ip/ipconfig -N ether $ether >[2]/dev/null \ - || ip/ipconfig ether $ether -h $sysname + || ip/ipconfig -h $sysname ether $ether } } } -- cgit v1.2.3 From 0c7a3ad1c9864a62174129bcd4adeef6c9dfac16 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 2 May 2018 20:29:29 +0200 Subject: remove ipv6on, update ipconfig(8) --- rc/bin/ipv6on | 104 ----------------------------------------------------- sys/man/8/ipconfig | 46 ++++++++---------------- 2 files changed, 15 insertions(+), 135 deletions(-) delete mode 100755 rc/bin/ipv6on (limited to 'rc/bin') diff --git a/rc/bin/ipv6on b/rc/bin/ipv6on deleted file mode 100755 index 703feed76..000000000 --- a/rc/bin/ipv6on +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/rc -# ipv6on [netdir ndbfile [gwv4]] - configure an interface for ipv6, -# once ipv4 is configured. -if (! ~ $#* 0 2 3) { - echo usage: $0 '[netdir ndbfile [gw-v4-name]]' >[1=2] - exit usage -} -rfork e -if (~ $#* 0) { - netdir=/net - ndbf=/lib/ndb/local - gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'} -} -if not { - netdir=$1 - ndbf=$2 - if (~ $#* 2) - # gw=() - gw=`{ndb/ipquery sys $sysname ipgw | sed 's/ipgw=//'} - if not - gw=$3 -} -if (~ $netdir /net) { - xsfx=() - xdir=() -} -if not { - xsfx=(-x `{echo $netdir | sed 's;^/net;;'}) - xdir=(-x $netdir) -} -fn nonnil { # variable - if (~ $#$1 0) { - echo no ip for $1 - exit no-ip - } - if (! ~ $#$1 1) { - echo multiple ips for $1 - exit multiple-ips - } -} -devdir=`{awk '/^device/{print $2}' $netdir/ipifc/*/status | grep -v /dev/null} -nonnil devdir -devtype=pkt -if(~ $devdir *ether*) - devtype=ether - -# -# configure v6 for link-local addresses (fe80::) & multicast (ff02::) -# -if (! ip/ipconfig -6 $xdir $devtype $devdir) - exit 'ipconfig -6 failed' -ip/ipconfig $xdir $devtype $devdir ra6 recvra 1 - -mev6=`{ndb/query -f $ndbf sys $sysname ipv6 | grep :} -if (~ $#mev6 0) - mev6=`{ndb/query -mf $ndbf sys $sysname ip | grep :} -# mev4=`{ndb/query -f $ndbf sys $sysname ip | grep -v :} - -# for testing -if(~ $devtype ether){ - mylnk=`{ip/linklocal `{cat $devdir/addr}} - nonnil mylnk -} - -if (~ $#gw 1) { - if (~ $gw [0-9]*.[0-9]*.[0-9]*.[0-9]*) - gwv4=$gw - if (~ $#gwv4 0) - gwv4=`{ndb/query -f $ndbf sys $gw ip | grep -v :} - if (~ $gw *:*) - gwv6=$gw - if (~ $#gwv6 0) - gwv6=`{ndb/query -f $ndbf sys $gw ipv6 | grep :} - if (~ $#gwv6 0) - gwv6=`{ndb/query -f $ndbf sys $gw ip | grep :} - if (~ $#gwv6 0) { - if (~ $#gwv4 1) { - # echo ping gw $gwv4... - # load arp cache with gw mac - ip/ping -qn 3 $netdir/icmp!$gwv4 >/dev/null >[2=1] & - sleep 1 # wait for ping - - gweth=`{grep '* '^$gwv4^' ' $netdir/arp | awk '{print $4}' } - nonnil gweth - gwlnk=`{ip/linklocal $gweth} - nonnil gwlnk - gwv6=$gwlnk - } - } -} -nonnil mev6 -# -# configure my global v6 addresses -# -ip/ipconfig $xdir $devtype $devdir add $mev6 /64 -ip/ipconfig $xdir loopback /dev/null add $mev6 /128 - -if (~ $#gwv6 1) { - # - # add default v6 route to v6 addr of v4 gw - # - echo add :: /0 $gwv6 >$netdir/iproute # need not be link-local -} -exit '' diff --git a/sys/man/8/ipconfig b/sys/man/8/ipconfig index 6cbaa3ef6..1a58c48d9 100644 --- a/sys/man/8/ipconfig +++ b/sys/man/8/ipconfig @@ -1,6 +1,6 @@ .TH IPCONFIG 8 .SH NAME -ipconfig, rip, linklocal, ipv6on \- Internet configuration and routing +ipconfig, rip, linklocal \- Internet configuration and routing .SH SYNOPSIS .in +0.25i .ti -0.25i @@ -52,14 +52,6 @@ ipconfig, rip, linklocal, ipv6on \- Internet configuration and routing ] .I mac \&... -.PP -.B ipv6on -[ -.I netmtpt -.I ndbfile -[ -.I gwv4 -]\|] .SH DESCRIPTION .I Ipconfig binds a device interface to a mounted IP stack (default @@ -73,12 +65,13 @@ The addresses can be specified in the command line or obtained via DHCP. If DHCP is requested, it will also obtain the addresses of DNS servers, NTP servers, gateways, a Plan 9 file server, and a Plan 9 authentication server. -If this is the first non-loopback -interface on the IP stack, the information will be written to +Information from DHCP and IPv6 router advertisements is written to .B /net/ndb in the form of an .IR ndb (8) -entry. +entry unless the +.B P +flag has been specified. .PP .I Type may be @@ -175,7 +168,7 @@ turn on debugging. the default gateway. .TP .B G -use only generic DHCP options. Without this option, +use only generic DHCP and RA options. Without this option, .I ipconfig adds to requests a Vendor Class option with value .BI plan9_$ cputype @@ -197,10 +190,15 @@ determine parameters but don't configure the interface. .TP .B N look in -.B /lib/ndb -for the IP parameters. This only works if the -interface is an ethernet. It uses the ethernet address to find -a matching entry. +.I dbfile +(default +.BR /lib/ndb/local ) +for the IP parameters for the specified IP address or if the +IP is omited and the device is an ethernet then all IP parameters +associated with the MAC address. IPv6 addresses are added only +if a IPv6 link local address exists on the interface or the +.B 6 +flag has been given to automatically configure one. .TP .B O addresses specified on the command line override those obtained via DHCP. @@ -322,18 +320,6 @@ and .I 6to4 gateway .IR gwipv4 . -.PP -.I Ipv6on -uses the network database at -.I ndbfile -to configure the network mounted on -.I netmtpt -with a link-local address (derived from its MAC address) -and attempts to add a default IPv6 route to the local -IPv4 gateway's IPv6 address. -If -.I gwv4 -is supplied, it will be used as the gateway IPv4 address. .SH EXAMPLES Configure Ethernet 0 as the primary IP interface. Get all addresses via DHCP. Start up a connection server @@ -386,8 +372,6 @@ ip/ipconfig ra6 recvra 1 .B /sys/src/cmd/ip/rip.c .br .B /sys/src/cmd/ip/linklocal.c -.br -.B /rc/bin/ipv6on .SH "SEE ALSO" .IR ether (3), .IR ip (3), -- cgit v1.2.3