shithub: riscv

Download patch

ref: 8dd003eb04aacf13c4a3a3123269a980c03504f9
parent: 1de2698dc824b995781c8525e85b4445d0648a04
author: cinap_lenrek <[email protected]>
date: Tue Jun 19 17:17:15 EDT 2018

devip: fix flush, copy tag when replacing route entry

--- a/sys/src/9/ip/iproute.c
+++ b/sys/src/9/ip/iproute.c
@@ -193,6 +193,7 @@
 		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 @@
 {
 	Cmdbuf *cb;
 	IPaux *a;
+	Route *x, r;
 
 	cb = parsecmd(p, n);
 	if(waserror()){
@@ -977,19 +979,22 @@
 		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));