-/* $OpenBSD: if_spppsubr.c,v 1.154 2016/06/14 20:44:43 sthen Exp $ */
+/* $OpenBSD: if_spppsubr.c,v 1.155 2016/07/11 13:06:31 bluhm Exp $ */
/*
* Synchronous PPP link level subroutines.
*
rt->rt_gateway->sa_family ||
!ISSET(rt->rt_flags, RTF_GATEWAY))
return (0); /* do not modify non-gateway routes */
- rt_setgate(rt, rt->rt_ifa->ifa_dstaddr);
+ rt_setgate(rt, rt->rt_ifa->ifa_dstaddr, ifp->if_rdomain);
}
return (0);
}
-/* $OpenBSD: route.c,v 1.310 2016/07/11 09:23:06 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.311 2016/07/11 13:06:31 bluhm Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
struct pool rttimer_pool; /* pool for rttimer structures */
void rt_timer_init(void);
+void rt_setgwroute(struct rtentry *, u_int);
int rtflushclone1(struct rtentry *, void *, u_int);
void rtflushclone(unsigned int, struct rtentry *);
int rt_if_remove_rtdelete(struct rtentry *, void *, u_int);
struct rtentry *
_rtalloc(struct sockaddr *dst, uint32_t *src, int flags, unsigned int rtableid)
{
- struct rtentry *rt, *nhrt;
+ struct rtentry *rt;
rt = rt_match(dst, src, flags, rtableid);
if (rtisvalid(rt->rt_gwroute))
return (rt);
+ rt_setgwroute(rt, rtableid);
+
+ return (rt);
+}
+
+void
+rt_setgwroute(struct rtentry *rt, u_int rtableid)
+{
+ struct rtentry *nhrt;
+
rtfree(rt->rt_gwroute);
rt->rt_gwroute = NULL;
* this behavior. But it is safe since rt_checkgate() wont
* allow us to us this route later on.
*/
- nhrt = rt_match(rt->rt_gateway, NULL, flags | RT_RESOLVE,
- rtable_l2(rtableid));
+ nhrt = rt_match(rt->rt_gateway, NULL, RT_RESOLVE, rtable_l2(rtableid));
if (nhrt == NULL)
- return (rt);
+ return;
/*
* Next hop must be reachable, this also prevents rtentry
*/
if (ISSET(nhrt->rt_flags, RTF_CLONING|RTF_GATEWAY)) {
rtfree(nhrt);
- return (rt);
+ return;
}
/* Next hop entry must be UP and on the same interface. */
if (!ISSET(nhrt->rt_flags, RTF_UP) || nhrt->rt_ifidx != rt->rt_ifidx) {
rtfree(nhrt);
- return (rt);
+ return;
}
/*
* do the magic for us.
*/
rt->rt_gwroute = nhrt;
-
- return (rt);
}
void
flags |= RTF_MODIFIED;
prio = rt->rt_priority;
stat = &rtstat.rts_newgateway;
- rt_setgate(rt, gateway);
+ rt_setgate(rt, gateway, rdomain);
}
} else
error = EHOSTUNREACH;
* the routing table because the radix MPATH code use
* it to (re)order routes.
*/
- if ((error = rt_setgate(rt, info->rti_info[RTAX_GATEWAY]))) {
+ if ((error = rt_setgate(rt, info->rti_info[RTAX_GATEWAY],
+ tableid))) {
ifafree(ifa);
rtfree(rt->rt_parent);
rtfree(rt->rt_gwroute);
}
int
-rt_setgate(struct rtentry *rt, struct sockaddr *gate)
+rt_setgate(struct rtentry *rt, struct sockaddr *gate, u_int rtableid)
{
int glen = ROUNDUP(gate->sa_len);
struct sockaddr *sa;
}
memmove(rt->rt_gateway, gate, glen);
- rtfree(rt->rt_gwroute);
- rt->rt_gwroute = NULL;
+ if (ISSET(rt->rt_flags, RTF_GATEWAY))
+ rt_setgwroute(rt, rtableid);
return (0);
}
-/* $OpenBSD: route.h,v 1.139 2016/07/11 09:23:06 mpi Exp $ */
+/* $OpenBSD: route.h,v 1.140 2016/07/11 13:06:31 bluhm Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
void rt_sendmsg(struct rtentry *, int, u_int);
void rt_sendaddrmsg(struct rtentry *, int, struct ifaddr *);
void rt_missmsg(int, struct rt_addrinfo *, int, uint8_t, u_int, int, u_int);
-int rt_setgate(struct rtentry *, struct sockaddr *);
+int rt_setgate(struct rtentry *, struct sockaddr *, u_int);
int rt_checkgate(struct rtentry *, struct rtentry **);
void rt_setmetrics(u_long, const struct rt_metrics *, struct rt_kmetrics *);
void rt_getmetrics(const struct rt_kmetrics *, struct rt_metrics *);