M ip/ip.h => ip/ip.h +1 -0
@@ 383,6 383,7 @@ struct RouteTree
uchar ifcid; /* must match ifc->id */
Ipifc *ifc;
char tag[4];
+ int ref;
};
struct V4route
M ip/ipifc.c => ip/ipifc.c +4 -2
@@ 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);
M ip/iproute.c => ip/iproute.c +23 -17
@@ 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)
M pc/clock.c => pc/clock.c +1 -1
@@ 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){
M pc/uarti8250.c => pc/uarti8250.c +3 -3
@@ 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;