-/* $OpenBSD: route.c,v 1.212 2015/05/26 12:19:51 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.213 2015/06/06 09:31:53 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
int
rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst)
{
+ struct ifnet *ifp = ifa->ifa_ifp;
struct rtentry *rt, *nrt = NULL;
struct sockaddr_rtlabel sa_rl;
- struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK };
struct rt_addrinfo info;
- u_short rtableid = ifa->ifa_ifp->if_rdomain;
- u_int8_t prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
+ u_short rtableid = ifp->if_rdomain;
+ u_int8_t prio = ifp->if_priority + RTP_STATIC;
int error;
- sa_dl.sdl_type = ifa->ifa_ifp->if_type;
- sa_dl.sdl_index = ifa->ifa_ifp->if_index;
-
memset(&info, 0, sizeof(info));
info.rti_ifa = ifa;
info.rti_flags = flags | RTF_MPATH;
info.rti_info[RTAX_DST] = dst;
if (flags & RTF_LLINFO)
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl;
+ info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)ifp->if_sadl;
else
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
- info.rti_info[RTAX_LABEL] =
- rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl);
+ info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
#ifdef MPLS
if ((flags & RTF_MPLS) == RTF_MPLS) {
int
rt_ifa_del(struct ifaddr *ifa, int flags, struct sockaddr *dst)
{
+ struct ifnet *ifp = ifa->ifa_ifp;
struct rtentry *rt, *nrt = NULL;
struct mbuf *m = NULL;
struct sockaddr *deldst;
struct rt_addrinfo info;
struct sockaddr_rtlabel sa_rl;
- struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK };
- u_short rtableid = ifa->ifa_ifp->if_rdomain;
- u_int8_t prio = ifa->ifa_ifp->if_priority + RTP_STATIC;
+ u_short rtableid = ifp->if_rdomain;
+ u_int8_t prio = ifp->if_priority + RTP_STATIC;
int error;
#ifdef MPLS
}
}
- sa_dl.sdl_type = ifa->ifa_ifp->if_type;
- sa_dl.sdl_index = ifa->ifa_ifp->if_index;
-
memset(&info, 0, sizeof(info));
info.rti_ifa = ifa;
info.rti_flags = flags;
info.rti_info[RTAX_DST] = dst;
- if (flags & RTF_LLINFO)
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl;
- else
+ if ((flags & RTF_LLINFO) == 0)
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
- info.rti_info[RTAX_LABEL] =
- rtlabel_id2sa(ifa->ifa_ifp->if_rtlabelid, &sa_rl);
+ info.rti_info[RTAX_LABEL] = rtlabel_id2sa(ifp->if_rtlabelid, &sa_rl);
if ((flags & RTF_HOST) == 0)
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
-/* $OpenBSD: nd6.c,v 1.136 2015/05/15 12:00:57 claudio Exp $ */
+/* $OpenBSD: nd6.c,v 1.137 2015/06/06 09:31:53 mpi Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
}
if (!rt) {
if (create && ifp) {
- struct sockaddr_dl sa_dl = { sizeof(sa_dl), AF_LINK };
struct rt_addrinfo info;
int e;
if (ifa == NULL)
return (NULL);
- sa_dl.sdl_type = ifp->if_type;
- sa_dl.sdl_index = ifp->if_index;
-
/*
* Create a new route. RTF_LLINFO is necessary
* to create a Neighbor Cache entry for the
bzero(&info, sizeof(info));
info.rti_flags = RTF_UP | RTF_HOST | RTF_LLINFO;
info.rti_info[RTAX_DST] = sin6tosa(&sin6);
- info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sa_dl;
+ info.rti_info[RTAX_GATEWAY] =
+ (struct sockaddr *)ifp->if_sadl;
if ((e = rtrequest1(RTM_ADD, &info, RTP_CONNECTED,
&rt, rtableid)) != 0) {
#if 0