merge
This commit is contained in:
commit
fcb974af3a
15 changed files with 159 additions and 175 deletions
27
rc/bin/cpurc
27
rc/bin/cpurc
|
@ -5,7 +5,7 @@
|
||||||
NPROC=`{wc -l </dev/sysstat}
|
NPROC=`{wc -l </dev/sysstat}
|
||||||
|
|
||||||
# bind all likely devices
|
# bind all likely devices
|
||||||
for(i in t S P '$')
|
for(i in u t S P '$')
|
||||||
bind -a '#'^$i /dev >/dev/null >[2=1]
|
bind -a '#'^$i /dev >/dev/null >[2=1]
|
||||||
rm -f /env/i
|
rm -f /env/i
|
||||||
|
|
||||||
|
@ -56,12 +56,19 @@ if(test -e /cfg/$sysname/cpurc)
|
||||||
# automatic ip address setup
|
# automatic ip address setup
|
||||||
if(test -r /net/ipselftab){
|
if(test -r /net/ipselftab){
|
||||||
if(! grep u /net/ipselftab | grep -sv 127.0.0.1){
|
if(! grep u /net/ipselftab | grep -sv 127.0.0.1){
|
||||||
ether=`{ndb/query sys $sysname ether}
|
addrs=`{ndb/query -a sys $sysname ether}
|
||||||
if(~ $#ether 1){
|
if(! ~ $#addrs 0){
|
||||||
# try /lib/ndb first, then do dhcp
|
for(ether in /net/ether*){
|
||||||
ip/ipconfig -N >[2]/dev/null || ip/ipconfig -h $sysname
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rm -f /env/ether
|
rm -f /env/ether /env/addrs /env/addr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,16 +84,16 @@ if(! ps|grep -s timesync){
|
||||||
sleep 2
|
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)
|
if(test -d /cfg/$sysname/service)
|
||||||
serviced=/cfg/$sysname/service
|
serviced=/cfg/$sysname/service
|
||||||
if not if(test -d /cfg/default/service)
|
if not if(test -d /cfg/default/service)
|
||||||
serviced=/cfg/default/service
|
serviced=/cfg/default/service
|
||||||
if not
|
if not
|
||||||
serviced=/rc/bin/service
|
serviced=/rc/bin/service
|
||||||
|
if(~ $#auth 0){
|
||||||
|
auth=`{ndb/query sys $sysname auth}
|
||||||
|
. <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'}
|
||||||
|
}
|
||||||
switch($auth){
|
switch($auth){
|
||||||
case `{ echo $sysname; ndb/query sys $sysname dom
|
case `{ echo $sysname; ndb/query sys $sysname dom
|
||||||
if(test -r /net/ipselftab){
|
if(test -r /net/ipselftab){
|
||||||
|
|
104
rc/bin/ipv6on
104
rc/bin/ipv6on
|
@ -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 ''
|
|
|
@ -6,7 +6,7 @@ TIMESYNCARGS=(-rLa1000000)
|
||||||
NPROC=`{wc -l </dev/sysstat}
|
NPROC=`{wc -l </dev/sysstat}
|
||||||
|
|
||||||
# bind all likely devices
|
# bind all likely devices
|
||||||
for(i in v t m i f S P L A '$')
|
for(i in u v t m i f S P L A '$')
|
||||||
bind -a '#'^$i /dev >/dev/null >[2=1]
|
bind -a '#'^$i /dev >/dev/null >[2=1]
|
||||||
rm -f /env/i
|
rm -f /env/i
|
||||||
|
|
||||||
|
@ -57,12 +57,19 @@ if(test -e /cfg/$sysname/termrc)
|
||||||
# automatic ip address setup
|
# automatic ip address setup
|
||||||
if(test -r /net/ipselftab){
|
if(test -r /net/ipselftab){
|
||||||
if(! grep u /net/ipselftab | grep -sv 127.0.0.1){
|
if(! grep u /net/ipselftab | grep -sv 127.0.0.1){
|
||||||
ether=`{ndb/query sys $sysname ether}
|
addrs=`{ndb/query -a sys $sysname ether}
|
||||||
if(~ $#ether 1){
|
if(! ~ $#addrs 0){
|
||||||
# try /lib/ndb first, then do dhcp
|
for(ether in /net/ether*){
|
||||||
ip/ipconfig -N >[2]/dev/null || ip/ipconfig -h $sysname
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rm -f /env/ether
|
rm -f /env/ether /env/addrs /env/addr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
sys/man/3/ip
11
sys/man/3/ip
|
@ -194,6 +194,17 @@ Set the maximum transfer unit for this device to
|
||||||
The mtu is the maximum size of the packet including any
|
The mtu is the maximum size of the packet including any
|
||||||
medium-specific headers.
|
medium-specific headers.
|
||||||
.TP
|
.TP
|
||||||
|
.BI speed\ n
|
||||||
|
Set the maximum transmit speed in bits per second.
|
||||||
|
TP
|
||||||
|
.BI delay\ n
|
||||||
|
Set the maximum burst delay in milliseconds. (Default is 40ms)
|
||||||
|
When
|
||||||
|
.B speed
|
||||||
|
has been set and packets in flight exceed the maximum burst
|
||||||
|
delay then packets send on the interface are discarded until
|
||||||
|
the load drops below the maximum.
|
||||||
|
.TP
|
||||||
.BI iprouting\ n
|
.BI iprouting\ n
|
||||||
Allow
|
Allow
|
||||||
.RI ( n
|
.RI ( n
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.TH IPCONFIG 8
|
.TH IPCONFIG 8
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ipconfig, rip, linklocal, ipv6on \- Internet configuration and routing
|
ipconfig, rip, linklocal \- Internet configuration and routing
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.in +0.25i
|
.in +0.25i
|
||||||
.ti -0.25i
|
.ti -0.25i
|
||||||
|
@ -52,14 +52,6 @@ ipconfig, rip, linklocal, ipv6on \- Internet configuration and routing
|
||||||
]
|
]
|
||||||
.I mac
|
.I mac
|
||||||
\&...
|
\&...
|
||||||
.PP
|
|
||||||
.B ipv6on
|
|
||||||
[
|
|
||||||
.I netmtpt
|
|
||||||
.I ndbfile
|
|
||||||
[
|
|
||||||
.I gwv4
|
|
||||||
]\|]
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.I Ipconfig
|
.I Ipconfig
|
||||||
binds a device interface to a mounted IP stack (default
|
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
|
If DHCP is requested, it will also obtain the addresses of DNS
|
||||||
servers, NTP servers, gateways, a Plan 9 file server,
|
servers, NTP servers, gateways, a Plan 9 file server,
|
||||||
and a Plan 9 authentication server.
|
and a Plan 9 authentication server.
|
||||||
If this is the first non-loopback
|
Information from DHCP and IPv6 router advertisements is written to
|
||||||
interface on the IP stack, the information will be written to
|
|
||||||
.B /net/ndb
|
.B /net/ndb
|
||||||
in the form of an
|
in the form of an
|
||||||
.IR ndb (8)
|
.IR ndb (8)
|
||||||
entry.
|
entry unless the
|
||||||
|
.B P
|
||||||
|
flag has been specified.
|
||||||
.PP
|
.PP
|
||||||
.I Type
|
.I Type
|
||||||
may be
|
may be
|
||||||
|
@ -175,7 +168,7 @@ turn on debugging.
|
||||||
the default gateway.
|
the default gateway.
|
||||||
.TP
|
.TP
|
||||||
.B G
|
.B G
|
||||||
use only generic DHCP options. Without this option,
|
use only generic DHCP and RA options. Without this option,
|
||||||
.I ipconfig
|
.I ipconfig
|
||||||
adds to requests a Vendor Class option with value
|
adds to requests a Vendor Class option with value
|
||||||
.BI plan9_$ cputype
|
.BI plan9_$ cputype
|
||||||
|
@ -197,10 +190,18 @@ determine parameters but don't configure the interface.
|
||||||
.TP
|
.TP
|
||||||
.B N
|
.B N
|
||||||
look in
|
look in
|
||||||
.B /lib/ndb
|
.I dbfile
|
||||||
for the IP parameters. This only works if the
|
(default
|
||||||
interface is an ethernet. It uses the ethernet address to find
|
.BR /lib/ndb/local )
|
||||||
a matching entry.
|
for the IP parameters for the specified
|
||||||
|
.I local
|
||||||
|
IP address or if
|
||||||
|
.I local
|
||||||
|
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
|
.TP
|
||||||
.B O
|
.B O
|
||||||
addresses specified on the command line override those obtained via DHCP.
|
addresses specified on the command line override those obtained via DHCP.
|
||||||
|
@ -208,13 +209,11 @@ A command line address of 0 implies no override.
|
||||||
.TP
|
.TP
|
||||||
.B p
|
.B p
|
||||||
write configuration information to
|
write configuration information to
|
||||||
.BR /net/ndb ,
|
.BR /net/ndb .
|
||||||
even if other network interfaces are already configured
|
|
||||||
.TP
|
.TP
|
||||||
.B P
|
.B P
|
||||||
do not write configuration information to
|
do not write configuration information to
|
||||||
.BR /net/ndb ,
|
.BR /net/ndb .
|
||||||
even if this is the first network interface to be configured
|
|
||||||
.TP
|
.TP
|
||||||
.B r
|
.B r
|
||||||
by default,
|
by default,
|
||||||
|
@ -231,7 +230,7 @@ before adding new ones.
|
||||||
.TP
|
.TP
|
||||||
.B f
|
.B f
|
||||||
use the ndb database file
|
use the ndb database file
|
||||||
.I dbfile .
|
.IR dbfile .
|
||||||
.TP
|
.TP
|
||||||
.B x
|
.B x
|
||||||
use the IP stack mounted at
|
use the IP stack mounted at
|
||||||
|
@ -322,18 +321,6 @@ and
|
||||||
.I 6to4
|
.I 6to4
|
||||||
gateway
|
gateway
|
||||||
.IR gwipv4 .
|
.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
|
.SH EXAMPLES
|
||||||
Configure Ethernet 0 as the primary IP interface.
|
Configure Ethernet 0 as the primary IP interface.
|
||||||
Get all addresses via DHCP. Start up a connection server
|
Get all addresses via DHCP. Start up a connection server
|
||||||
|
@ -386,8 +373,6 @@ ip/ipconfig ra6 recvra 1
|
||||||
.B /sys/src/cmd/ip/rip.c
|
.B /sys/src/cmd/ip/rip.c
|
||||||
.br
|
.br
|
||||||
.B /sys/src/cmd/ip/linklocal.c
|
.B /sys/src/cmd/ip/linklocal.c
|
||||||
.br
|
|
||||||
.B /rc/bin/ipv6on
|
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.IR ether (3),
|
.IR ether (3),
|
||||||
.IR ip (3),
|
.IR ip (3),
|
||||||
|
|
|
@ -53,6 +53,10 @@ ppp, pppoe, pptp, pptpd \- point-to-point protocol
|
||||||
.I mtu
|
.I mtu
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
.B -b
|
||||||
|
.I baud
|
||||||
|
]
|
||||||
|
[
|
||||||
.B -x
|
.B -x
|
||||||
.I pppnetmntpt
|
.I pppnetmntpt
|
||||||
]
|
]
|
||||||
|
|
|
@ -303,7 +303,7 @@ arpenter(Fs *fs, int version, uchar *ip, uchar *mac, int n, uchar *ia, Ipifc *if
|
||||||
freeblistchain(next);
|
freeblistchain(next);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ifc->m->bwrite(ifc, concatblock(bp), version, ip);
|
ipifcoput(ifc, bp, version, ip);
|
||||||
poperror();
|
poperror();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -180,6 +180,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
|
||||||
runlock(ifc);
|
runlock(ifc);
|
||||||
nexterror();
|
nexterror();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ifc->m == nil)
|
if(ifc->m == nil)
|
||||||
goto raise;
|
goto raise;
|
||||||
|
|
||||||
|
@ -196,7 +197,7 @@ ipoput4(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
|
||||||
eh->cksum[0] = 0;
|
eh->cksum[0] = 0;
|
||||||
eh->cksum[1] = 0;
|
eh->cksum[1] = 0;
|
||||||
hnputs(eh->cksum, ipcsum(&eh->vihl));
|
hnputs(eh->cksum, ipcsum(&eh->vihl));
|
||||||
ifc->m->bwrite(ifc, concatblock(bp), V4, gate);
|
ipifcoput(ifc, bp, V4, gate);
|
||||||
runlock(ifc);
|
runlock(ifc);
|
||||||
poperror();
|
poperror();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -280,7 +281,7 @@ if((eh->frag[0] & (IP_DF>>8)) && !gating) print("%V: DF set\n", eh->dst);
|
||||||
feh->cksum[0] = 0;
|
feh->cksum[0] = 0;
|
||||||
feh->cksum[1] = 0;
|
feh->cksum[1] = 0;
|
||||||
hnputs(feh->cksum, ipcsum(&feh->vihl));
|
hnputs(feh->cksum, ipcsum(&feh->vihl));
|
||||||
ifc->m->bwrite(ifc, nb, V4, gate);
|
ipifcoput(ifc, nb, V4, gate);
|
||||||
ip->stats[FragCreates]++;
|
ip->stats[FragCreates]++;
|
||||||
}
|
}
|
||||||
ip->stats[FragOKs]++;
|
ip->stats[FragOKs]++;
|
||||||
|
|
|
@ -327,6 +327,12 @@ struct Ipifc
|
||||||
uchar recvra6; /* flag: recv router advs on this ifc */
|
uchar recvra6; /* flag: recv router advs on this ifc */
|
||||||
Routerparams rp; /* router parameters as in RFC 2461, pp.40—43.
|
Routerparams rp; /* router parameters as in RFC 2461, pp.40—43.
|
||||||
used only if node is router */
|
used only if node is router */
|
||||||
|
|
||||||
|
int speed; /* link speed in bits per second */
|
||||||
|
int delay; /* burst delay in ms */
|
||||||
|
int burst; /* burst delay in bytes */
|
||||||
|
int load; /* bytes in flight */
|
||||||
|
ulong ticks;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -652,6 +658,7 @@ extern Medium pktmedium;
|
||||||
*/
|
*/
|
||||||
extern Medium* ipfindmedium(char *name);
|
extern Medium* ipfindmedium(char *name);
|
||||||
extern void addipmedium(Medium *med);
|
extern void addipmedium(Medium *med);
|
||||||
|
extern void ipifcoput(Ipifc *ifc, Block *bp, int version, uchar *ip);
|
||||||
extern int ipforme(Fs*, uchar *addr);
|
extern int ipforme(Fs*, uchar *addr);
|
||||||
extern int ipismulticast(uchar *ip);
|
extern int ipismulticast(uchar *ip);
|
||||||
extern Ipifc* findipifc(Fs*, uchar *local, uchar *remote, int type);
|
extern Ipifc* findipifc(Fs*, uchar *local, uchar *remote, int type);
|
||||||
|
|
|
@ -250,7 +250,7 @@ ipifcunbind(Ipifc *ifc)
|
||||||
|
|
||||||
char sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag"
|
char sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag"
|
||||||
" %d maxraint %d minraint %d linkmtu %d reachtime %d rxmitra %d ttl %d routerlt"
|
" %d maxraint %d minraint %d linkmtu %d reachtime %d rxmitra %d ttl %d routerlt"
|
||||||
" %d pktin %lud pktout %lud errin %lud errout %lud\n";
|
" %d pktin %lud pktout %lud errin %lud errout %lud speed %d delay %d\n";
|
||||||
|
|
||||||
char slineformat[] = " %-40I %-10M %-40I %-12lud %-12lud\n";
|
char slineformat[] = " %-40I %-10M %-40I %-12lud %-12lud\n";
|
||||||
|
|
||||||
|
@ -267,7 +267,8 @@ ipifcstate(Conv *c, char *state, int n)
|
||||||
ifc->rp.mflag, ifc->rp.oflag, ifc->rp.maxraint,
|
ifc->rp.mflag, ifc->rp.oflag, ifc->rp.maxraint,
|
||||||
ifc->rp.minraint, ifc->rp.linkmtu, ifc->rp.reachtime,
|
ifc->rp.minraint, ifc->rp.linkmtu, ifc->rp.reachtime,
|
||||||
ifc->rp.rxmitra, ifc->rp.ttl, ifc->rp.routerlt,
|
ifc->rp.rxmitra, ifc->rp.ttl, ifc->rp.routerlt,
|
||||||
ifc->in, ifc->out, ifc->inerr, ifc->outerr);
|
ifc->in, ifc->out, ifc->inerr, ifc->outerr,
|
||||||
|
ifc->speed, ifc->delay);
|
||||||
|
|
||||||
rlock(ifc);
|
rlock(ifc);
|
||||||
for(lifc = ifc->lifc; lifc != nil && n > m; lifc = lifc->next)
|
for(lifc = ifc->lifc; lifc != nil && n > m; lifc = lifc->next)
|
||||||
|
@ -309,6 +310,50 @@ ipifcinuse(Conv *c)
|
||||||
return ifc->m != nil;
|
return ifc->m != nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ipifcsetdelay(Ipifc *ifc, int delay)
|
||||||
|
{
|
||||||
|
if(delay < 0)
|
||||||
|
delay = 0;
|
||||||
|
else if(delay > 1000)
|
||||||
|
delay = 1000;
|
||||||
|
ifc->delay = delay;
|
||||||
|
ifc->burst = ((vlong)delay * ifc->speed) / 8000;
|
||||||
|
if(ifc->burst < ifc->maxtu)
|
||||||
|
ifc->burst = ifc->maxtu;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ipifcsetspeed(Ipifc *ifc, int speed)
|
||||||
|
{
|
||||||
|
if(speed < 0)
|
||||||
|
speed = 0;
|
||||||
|
ifc->speed = speed;
|
||||||
|
ifc->load = 0;
|
||||||
|
ipifcsetdelay(ifc, ifc->delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ipifcoput(Ipifc *ifc, Block *bp, int version, uchar *ip)
|
||||||
|
{
|
||||||
|
if(ifc->speed){
|
||||||
|
ulong now = MACHP(0)->ticks;
|
||||||
|
int dt = TK2MS(now - ifc->ticks);
|
||||||
|
ifc->ticks = now;
|
||||||
|
ifc->load -= ((vlong)dt * ifc->speed) / 8000;
|
||||||
|
if(ifc->load < 0 || dt < 0 || dt > 1000)
|
||||||
|
ifc->load = 0;
|
||||||
|
else if(ifc->load > ifc->burst){
|
||||||
|
freeblist(bp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bp = concatblock(bp);
|
||||||
|
ifc->load += BLEN(bp);
|
||||||
|
ifc->m->bwrite(ifc, bp, version, ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* called when a process writes to an interface's 'data'
|
* called when a process writes to an interface's 'data'
|
||||||
*/
|
*/
|
||||||
|
@ -358,6 +403,8 @@ ipifccreate(Conv *c)
|
||||||
ifc->m = nil;
|
ifc->m = nil;
|
||||||
ifc->reflect = 0;
|
ifc->reflect = 0;
|
||||||
ifc->reassemble = 0;
|
ifc->reassemble = 0;
|
||||||
|
ipifcsetspeed(ifc, 0);
|
||||||
|
ipifcsetdelay(ifc, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -772,6 +819,14 @@ ipifcctl(Conv* c, char **argv, int argc)
|
||||||
return ipifcunbind(ifc);
|
return ipifcunbind(ifc);
|
||||||
else if(strcmp(argv[0], "mtu") == 0)
|
else if(strcmp(argv[0], "mtu") == 0)
|
||||||
return ipifcsetmtu(ifc, argv, argc);
|
return ipifcsetmtu(ifc, argv, argc);
|
||||||
|
else if(strcmp(argv[0], "speed") == 0){
|
||||||
|
ipifcsetspeed(ifc, argc>1? atoi(argv[1]): 0);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
else if(strcmp(argv[0], "delay") == 0){
|
||||||
|
ipifcsetdelay(ifc, argc>1? atoi(argv[1]): 0);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
else if(strcmp(argv[0], "iprouting") == 0){
|
else if(strcmp(argv[0], "iprouting") == 0){
|
||||||
iprouting(c->p->f, argc>1? atoi(argv[1]): 1);
|
iprouting(c->p->f, argc>1? atoi(argv[1]): 1);
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -103,7 +103,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
|
||||||
medialen = ifc->maxtu - ifc->m->hsize;
|
medialen = ifc->maxtu - ifc->m->hsize;
|
||||||
if(len <= medialen) {
|
if(len <= medialen) {
|
||||||
hnputs(eh->ploadlen, len - IP6HDR);
|
hnputs(eh->ploadlen, len - IP6HDR);
|
||||||
ifc->m->bwrite(ifc, concatblock(bp), V6, gate);
|
ipifcoput(ifc, bp, V6, gate);
|
||||||
runlock(ifc);
|
runlock(ifc);
|
||||||
poperror();
|
poperror();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -193,8 +193,7 @@ ipoput6(Fs *f, Block *bp, int gating, int ttl, int tos, Routehint *rh)
|
||||||
if(xp->rp == xp->wp)
|
if(xp->rp == xp->wp)
|
||||||
xp = xp->next;
|
xp = xp->next;
|
||||||
}
|
}
|
||||||
|
ipifcoput(ifc, nb, V6, gate);
|
||||||
ifc->m->bwrite(ifc, nb, V6, gate);
|
|
||||||
ip->stats[FragCreates]++;
|
ip->stats[FragCreates]++;
|
||||||
}
|
}
|
||||||
ip->stats[FragOKs]++;
|
ip->stats[FragOKs]++;
|
||||||
|
|
|
@ -318,8 +318,7 @@ main(int argc, char **argv)
|
||||||
plan9 = 0;
|
plan9 = 0;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
snprint(conf.hostname, sizeof conf.hostname, "%s",
|
snprint(conf.hostname, sizeof conf.hostname, "%s", EARGF(usage()));
|
||||||
EARGF(usage()));
|
|
||||||
sendhostname = 1;
|
sendhostname = 1;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
|
@ -389,7 +388,7 @@ main(int argc, char **argv)
|
||||||
if(dondbconfig){
|
if(dondbconfig){
|
||||||
dodhcp = 0;
|
dodhcp = 0;
|
||||||
ndbconfig();
|
ndbconfig();
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
doadd();
|
doadd();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -25,7 +25,7 @@ usage(void)
|
||||||
void
|
void
|
||||||
ea2eui64(uchar *lla, uchar *ea)
|
ea2eui64(uchar *lla, uchar *ea)
|
||||||
{
|
{
|
||||||
*lla++ = *ea++ | V60globaladm; /* oui (company id) */
|
*lla++ = *ea++ ^ V60globaladm; /* oui (company id) */
|
||||||
*lla++ = *ea++; /* " */
|
*lla++ = *ea++; /* " */
|
||||||
*lla++ = *ea++; /* " */
|
*lla++ = *ea++; /* " */
|
||||||
*lla++ = 0xFF; /* mac-48 in eui-64 (sic) */
|
*lla++ = 0xFF; /* mac-48 in eui-64 (sic) */
|
||||||
|
|
|
@ -1497,7 +1497,7 @@ ppptimer(PPP *ppp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setdefroute(char *net, Ipaddr gate)
|
defroute(char *net, char *verb, Ipaddr gate, Ipaddr local)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char path[128];
|
char path[128];
|
||||||
|
@ -1506,7 +1506,10 @@ setdefroute(char *net, Ipaddr gate)
|
||||||
fd = open(path, ORDWR);
|
fd = open(path, ORDWR);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
return;
|
return;
|
||||||
fprint(fd, "add 0 0 %I", gate);
|
fprint(fd, "tag ppp");
|
||||||
|
if(primary)
|
||||||
|
fprint(fd, "%s 0.0.0.0 0.0.0.0 %I", verb, gate);
|
||||||
|
fprint(fd, "%s 0.0.0.0 0.0.0.0 %I %I 255.255.255.255", verb, gate, local);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1550,8 +1553,9 @@ ipopen(PPP *ppp)
|
||||||
close(cfd);
|
close(cfd);
|
||||||
return "can't set addresses";
|
return "can't set addresses";
|
||||||
}
|
}
|
||||||
if(primary)
|
if(baud)
|
||||||
setdefroute(ppp->net, ppp->remote);
|
fprint(cfd, "speed %d", baud);
|
||||||
|
defroute(ppp->net, "add", ppp->remote, ppp->local);
|
||||||
ppp->ipfd = fd;
|
ppp->ipfd = fd;
|
||||||
ppp->ipcfd = cfd;
|
ppp->ipcfd = cfd;
|
||||||
|
|
||||||
|
@ -1570,6 +1574,7 @@ ipopen(PPP *ppp)
|
||||||
/* we may have changed addresses */
|
/* we may have changed addresses */
|
||||||
if(ipcmp(ppp->local, ppp->curlocal) != 0 ||
|
if(ipcmp(ppp->local, ppp->curlocal) != 0 ||
|
||||||
ipcmp(ppp->remote, ppp->curremote) != 0){
|
ipcmp(ppp->remote, ppp->curremote) != 0){
|
||||||
|
defroute(ppp->net, "remove", ppp->curremote, ppp->curlocal);
|
||||||
snprint(buf, sizeof buf, "remove %I 255.255.255.255 %I",
|
snprint(buf, sizeof buf, "remove %I 255.255.255.255 %I",
|
||||||
ppp->curlocal, ppp->curremote);
|
ppp->curlocal, ppp->curremote);
|
||||||
if(fprint(ppp->ipcfd, "%s", buf) < 0)
|
if(fprint(ppp->ipcfd, "%s", buf) < 0)
|
||||||
|
@ -1578,6 +1583,7 @@ ipopen(PPP *ppp)
|
||||||
ppp->local, ppp->remote, ppp->mtu-10);
|
ppp->local, ppp->remote, ppp->mtu-10);
|
||||||
if(fprint(ppp->ipcfd, "%s", buf) < 0)
|
if(fprint(ppp->ipcfd, "%s", buf) < 0)
|
||||||
syslog(0, "ppp", "can't %s: %r", buf);
|
syslog(0, "ppp", "can't %s: %r", buf);
|
||||||
|
defroute(ppp->net, "add", ppp->remote, ppp->local);
|
||||||
}
|
}
|
||||||
syslog(0, "ppp", "%I/%I -> %I/%I", ppp->curlocal, ppp->curremote,
|
syslog(0, "ppp", "%I/%I -> %I/%I", ppp->curlocal, ppp->curremote,
|
||||||
ppp->local, ppp->remote);
|
ppp->local, ppp->remote);
|
||||||
|
@ -2634,7 +2640,7 @@ usage(void)
|
||||||
void
|
void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int mtu, baud, framing, user, mediain, mediaout, cfd;
|
int mtu, framing, user, mediain, mediaout, cfd;
|
||||||
Ipaddr ipaddr, remip;
|
Ipaddr ipaddr, remip;
|
||||||
char *dev, *modemcmd;
|
char *dev, *modemcmd;
|
||||||
char net[128];
|
char net[128];
|
||||||
|
@ -2654,7 +2660,6 @@ main(int argc, char **argv)
|
||||||
invalidate(remip);
|
invalidate(remip);
|
||||||
|
|
||||||
mtu = Defmtu;
|
mtu = Defmtu;
|
||||||
baud = 0;
|
|
||||||
framing = 0;
|
framing = 0;
|
||||||
setnetmtpt(net, sizeof(net), nil);
|
setnetmtpt(net, sizeof(net), nil);
|
||||||
user = 0;
|
user = 0;
|
||||||
|
|
|
@ -29,11 +29,12 @@ int cookielen;
|
||||||
uchar etherdst[6];
|
uchar etherdst[6];
|
||||||
int mtu = 1492;
|
int mtu = 1492;
|
||||||
int pktcompress, hdrcompress;
|
int pktcompress, hdrcompress;
|
||||||
|
char *baud;
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: pppoe [-PdcC] [-A acname] [-S srvname] [-k keyspec] [-m mtu] [-x pppnet] [ether0]\n");
|
fprint(2, "usage: pppoe [-PdcC] [-A acname] [-S srvname] [-k keyspec] [-m mtu] [-b baud] [-x pppnet] [ether0]\n");
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@ main(int argc, char **argv)
|
||||||
case 'k':
|
case 'k':
|
||||||
keyspec = EARGF(usage());
|
keyspec = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
baud = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
pktcompress = 1;
|
pktcompress = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -533,6 +537,10 @@ execppp(int fd)
|
||||||
argv[argc++] = "-d";
|
argv[argc++] = "-d";
|
||||||
if(primary)
|
if(primary)
|
||||||
argv[argc++] = "-P";
|
argv[argc++] = "-P";
|
||||||
|
if(baud){
|
||||||
|
argv[argc++] = "-b";
|
||||||
|
argv[argc++] = baud;
|
||||||
|
}
|
||||||
if(hdrcompress)
|
if(hdrcompress)
|
||||||
argv[argc++] = "-C";
|
argv[argc++] = "-C";
|
||||||
if(pktcompress)
|
if(pktcompress)
|
||||||
|
|
Loading…
Reference in a new issue