summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2018-06-19 21:17:15 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2018-06-19 21:17:15 +0200
commit8dd003eb04aacf13c4a3a3123269a980c03504f9 (patch)
tree289ca06552b0f7a0dc0517dddfbcec22f8535f77
parent1de2698dc824b995781c8525e85b4445d0648a04 (diff)
devip: fix flush, copy tag when replacing route entry
-rw-r--r--sys/src/9/ip/iproute.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/src/9/ip/iproute.c b/sys/src/9/ip/iproute.c
index 0681b2464..d30991a33 100644
--- a/sys/src/9/ip/iproute.c
+++ b/sys/src/9/ip/iproute.c
@@ -193,6 +193,7 @@ copygate(Route *old, Route *new)
memmove(old->v4.gate, new->v4.gate, IPv4addrlen);
else
ipmove(old->v6.gate, new->v6.gate);
+ strncpy(old->tag, new->tag, sizeof(new->tag));
}
/*
@@ -967,6 +968,7 @@ routewrite(Fs *f, Chan *c, char *p, int n)
{
Cmdbuf *cb;
IPaux *a;
+ Route *x, r;
cb = parsecmd(p, n);
if(waserror()){
@@ -977,19 +979,22 @@ routewrite(Fs *f, Chan *c, char *p, int n)
error("short control request");
if(strcmp(cb->f[0], "flush") == 0){
char *tag = cb->nf < 2 ? nil : cb->f[1];
- Route *x;
int h;
wlock(&routelock);
for(h = 0; h < nelem(f->v4root); h++)
- while((x = looknodetag(f->v4root[h], tag)) != nil)
- routerem(f, x);
+ while((x = looknodetag(f->v4root[h], tag)) != nil){
+ memmove(&r, x, sizeof(RouteTree) + sizeof(V4route));
+ routerem(f, &r);
+ }
for(h = 0; h < nelem(f->v6root); h++)
- while((x = looknodetag(f->v6root[h], tag)) != nil)
- routerem(f, x);
+ while((x = looknodetag(f->v6root[h], tag)) != nil){
+ memmove(&r, x, sizeof(RouteTree) + sizeof(V6route));
+ routerem(f, &r);
+ }
wunlock(&routelock);
} else if(strcmp(cb->f[0], "add") == 0 || strcmp(cb->f[0], "remove") == 0){
- Route r = parseroute(f, cb->f, cb->nf);
+ r = parseroute(f, cb->f, cb->nf);
if(*r.tag == 0){
a = c->aux;
strncpy(r.tag, a->tag, sizeof(r.tag));