Date: Fri, 25 May 2018 19:48:27 +0000 (UTC) From: Matt Macy <mmacy@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334222 - head/sys/net Message-ID: <201805251948.w4PJmRbj098244@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mmacy Date: Fri May 25 19:48:26 2018 New Revision: 334222 URL: https://svnweb.freebsd.org/changeset/base/334222 Log: rtrequest1_fib: we need to always bump the ifaddr refcount when we take a reference from an rtentry. r334118 introduced a case when this was not done. While we're here make the intent more obvious by moving the refcount bump down to when we know we'll actually need it. Reported by: markj Modified: head/sys/net/route.c Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Fri May 25 19:36:26 2018 (r334221) +++ head/sys/net/route.c Fri May 25 19:48:26 2018 (r334222) @@ -1586,12 +1586,9 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru error = rt_getifa_fib(info, fibnum); if (error) return (error); - } else - ifa_ref(info->rti_ifa); - ifa = info->rti_ifa; + } rt = uma_zalloc(V_rtzone, M_NOWAIT); if (rt == NULL) { - ifa_free(ifa); return (ENOBUFS); } rt->rt_flags = RTF_UP | flags; @@ -1600,7 +1597,6 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru * Add the gateway. Possibly re-malloc-ing the storage for it. */ if ((error = rt_setgate(rt, dst, gateway)) != 0) { - ifa_free(ifa); uma_zfree(V_rtzone, rt); return (error); } @@ -1623,6 +1619,8 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru * This moved from below so that rnh->rnh_addaddr() can * examine the ifa and ifa->ifa_ifp if it so desires. */ + ifa = info->rti_ifa; + ifa_ref(ifa); rt->rt_ifa = ifa; rt->rt_ifp = ifa->ifa_ifp; rt->rt_weight = 1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805251948.w4PJmRbj098244>