- /*
- * Smash the current notion of the gateway to
- * this destination. This is probably not right,
- * as it's conceivable a flurry of redirects could
- * cause the gateway value to fluctuate wildly during
- * dynamic routing reconfiguration.
- */
- rt->rt_gateway = *gateway;
- rtfree(rt);
- rtstat.rts_newgateway++;
- return;
+ if (((rt->rt_flags & RTF_HOST) == 0) && (flags & RTF_HOST)) {
+ /*
+ * Changing from route to gateway => route to host.
+ * Create new route, rather than smashing route to net.
+ */
+ rtfree(rt);
+ rtinit(dst, gateway, flags);
+ rtstat.rts_newgateway++;
+ } else {
+ /*
+ * Smash the current notion of the gateway to
+ * this destination. This is probably not right,
+ * as it's conceivable a flurry of redirects could
+ * cause the gateway value to fluctuate wildly during
+ * dynamic routing reconfiguration.
+ */
+ rt->rt_gateway = *gateway;
+ rtfree(rt);
+ rtstat.rts_newgateway++;
+ }