-/* $OpenBSD: rtsock.c,v 1.174 2015/10/23 10:22:29 claudio Exp $ */
+/* $OpenBSD: rtsock.c,v 1.175 2015/10/23 13:41:41 bluhm Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
info.rti_info[RTAX_GATEWAY]->sa_len)) {
newgate = 1;
}
- if (info.rti_info[RTAX_GATEWAY] != NULL &&
- (error = rt_setgate(rt, info.rti_info[RTAX_GATEWAY],
- tableid)))
- goto flush;
/*
- * new gateway could require new ifaddr, ifp;
+ * Check reachable gateway before changing the route.
+ * New gateway could require new ifaddr, ifp;
* flags may also be different; ifp may be specified
- * by ll sockaddr when protocol address is ambiguous
+ * by ll sockaddr when protocol address is ambiguous.
*/
if (newgate || info.rti_info[RTAX_IFP] != NULL ||
info.rti_info[RTAX_IFA] != NULL) {
goto flush;
ifa = info.rti_ifa;
}
+ if (info.rti_info[RTAX_GATEWAY] != NULL &&
+ (error = rt_setgate(rt, info.rti_info[RTAX_GATEWAY],
+ tableid)))
+ goto flush;
if (ifa) {
if (rt->rt_ifa != ifa) {
if (rt->rt_ifa->ifa_rtrequest)