From 134397184049e5410e84d7a45e38cf2f64a1b719 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 10 Jul 2001 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2001-07-10 --- ip/ip.h | 1 + ip/ipifc.c | 6 ++++-- ip/iproute.c | 40 +++++++++++++++++++++++----------------- pc/clock.c | 2 +- pc/uarti8250.c | 6 +++--- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/ip/ip.h b/ip/ip.h index 590b79afb495396b13754363cb1acd04ca45ecf1..b89706b942c5a4566f65d04bb3fd5741073900fb 100644 --- a/ip/ip.h +++ b/ip/ip.h @@ -383,6 +383,7 @@ struct RouteTree uchar ifcid; /* must match ifc->id */ Ipifc *ifc; char tag[4]; + int ref; }; struct V4route diff --git a/ip/ipifc.c b/ip/ipifc.c index 09a0e0784ee57199a884996016ab943066ec20a6..4d5e03f869b6615deb5d667e30f34f22f347a8cc 100644 --- a/ip/ipifc.c +++ b/ip/ipifc.c @@ -405,9 +405,9 @@ ipifcadd(Ipifc *ifc, char **argv, int argc) type |= Rptpt; } if(isv4(ip)) - v4addroute(f, tifc, rem+IPv4off, mask+IPv4off, ip+IPv4off, type); + v4addroute(f, tifc, rem+IPv4off, mask+IPv4off, rem+IPv4off, type); else - v6addroute(f, tifc, rem, mask, ip, type); + v6addroute(f, tifc, rem, mask, rem, type); addselfcache(f, ifc, lifc, ip, Runi); @@ -503,6 +503,8 @@ ipifcrem(Ipifc *ifc, char **argv, int argc, int dolock) return "address not on this interface"; } + ifc->ifcid++; + /* disassociate any addresses */ while(lifc->link) remselfcache(f, ifc, lifc, lifc->link->self->a); diff --git a/ip/iproute.c b/ip/iproute.c index bdbe5e691b51085fd895705b75d6391dcc984f30..c8603d66f75b43c24ab54b83d50cebb74327ee5b 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -57,6 +57,7 @@ allocroute(int type) memset(r, 0, n); r->type = type; r->ifc = nil; + r->ref = 1; return r; } @@ -271,7 +272,8 @@ addnode(Fs *f, Route **cur, Route *new) p->type = new->type; p->ifcid = -1; copygate(p, new); - } + } else if(new->type & Rifc) + p->ref++; freeroute(new); break; case Rcontained: @@ -404,15 +406,17 @@ v4delroute(Fs *f, uchar *a, uchar *mask, int dolock) r = looknode(&f->v4root[h], &rt); if(r) { p = *r; - *r = 0; - addqueue(&f->queue, p->left); - addqueue(&f->queue, p->mid); - addqueue(&f->queue, p->right); - freeroute(p); - while(p = f->queue) { - f->queue = p->mid; - walkadd(f, &f->v4root[h], p->left); + if(--(p->ref) == 0){ + *r = 0; + addqueue(&f->queue, p->left); + addqueue(&f->queue, p->mid); + addqueue(&f->queue, p->right); freeroute(p); + while(p = f->queue) { + f->queue = p->mid; + walkadd(f, &f->v4root[h], p->left); + freeroute(p); + } } } if(dolock) @@ -445,15 +449,17 @@ v6delroute(Fs *f, uchar *a, uchar *mask, int dolock) r = looknode(&f->v6root[h], &rt); if(r) { p = *r; - *r = 0; - addqueue(&f->queue, p->left); - addqueue(&f->queue, p->mid); - addqueue(&f->queue, p->right); - freeroute(p); - while(p = f->queue) { - f->queue = p->mid; - walkadd(f, &f->v6root[h], p->left); + if(--(p->ref) == 0){ + *r = 0; + addqueue(&f->queue, p->left); + addqueue(&f->queue, p->mid); + addqueue(&f->queue, p->right); freeroute(p); + while(p = f->queue) { + f->queue = p->mid; + walkadd(f, &f->v6root[h], p->left); + freeroute(p); + } } } if(dolock) diff --git a/pc/clock.c b/pc/clock.c index a35b2309f0b8490a467dec259ce8859b1ef941b7..f7266088aca71cc0b9a5a2fe9baf83924c893f90 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -10,7 +10,7 @@ void clockintr(Ureg* ureg, void*) { // this needs to be here for synchronizing mp clocks - // see mp.c's squidboy() + // see pc/mp.c's squidboy() fastticks(nil); if(m->flushmmu){ diff --git a/pc/uarti8250.c b/pc/uarti8250.c index 22d0e33d5bdd008d360a5e965bd01e15804791f5..508df314b62ad4ec23d72df1266755e7890775a5 100644 --- a/pc/uarti8250.c +++ b/pc/uarti8250.c @@ -379,9 +379,9 @@ i8250baud(Uart* uart, int baud) Ctlr *ctlr; /* - * Set the baudrate by calculating and setting the baudrate - * generator constant. This will work with fairly non-standard - * baudrates. + * Set the Baud rate by calculating and setting the Baud rate + * Generator Constant. This will work with fairly non-standard + * Baud rates. */ if(uart->freq == 0 || baud <= 0) return -1;