* Take ethernet interface from ndb in ipv6on
@ 2016-04-03 16:49 k0ga
2016-04-05 1:18 ` [9front] " arisawa
0 siblings, 1 reply; 2+ messages in thread
From: k0ga @ 2016-04-03 16:49 UTC (permalink / raw)
To: 9front
Hi,
ipv6on has several problems, because lines like:
if (! ip/ipconfig -6 $xdir ether $netdir/ether?)
will fail when there are more of one interface in /net
or when the interface has a slighty different name,
like for example etherU0 in the raspberry pi.
This patch uses ndb to guess what if the interface
for the ipv6 pair, and in case of not having any ether
entry in ndb then it takes the first ether* in /net
(or in general in the net mount point).
8<--------
diff -r 3e63050481a8 rc/bin/ipv6on
--- a/rc/bin/ipv6on Sat Mar 05 07:44:02 2016 +0100
+++ b/rc/bin/ipv6on Sun Apr 03 18:20:44 2016 +0200
@@ -40,20 +40,36 @@
}
}
-#
-# configure v6 for link-local addresses (fe80::) & multicast (ff02::)
-#
-if (! ip/ipconfig -6 $xdir ether $netdir/ether?)
- exit 'ipconfig -6 failed'
-ip/ipconfig $xdir ether $netdir/ether? ra6 recvra 1
-
mev6=`{ndb/query -f $ndbf sys $sysname ipv6}
if (~ $#mev6 0 || ~ $mev6 '')
mev6=`{ndb/query -mf $ndbf sys $sysname ip | grep :}
# mev4=`{ndb/query -f $ndbf sys $sysname ip | grep -v :}
+#
+# Get our mac from ndb
+eth=`{ndb/query -f $ndbf ipv6 $mev6 ether}
+if (~ $#eth 0 || ~ $eth '')
+ eth=`{ndb/query -f $ndbf sys $sysname ether}
+
+#
+# Get the ether for our mac
+if (~ $#eth 1 && ! ~ $eth '')
+ ifc=`{for (i in $netdir/ether*)
+ if (~ `{cat $i/addr} $eth) echo $i}
+
+if (~ $#ifc 0 || ~ $ifc '')
+ ifc=`{ls -d $netdir/ether* | sed -n 1q}
+
+#
+# configure v6 for link-local addresses (fe80::) & multicast (ff02::)
+#
+if (! ip/ipconfig -6 $xdir ether $ifc)
+ exit 'ipconfig -6 failed'
+ip/ipconfig $xdir ether $ifc ra6 recvra 1
+
+
# for testing
-mylnk=`{ip/linklocal `{cat $netdir/ether?/addr}}
+mylnk=`{ip/linklocal `{cat $ifc/addr}}
nonnil mylnk
if (~ $#gw 1) {
@@ -79,8 +95,8 @@
#
# configure my global v6 addresses
#
-ip/ipconfig $xdir ether $netdir/ether? add $mev6 /64
+ip/ipconfig $xdir ether $ifc add $mev6 /64
ip/ipconfig $xdir loopback /dev/null add $mev6 /128
if (~ $#gw 1) {
if (~ $#gwv6 0 || ~ $gwv6 '')
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [9front] Take ethernet interface from ndb in ipv6on
2016-04-03 16:49 Take ethernet interface from ndb in ipv6on k0ga
@ 2016-04-05 1:18 ` arisawa
0 siblings, 0 replies; 2+ messages in thread
From: arisawa @ 2016-04-05 1:18 UTC (permalink / raw)
To: 9front
Hello,
> ipv6on has several problems, because lines like:
>
> if (! ip/ipconfig -6 $xdir ether $netdir/ether?)
>
> will fail when there are more of one interface in /net
> or when the interface has a slighty different name,
> like for example etherU0 in the raspberry pi.
Yes current ipv6on has some problems.
> This patch uses ndb
In a certain situation such as terminal on mobile device, the ndb is no help.
the code below is my ipv6on that is working on notebook EeePC901,
but not tested in other environment.
probably there may be bugs.
I am happy if we have better ipv6on.
==== BEGIN ipv6on ====
#!/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
}
gw=`{awk '$4 ~ /4/ && $5 ~ /none/{print $3}' $netdir/iproute}
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
}
}
#
# configure v6 for link-local addresses (fe80::) & multicast (ff02::)
#
netether=`{ls -d $netdir/ether*}
netether=$netether(1)
if (! ip/ipconfig -6 $xdir ether $netether)
exit 'ipconfig -6 failed'
ip/ipconfig $xdir ether $netether ra6 recvra 1
# for testing
mylnk=`{ip/linklocal `{cat $netether/addr}}
nonnil mylnk
mev6=`{ndb/query -f $ndbf sys $sysname ipv6}
if (~ $#mev6 0 || ~ $mev6 '')
mev6=`{ndb/query -mf $ndbf sys $sysname ip | grep :}
if(~ $#mev6 0 || ~ $mev6 ''){
# I am not registered to /lib/ndb/local
# How to get my global IPv6 prefix?
# probably RA resolve this problem
# RA takes time, so we don't have the info at the moment
#v6pr=`{awk '$4 ~ /6i/{print $1}' $netdir/iproute | sed 's/::$/:/'}
#ifid=`{echo $mylnk | sed 's/^fe80:://'}
#mev6=$v6pr:$ifid # can be buggy if $ifid begins with 0:
mev6=$mylnk
}
nonnil mev6
if (~ $#gw 1) {
if (~ $gw [0-9]*.[0-9]*.[0-9]*.[0-9]*)
gwv4 = $gw
if (~ $#gwv4 0 || ~ $gwv4 '') # assume namev6 and name
gwv4=`{ndb/query -f $ndbf sys $gw ip}
gwv6=`{ndb/query -f $ndbf sys $gw ipv6}
if (! ~ $#gwv4 0) {
# 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}' }
}
}
#
# configure my global or link v6 addresses
#
ip/ipconfig $xdir ether $netether add $mev6 /64
ip/ipconfig $xdir loopback /dev/null add $mev6 /128
nonnil gweth
if (~ $#gwv6 0 || ~ $gwv6 '')
gwv6=`{ip/linklocal $gweth}
nonnil gwv6
#
# add default v6 route to v6 addr of v4 gw
#
echo add :: /0 $gwv6 >$netdir/iproute # need not be link-local
exit '’
=== END ipv6on ===
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-05 1:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-03 16:49 Take ethernet interface from ndb in ipv6on k0ga
2016-04-05 1:18 ` [9front] " arisawa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).