svn commit: r365925 - head/sys/net/route
Alexander V. Chernikov
melifaro at FreeBSD.org
Sun Sep 20 12:31:49 UTC 2020
Author: melifaro
Date: Sun Sep 20 12:31:48 2020
New Revision: 365925
URL: https://svnweb.freebsd.org/changeset/base/365925
Log:
Fix gw updates / flag updates during route changes.
* Zero gw_sdl if switching to interface route - the assumption
that underlying storage is zeroed is incorrect with route changes.
* Apply proper flag mask to rte.
Reported by: vangyzen
Modified:
head/sys/net/route/nhop_ctl.c
head/sys/net/route/route_ctl.c
Modified: head/sys/net/route/nhop_ctl.c
==============================================================================
--- head/sys/net/route/nhop_ctl.c Sun Sep 20 09:47:28 2020 (r365924)
+++ head/sys/net/route/nhop_ctl.c Sun Sep 20 12:31:48 2020 (r365925)
@@ -205,6 +205,7 @@ static void
fill_sdl_from_ifp(struct sockaddr_dl_short *sdl, const struct ifnet *ifp)
{
+ bzero(sdl, sizeof(struct sockaddr_dl_short));
sdl->sdl_family = AF_LINK;
sdl->sdl_len = sizeof(struct sockaddr_dl_short);
sdl->sdl_index = ifp->if_index;
@@ -217,6 +218,8 @@ set_nhop_gw_from_info(struct nhop_object *nh, struct r
struct sockaddr *gw;
gw = info->rti_info[RTAX_GATEWAY];
+ KASSERT(gw != NULL, ("gw is NULL"));
+
if (info->rti_flags & RTF_GATEWAY) {
if (gw->sa_len > sizeof(struct sockaddr_in6)) {
DPRINTF("nhop SA size too big: AF %d len %u",
@@ -318,6 +321,9 @@ nhop_create_from_info(struct rib_head *rnh, struct rt_
int error;
NET_EPOCH_ASSERT();
+
+ if (info->rti_info[RTAX_GATEWAY] == NULL)
+ return (EINVAL);
nh_priv = alloc_nhop_structure();
Modified: head/sys/net/route/route_ctl.c
==============================================================================
--- head/sys/net/route/route_ctl.c Sun Sep 20 09:47:28 2020 (r365924)
+++ head/sys/net/route/route_ctl.c Sun Sep 20 12:31:48 2020 (r365925)
@@ -397,7 +397,7 @@ create_rtentry(struct rib_head *rnh, struct rt_addrinf
nhop_free(nh);
return (ENOBUFS);
}
- rt->rte_flags = RTF_UP | flags;
+ rt->rte_flags = (RTF_UP | flags) & RTE_RT_FLAG_MASK;
rt->rt_nhop = nh;
/* Fill in dst */
More information about the svn-src-head
mailing list