diff options
| -rw-r--r-- | fw/src/fw.c | 69 | ||||
| -rw-r--r-- | fw/src/netfs.c | 8 |
2 files changed, 10 insertions, 67 deletions
diff --git a/fw/src/fw.c b/fw/src/fw.c index a136194..23971cd 100644 --- a/fw/src/fw.c +++ b/fw/src/fw.c @@ -1100,71 +1100,14 @@ learnaddr(char *net, char *dev, char *addr, int naddr, char *gw, int ngw) * So before taking anything, throw away any pkt interface already * carrying the address we are about to use. Nothing else can have made * it: a live fw would still be holding the card we are about to take. - */ -/* - * Undo a previous fw that died. - * - * An IP stack outlives the program that configured it, so a fw that is - * killed leaves its pkt interface behind, holding the address, with - * nothing on the other end of it. The machine has no network until - * someone unpicks that by hand, and the next fw to start makes a second - * interface with the same address and routes that could go to either. * - * So before taking anything, throw away any pkt interface already - * carrying the address we are about to use. Nothing else can have made - * it: a live fw would still be holding the card we are about to take. + * This is the only cleanup there is. There was once a putback() that + * meant to restore the card on the way out, registered with atexit and + * threadnotify; both match on the pid that registered them, and that + * proc exits as soon as the server is posted, so neither could ever + * run. Nothing puts the card back - see fw(8) and todo.md, not a + * function that reads as though it does. */ -/* - * Put the card back. - * - * Taking a card is destructive: the stack loses it, and the pkt - * interface that replaced it is unbindonclose, so when fw stops the - * address goes with it and the machine is left with a card bound to - * nothing. Restore it on the way out, so that everything short of an - * uncatchable kill leaves the machine as we found it. - */ -static char *backdev, *backaddr, *backmask, *backnet, *backgw; - -static void -putback(void) -{ - char path[128], buf[64]; - int cfd, n, ifc; - - if(backdev == nil) - return; - snprint(path, sizeof path, "%s/ipifc/clone", backnet); - if((cfd = open(path, ORDWR)) < 0) - return; - if((n = read(cfd, buf, sizeof buf - 1)) <= 0){ - close(cfd); - return; - } - buf[n] = '\0'; - ifc = atoi(buf); - if(fprint(cfd, "bind ether %s", backdev) > 0 - && fprint(cfd, "add %s %s", backaddr, backmask) > 0){ - if(backgw != nil){ - snprint(path, sizeof path, "%s/iproute", backnet); - if((n = open(path, OWRITE)) >= 0){ - fprint(n, "add 0.0.0.0 0.0.0.0 %s", backgw); - close(n); - } - } - fprint(2, "fw: put %s back on %s/ipifc/%d\n", backdev, backnet, ifc); - } - /* the ctl fd must stay open for the binding to last */ - backdev = nil; -} - -/* clean up, then let the note do what it was going to do */ -static int -notehandler(void*, char*) -{ - putback(); - return 0; -} - static void reclaim(char *net, char *addr) { diff --git a/fw/src/netfs.c b/fw/src/netfs.c index 4aa1909..f44b089 100644 --- a/fw/src/netfs.c +++ b/fw/src/netfs.c @@ -325,10 +325,6 @@ ctlproto(char *path) } /* - * connect takes addr!port with optional trailing fields; announce takes - * a bare port, or addr!port with addr often "*". - */ -/* * Control messages that only change how this one conversation behaves, * and so cannot reach the network by themselves. Everything outside * this list is refused: see checkctl. @@ -344,6 +340,10 @@ static char *okverbs[] = { nil, }; +/* + * connect takes addr!port with optional trailing fields; announce takes + * a bare port, or addr!port with addr often "*". + */ static char* checkctl(char *proto, char *msg, long n) { |
