-/* $OpenBSD: route.c,v 1.259 2015/10/23 14:48:22 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.260 2015/10/24 11:58:46 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
void
rt_sendmsg(struct rtentry *rt, int cmd, u_int rtableid)
{
- struct rt_addrinfo info;
- struct sockaddr_rtlabel sa_rl;
+ struct rt_addrinfo info;
+ struct ifnet *ifp;
+ struct sockaddr_rtlabel sa_rl;
memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, &sa_rl);
- if (rt->rt_ifp != NULL) {
- info.rti_info[RTAX_IFP] = sdltosa(rt->rt_ifp->if_sadl);
+ ifp = if_get(rt->rt_ifidx);
+ if (ifp != NULL) {
+ info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
}
- rt_missmsg(cmd, &info, rt->rt_flags, rt->rt_ifp, 0, rtableid);
+ rt_missmsg(cmd, &info, rt->rt_flags, ifp, 0, rtableid);
+ if_put(ifp);
}
void
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_flags = rt->rt_flags;
- ifp = rt->rt_ifp;
+ ifp = if_get(rt->rt_ifidx);
error = rtrequest1(RTM_DELETE, &info, rt->rt_priority, &rt, tableid);
rt_missmsg(RTM_DELETE, &info, info.rti_flags, ifp, error, tableid);
if (error == 0)
rtfree(rt);
+ if_put(ifp);
return (error);
}
* loops, for example when rt->rt_gwroute points to rt.
*/
if (((rt->rt_gwroute->rt_flags & (RTF_UP|RTF_GATEWAY)) !=
- RTF_UP) || (rt->rt_gwroute->rt_ifp != ifp)) {
+ RTF_UP) || (rt->rt_gwroute->rt_ifidx != ifp->if_index)) {
rtfree(rt->rt_gwroute);
rt->rt_gwroute = NULL;
return (EHOSTUNREACH);
{
struct ifnet *ifp = vifp;
- if (rt->rt_ifp == ifp) {
+ if (rt->rt_ifidx == ifp->if_index) {
int cloning = (rt->rt_flags & RTF_CLONING);
if (rtdeletemsg(rt, id) == 0 && cloning)
{
struct ifnet *ifp = arg;
- if (rt->rt_ifp != ifp)
+ if (rt->rt_ifidx != ifp->if_index)
return (0);
/* Local routes are always usable. */
db_printf(" key="); db_print_sa(rt_key(rt));
db_printf(" mask="); db_print_sa(rt_mask(rt));
db_printf(" gw="); db_print_sa(rt->rt_gateway);
-
- db_printf(" ifp=%p ", rt->rt_ifp);
- if (rt->rt_ifp)
- db_printf("(%s)", rt->rt_ifp->if_xname);
- else
- db_printf("(NULL)");
-
+ db_printf(" ifidx=%u ", rt->rt_ifidx);
db_printf(" ifa=%p\n", rt->rt_ifa);
db_print_ifa(rt->rt_ifa);
-/* $OpenBSD: rtsock.c,v 1.175 2015/10/23 13:41:41 bluhm Exp $ */
+/* $OpenBSD: rtsock.c,v 1.176 2015/10/24 11:58:47 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
&saved_nrt->rt_rmx);
/* write back the priority the kernel used */
rtm->rtm_priority = saved_nrt->rt_priority & RTP_MASK;
- rtm->rtm_index = saved_nrt->rt_ifp->if_index;
+ rtm->rtm_index = saved_nrt->rt_ifidx;
rtm->rtm_flags = saved_nrt->rt_flags;
rtfree(saved_nrt);
}
#endif
info.rti_info[RTAX_IFP] = NULL;
info.rti_info[RTAX_IFA] = NULL;
- if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA) &&
- (ifp = rt->rt_ifp) != NULL) {
+ ifp = if_get(rt->rt_ifidx);
+ if (ifp != NULL && rtm->rtm_addrs & (RTA_IFP|RTA_IFA)) {
info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
if (ifp->if_flags & IFF_POINTOPOINT)
info.rti_info[RTAX_BRD] = NULL;
rtm->rtm_index = ifp->if_index;
}
+ if_put(ifp);
len = rt_msg2(rtm->rtm_type, RTM_VERSION, &info, NULL,
NULL);
if (len > rtm->rtm_msglen) {
rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx,
&rt->rt_rmx);
- rtm->rtm_index = rt->rt_ifp->if_index;
+ rtm->rtm_index = rt->rt_ifidx;
rtm->rtm_priority = rt->rt_priority & RTP_MASK;
rtm->rtm_flags = rt->rt_flags;
if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest)
struct walkarg *w = v;
int error = 0, size;
struct rt_addrinfo info;
+ struct ifnet *ifp;
#ifdef MPLS
struct sockaddr_mpls sa_mpls;
#endif
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
- if (rt->rt_ifp) {
- info.rti_info[RTAX_IFP] = sdltosa(rt->rt_ifp->if_sadl);
+ ifp = if_get(rt->rt_ifidx);
+ if (ifp != NULL) {
+ info.rti_info[RTAX_IFP] = sdltosa(ifp->if_sadl);
info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
- if (rt->rt_ifp->if_flags & IFF_POINTOPOINT)
+ if (ifp->if_flags & IFF_POINTOPOINT)
info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr;
}
+ if_put(ifp);
info.rti_info[RTAX_LABEL] = rtlabel_id2sa(rt->rt_labelid, &sa_rl);
#ifdef MPLS
if (rt->rt_flags & RTF_MPLS) {
rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
/* Do not account the routing table's reference. */
rtm->rtm_rmx.rmx_refcnt = rt->rt_refcnt - 1;
- rtm->rtm_index = rt->rt_ifp->if_index;
+ rtm->rtm_index = rt->rt_ifidx;
rtm->rtm_addrs = info.rti_addrs;
rtm->rtm_tableid = id;
#ifdef MPLS