Author: melifaro Date: Mon Sep 7 10:13:54 2020 New Revision: 365404 URL: https://svnweb.freebsd.org/changeset/base/365404
Log: 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 Modified: head/sys/net/route.c Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Mon Sep 7 07:44:14 2020 (r365403) +++ head/sys/net/route.c Mon Sep 7 10:13:54 2020 (r365404) @@ -883,7 +883,6 @@ rt_maskedcopy(struct sockaddr *src, struct sockaddr *d * 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 fi 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 fi * 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 fi 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); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"