Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/route.c
Show First 20 Lines • Show All 1,989 Lines • ▼ Show 20 Lines | rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum) | ||||
struct sockaddr *netmask; | struct sockaddr *netmask; | ||||
struct rtentry *rt = NULL; | struct rtentry *rt = NULL; | ||||
struct rt_addrinfo info; | struct rt_addrinfo info; | ||||
int error = 0; | int error = 0; | ||||
int startfib, endfib; | int startfib, endfib; | ||||
char tempbuf[_SOCKADDR_TMPSIZE]; | char tempbuf[_SOCKADDR_TMPSIZE]; | ||||
int didwork = 0; | int didwork = 0; | ||||
int a_failure = 0; | int a_failure = 0; | ||||
static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; | struct sockaddr_dl *sdl = NULL; | ||||
struct rib_head *rnh; | struct rib_head *rnh; | ||||
if (flags & RTF_HOST) { | if (flags & RTF_HOST) { | ||||
dst = ifa->ifa_dstaddr; | dst = ifa->ifa_dstaddr; | ||||
netmask = NULL; | netmask = NULL; | ||||
} else { | } else { | ||||
dst = ifa->ifa_addr; | dst = ifa->ifa_addr; | ||||
netmask = ifa->ifa_netmask; | netmask = ifa->ifa_netmask; | ||||
Show All 34 Lines | if (cmd == RTM_DELETE) { | ||||
* If it's a net, mask off the host bits | * If it's a net, mask off the host bits | ||||
* (Assuming we have a mask) | * (Assuming we have a mask) | ||||
* XXX this is kinda inet specific.. | * XXX this is kinda inet specific.. | ||||
*/ | */ | ||||
if (netmask != NULL) { | if (netmask != NULL) { | ||||
rt_maskedcopy(dst, (struct sockaddr *)tempbuf, netmask); | rt_maskedcopy(dst, (struct sockaddr *)tempbuf, netmask); | ||||
dst = (struct sockaddr *)tempbuf; | dst = (struct sockaddr *)tempbuf; | ||||
} | } | ||||
} else if (cmd == RTM_ADD) { | |||||
sdl = (struct sockaddr_dl *)tempbuf; | |||||
bzero(sdl, sizeof(struct sockaddr_dl)); | |||||
sdl->sdl_family = AF_LINK; | |||||
sdl->sdl_len = sizeof(struct sockaddr_dl); | |||||
sdl->sdl_type = ifa->ifa_ifp->if_type; | |||||
sdl->sdl_index = ifa->ifa_ifp->if_index; | |||||
} | } | ||||
/* | /* | ||||
* Now go through all the requested tables (fibs) and do the | * Now go through all the requested tables (fibs) and do the | ||||
* requested action. Realistically, this will either be fib 0 | * requested action. Realistically, this will either be fib 0 | ||||
* for protocols that don't do multiple tables or all the | * for protocols that don't do multiple tables or all the | ||||
* tables for those that do. | * tables for those that do. | ||||
*/ | */ | ||||
for ( fibnum = startfib; fibnum <= endfib; fibnum++) { | for ( fibnum = startfib; fibnum <= endfib; fibnum++) { | ||||
if (cmd == RTM_DELETE) { | if (cmd == RTM_DELETE) { | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | #endif | ||||
info.rti_ifa = ifa; | info.rti_ifa = ifa; | ||||
info.rti_flags = flags | | info.rti_flags = flags | | ||||
(ifa->ifa_flags & ~IFA_RTSELF) | RTF_PINNED; | (ifa->ifa_flags & ~IFA_RTSELF) | RTF_PINNED; | ||||
info.rti_info[RTAX_DST] = dst; | info.rti_info[RTAX_DST] = dst; | ||||
/* | /* | ||||
* doing this for compatibility reasons | * doing this for compatibility reasons | ||||
*/ | */ | ||||
if (cmd == RTM_ADD) | if (cmd == RTM_ADD) | ||||
info.rti_info[RTAX_GATEWAY] = | info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)sdl; | ||||
(struct sockaddr *)&null_sdl; | |||||
else | else | ||||
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; | info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; | ||||
info.rti_info[RTAX_NETMASK] = netmask; | info.rti_info[RTAX_NETMASK] = netmask; | ||||
error = rtrequest1_fib(cmd, &info, &rt, fibnum); | error = rtrequest1_fib(cmd, &info, &rt, fibnum); | ||||
if (error == 0 && rt != NULL) { | if (error == 0 && rt != NULL) { | ||||
/* | /* | ||||
* notify any listening routing agents of the change | * notify any listening routing agents of the change | ||||
Show All 10 Lines | #ifdef RADIX_MPATH | ||||
if (memcmp(rt->rt_ifa->ifa_addr, | if (memcmp(rt->rt_ifa->ifa_addr, | ||||
ifa->ifa_addr, ifa->ifa_addr->sa_len)) { | ifa->ifa_addr, ifa->ifa_addr->sa_len)) { | ||||
ifa_free(rt->rt_ifa); | ifa_free(rt->rt_ifa); | ||||
ifa_ref(ifa); | ifa_ref(ifa); | ||||
rt->rt_ifp = ifa->ifa_ifp; | rt->rt_ifp = ifa->ifa_ifp; | ||||
rt->rt_ifa = ifa; | rt->rt_ifa = ifa; | ||||
} | } | ||||
#endif | #endif | ||||
/* | |||||
* doing this for compatibility reasons | |||||
*/ | |||||
if (cmd == RTM_ADD) { | |||||
((struct sockaddr_dl *)rt->rt_gateway)->sdl_type = | |||||
rt->rt_ifp->if_type; | |||||
((struct sockaddr_dl *)rt->rt_gateway)->sdl_index = | |||||
rt->rt_ifp->if_index; | |||||
} | |||||
RT_ADDREF(rt); | RT_ADDREF(rt); | ||||
RT_UNLOCK(rt); | RT_UNLOCK(rt); | ||||
rt_newaddrmsg_fib(cmd, ifa, error, rt, fibnum); | rt_newaddrmsg_fib(cmd, ifa, error, rt, fibnum); | ||||
RT_LOCK(rt); | RT_LOCK(rt); | ||||
RT_REMREF(rt); | RT_REMREF(rt); | ||||
if (cmd == RTM_DELETE) { | if (cmd == RTM_DELETE) { | ||||
/* | /* | ||||
* If we are deleting, and we found an entry, | * If we are deleting, and we found an entry, | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |