- if (!equal(&rt->rt_router, gate) && (rt->rt_state & RTS_INTERNAL) == 0)
- doioctl++;
- if (metric != rt->rt_metric) {
- metricchanged++;
- if (metric == HOPCNT_INFINITY)
+ if ((rt->rt_state & RTS_INTERNAL) == 0) {
+ /*
+ * If changing to different router, we need to add
+ * new route and delete old one if in the kernel.
+ * If the router is the same, we need to delete
+ * the route if has become unreachable, or re-add
+ * it if it had been unreachable.
+ */
+ if (!equal(&rt->rt_router, gate)) {
+ add++;
+ if (rt->rt_metric != HOPCNT_INFINITY)
+ delete++;
+ } else if (metric == HOPCNT_INFINITY)