summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-05-10 19:36:14 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-05-10 19:36:14 +0200
commiteb3951bcd48399d4d7239a9d396a113e95e38be9 (patch)
tree608ab49cb91e4c067f77e5d973b54a37d10ab7ba
parent298f2396957bea59cf0985227a6dd903813b5938 (diff)
downloadplan9front-eb3951bcd48399d4d7239a9d396a113e95e38be9.tar.xz
ppp: set source specific default route regardless of primary flag, set link speed thru new ctl message when -b is specified
-rw-r--r--sys/man/8/ppp4
-rw-r--r--sys/src/cmd/ip/ppp/ppp.c17
-rw-r--r--sys/src/cmd/ip/pppoe.c10
3 files changed, 24 insertions, 7 deletions
diff --git a/sys/man/8/ppp b/sys/man/8/ppp
index be60bfda3..66ebb7bfd 100644
--- a/sys/man/8/ppp
+++ b/sys/man/8/ppp
@@ -53,6 +53,10 @@ ppp, pppoe, pptp, pptpd \- point-to-point protocol
.I mtu
]
[
+.B -b
+.I baud
+]
+[
.B -x
.I pppnetmntpt
]
diff --git a/sys/src/cmd/ip/ppp/ppp.c b/sys/src/cmd/ip/ppp/ppp.c
index 650b75c3d..1225e8373 100644
--- a/sys/src/cmd/ip/ppp/ppp.c
+++ b/sys/src/cmd/ip/ppp/ppp.c
@@ -1497,7 +1497,7 @@ ppptimer(PPP *ppp)
}
static void
-setdefroute(char *net, Ipaddr gate)
+defroute(char *net, char *verb, Ipaddr gate, Ipaddr local)
{
int fd;
char path[128];
@@ -1506,7 +1506,10 @@ setdefroute(char *net, Ipaddr gate)
fd = open(path, ORDWR);
if(fd < 0)
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);
}
@@ -1550,8 +1553,9 @@ ipopen(PPP *ppp)
close(cfd);
return "can't set addresses";
}
- if(primary)
- setdefroute(ppp->net, ppp->remote);
+ if(baud)
+ fprint(cfd, "speed %d", baud);
+ defroute(ppp->net, "add", ppp->remote, ppp->local);
ppp->ipfd = fd;
ppp->ipcfd = cfd;
@@ -1570,6 +1574,7 @@ ipopen(PPP *ppp)
/* we may have changed addresses */
if(ipcmp(ppp->local, ppp->curlocal) != 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",
ppp->curlocal, ppp->curremote);
if(fprint(ppp->ipcfd, "%s", buf) < 0)
@@ -1578,6 +1583,7 @@ ipopen(PPP *ppp)
ppp->local, ppp->remote, ppp->mtu-10);
if(fprint(ppp->ipcfd, "%s", buf) < 0)
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,
ppp->local, ppp->remote);
@@ -2634,7 +2640,7 @@ usage(void)
void
main(int argc, char **argv)
{
- int mtu, baud, framing, user, mediain, mediaout, cfd;
+ int mtu, framing, user, mediain, mediaout, cfd;
Ipaddr ipaddr, remip;
char *dev, *modemcmd;
char net[128];
@@ -2654,7 +2660,6 @@ main(int argc, char **argv)
invalidate(remip);
mtu = Defmtu;
- baud = 0;
framing = 0;
setnetmtpt(net, sizeof(net), nil);
user = 0;
diff --git a/sys/src/cmd/ip/pppoe.c b/sys/src/cmd/ip/pppoe.c
index 34bfb00f9..8dd0f3638 100644
--- a/sys/src/cmd/ip/pppoe.c
+++ b/sys/src/cmd/ip/pppoe.c
@@ -29,11 +29,12 @@ int cookielen;
uchar etherdst[6];
int mtu = 1492;
int pktcompress, hdrcompress;
+char *baud;
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");
}
@@ -76,6 +77,9 @@ main(int argc, char **argv)
case 'k':
keyspec = EARGF(usage());
break;
+ case 'b':
+ baud = EARGF(usage());
+ break;
case 'c':
pktcompress = 1;
break;
@@ -533,6 +537,10 @@ execppp(int fd)
argv[argc++] = "-d";
if(primary)
argv[argc++] = "-P";
+ if(baud){
+ argv[argc++] = "-b";
+ argv[argc++] = baud;
+ }
if(hdrcompress)
argv[argc++] = "-C";
if(pktcompress)