On 06/09/16(Tue) 14:03, Stuart Henderson wrote:
> [...]
> And
> if you're trying to "route change" to a non-allowed address when
> you _already_ have a default route, you hit a repeatable kassert
> '"rt->rt_gwroute != NULL" failed: file "../../../../net/route.c",
> line 221'. (see below for trace/table for this one).
Diff below fixes that. Only free the old cached route if the new
one is valid.
ok?
Index: net/route.c
===================================================================
RCS file: /cvs/src/sys/net/route.c,v
retrieving revision 1.325
diff -u -p -r1.325 route.c
--- net/route.c 4 Sep 2016 15:45:42 -0000 1.325
+++ net/route.c 6 Sep 2016 13:33:11 -0000
@@ -382,7 +382,6 @@ rt_setgwroute(struct rtentry *rt, u_int
KERNEL_ASSERT_LOCKED();
KASSERT(ISSET(rt->rt_flags, RTF_GATEWAY));
- KASSERT(rt->rt_gwroute == NULL);
/* If we cannot find a valid next hop bail. */
nhrt = rt_match(rt->rt_gateway, NULL, RT_RESOLVE, rtable_l2(rtableid));
@@ -404,6 +403,10 @@ rt_setgwroute(struct rtentry *rt, u_int
return (ELOOP);
}
+ /* Next hop is valid so remove possible old cache. */
+ rt_putgwroute(rt);
+ KASSERT(rt->rt_gwroute == NULL);
+
/*
* If the MTU of next hop is 0, this will reset the MTU of the
* route to run PMTUD again from scratch.
@@ -1139,10 +1142,8 @@ rt_setgate(struct rtentry *rt, struct so
}
memmove(rt->rt_gateway, gate, glen);
- if (ISSET(rt->rt_flags, RTF_GATEWAY)) {
- rt_putgwroute(rt);
+ if (ISSET(rt->rt_flags, RTF_GATEWAY))
return (rt_setgwroute(rt, rtableid));
- }
return (0);
}