Consistently use the same gateway when adding/deleting interface routes.
Use the same link-level gateway when adding or deleting interface routes. This helps nexthop checking in the upcoming multipath changes. Differential Revision: https://reviews.freebsd.org/D26317
This commit is contained in:
parent
eddaeb2095
commit
05aca418f4
@ -883,7 +883,6 @@ rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, struct sockaddr *netma
|
||||
* Set up a routing table entry, normally
|
||||
* for an interface.
|
||||
*/
|
||||
#define _SOCKADDR_TMPSIZE 128 /* Not too big.. kernel stack size is limited */
|
||||
static inline int
|
||||
rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
|
||||
{
|
||||
@ -895,10 +894,10 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
|
||||
struct rt_addrinfo info;
|
||||
int error = 0;
|
||||
int startfib, endfib;
|
||||
char tempbuf[_SOCKADDR_TMPSIZE];
|
||||
struct sockaddr_storage ss;
|
||||
int didwork = 0;
|
||||
int a_failure = 0;
|
||||
struct sockaddr_dl_short *sdl = NULL;
|
||||
struct sockaddr_dl_short sdl;
|
||||
struct rib_head *rnh;
|
||||
|
||||
if (flags & RTF_HOST) {
|
||||
@ -946,17 +945,15 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
|
||||
* XXX this is kinda inet specific..
|
||||
*/
|
||||
if (netmask != NULL) {
|
||||
rt_maskedcopy(dst, (struct sockaddr *)tempbuf, netmask);
|
||||
dst = (struct sockaddr *)tempbuf;
|
||||
rt_maskedcopy(dst, (struct sockaddr *)&ss, netmask);
|
||||
dst = (struct sockaddr *)&ss;
|
||||
}
|
||||
} else if (cmd == RTM_ADD) {
|
||||
sdl = (struct sockaddr_dl_short *)tempbuf;
|
||||
bzero(sdl, sizeof(struct sockaddr_dl_short));
|
||||
sdl->sdl_family = AF_LINK;
|
||||
sdl->sdl_len = sizeof(struct sockaddr_dl_short);
|
||||
sdl->sdl_type = ifa->ifa_ifp->if_type;
|
||||
sdl->sdl_index = ifa->ifa_ifp->if_index;
|
||||
}
|
||||
}
|
||||
bzero(&sdl, sizeof(struct sockaddr_dl_short));
|
||||
sdl.sdl_family = AF_LINK;
|
||||
sdl.sdl_len = sizeof(struct sockaddr_dl_short);
|
||||
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
|
||||
* requested action. Realistically, this will either be fib 0
|
||||
@ -1012,13 +1009,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fibnum)
|
||||
info.rti_flags = flags |
|
||||
(ifa->ifa_flags & ~IFA_RTSELF) | RTF_PINNED;
|
||||
info.rti_info[RTAX_DST] = dst;
|
||||
/*
|
||||
* doing this for compatibility reasons
|
||||
*/
|
||||
if (cmd == RTM_ADD)
|
||||
info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)sdl;
|
||||
else
|
||||
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
|
||||
info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&sdl;
|
||||
info.rti_info[RTAX_NETMASK] = netmask;
|
||||
NET_EPOCH_ENTER(et);
|
||||
error = rib_action(fibnum, cmd, &info, &rc);
|
||||
|
Loading…
Reference in New Issue
Block a user