ref: eb3951bcd48399d4d7239a9d396a113e95e38be9
parent: 298f2396957bea59cf0985227a6dd903813b5938
author: cinap_lenrek <[email protected]>
date: Thu May 10 15:36:14 EDT 2018
ppp: set source specific default route regardless of primary flag, set link speed thru new ctl message when -b is specified
--- a/sys/man/8/ppp
+++ b/sys/man/8/ppp
@@ -53,6 +53,10 @@
.I mtu
]
[
+.B -b
+.I baud
+]
+[
.B -x
.I pppnetmntpt
]
--- a/sys/src/cmd/ip/ppp/ppp.c
+++ b/sys/src/cmd/ip/ppp/ppp.c
@@ -1497,7 +1497,7 @@
}
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 @@
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 @@
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 @@
/* 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 @@
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 @@
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 @@
invalidate(remip);
mtu = Defmtu;
- baud = 0;
framing = 0;
setnetmtpt(net, sizeof(net), nil);
user = 0;
--- a/sys/src/cmd/ip/pppoe.c
+++ b/sys/src/cmd/ip/pppoe.c
@@ -29,11 +29,12 @@
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 @@
case 'k':
keyspec = EARGF(usage());
break;
+ case 'b':
+ baud = EARGF(usage());
+ break;
case 'c':
pktcompress = 1;
break;
@@ -533,6 +537,10 @@
argv[argc++] = "-d";
if(primary)
argv[argc++] = "-P";
+ if(baud){
+ argv[argc++] = "-b";
+ argv[argc++] = baud;
+ }
if(hdrcompress)
argv[argc++] = "-C";
if(pktcompress)