svn commit: r361573 - head/sys/netinet6
Alexander V. Chernikov
melifaro at FreeBSD.org
Thu May 28 07:29:45 UTC 2020
Author: melifaro
Date: Thu May 28 07:29:44 2020
New Revision: 361573
URL: https://svnweb.freebsd.org/changeset/base/361573
Log:
Replace ip6_ouput fib6_lookup_nh_<ext|basic> calls with fib6_lookup().
fib6_lookup_nh_ represents pre-epoch generation of fib api,
providing less guarantees over pointer validness and requiring
on-stack data copying.
Conversion is straight-forwarded, as the only 2 differences are
requirement of running in network epoch and the need to handle
RTF_GATEWAY case in the caller code.
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D24973
Modified:
head/sys/netinet6/ip6_output.c
Modified: head/sys/netinet6/ip6_output.c
==============================================================================
--- head/sys/netinet6/ip6_output.c Thu May 28 07:26:18 2020 (r361572)
+++ head/sys/netinet6/ip6_output.c Thu May 28 07:29:44 2020 (r361573)
@@ -736,7 +736,7 @@ again:
counter_u64_add(nh->nh_pksent, 1);
}
} else {
- struct nhop6_extended nh6;
+ struct nhop_object *nh;
struct in6_addr kdst;
uint32_t scopeid;
@@ -766,20 +766,19 @@ again:
}
}
- error = fib6_lookup_nh_ext(fibnum, &kdst, scopeid, NHR_REF, 0,
- &nh6);
- if (error != 0) {
+ nh = fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0);
+ if (nh == NULL) {
IP6STAT_INC(ip6s_noroute);
/* No ifp in6_ifstat_inc(ifp, ifs6_out_discard); */
error = EHOSTUNREACH;;
goto bad;
}
- ifp = nh6.nh_ifp;
- mtu = nh6.nh_mtu;
- dst->sin6_addr = nh6.nh_addr;
- ia = nh6.nh_ia;
- fib6_free_nh_ext(fibnum, &nh6);
+ ifp = nh->nh_ifp;
+ mtu = nh->nh_mtu;
+ ia = ifatoia6(nh->nh_ifa);
+ if (nh->nh_flags & NHF_GATEWAY)
+ dst->sin6_addr = nh->gw6_sa.sin6_addr;
nonh6lookup:
;
}
@@ -1449,23 +1448,22 @@ ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int
static int
ip6_getpmtu_ctl(u_int fibnum, const struct in6_addr *dst, u_long *mtup)
{
- struct nhop6_extended nh6;
+ struct epoch_tracker et;
+ struct nhop_object *nh;
struct in6_addr kdst;
uint32_t scopeid;
- struct ifnet *ifp;
- u_long mtu;
int error;
in6_splitscope(dst, &kdst, &scopeid);
- if (fib6_lookup_nh_ext(fibnum, &kdst, scopeid, NHR_REF, 0, &nh6) != 0)
- return (EHOSTUNREACH);
- ifp = nh6.nh_ifp;
- mtu = nh6.nh_mtu;
+ NET_EPOCH_ENTER(et);
+ nh = fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0);
+ if (nh != NULL)
+ error = ip6_calcmtu(nh->nh_ifp, dst, nh->nh_mtu, mtup, NULL, 0);
+ else
+ error = EHOSTUNREACH;
+ NET_EPOCH_EXIT(et);
- error = ip6_calcmtu(ifp, dst, mtu, mtup, NULL, 0);
- fib6_free_nh_ext(fibnum, &nh6);
-
return (error);
}
@@ -1484,12 +1482,14 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, int do_lookup,
struct ifnet *ifp, const struct in6_addr *dst, u_long *mtup,
int *alwaysfragp, u_int fibnum, u_int proto)
{
- struct nhop6_basic nh6;
+ struct nhop_object *nh;
struct in6_addr kdst;
uint32_t scopeid;
struct sockaddr_in6 *sa6_dst, sin6;
u_long mtu;
+ NET_EPOCH_ASSERT();
+
mtu = 0;
if (ro_pmtu == NULL || do_lookup) {
@@ -1512,9 +1512,9 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, int do_lookup,
sa6_dst->sin6_addr = *dst;
in6_splitscope(dst, &kdst, &scopeid);
- if (fib6_lookup_nh_basic(fibnum, &kdst, scopeid, 0, 0,
- &nh6) == 0) {
- mtu = nh6.nh_mtu;
+ nh = fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0);
+ if (nh != NULL) {
+ mtu = nh->nh_mtu;
if (ro_pmtu != NULL)
ro_pmtu->ro_mtu = mtu;
}
More information about the svn-src-all
mailing list