svn commit: r361574 - head/sys/netinet
Alexander V. Chernikov
melifaro at FreeBSD.org
Thu May 28 07:31:54 UTC 2020
Author: melifaro
Date: Thu May 28 07:31:53 2020
New Revision: 361574
URL: https://svnweb.freebsd.org/changeset/base/361574
Log:
Switch ip_output/icmp_reflect rt lookup calls with fib4_lookup.
fib4_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/D24976
Modified:
head/sys/netinet/ip_icmp.c
head/sys/netinet/ip_output.c
Modified: head/sys/netinet/ip_icmp.c
==============================================================================
--- head/sys/netinet/ip_icmp.c Thu May 28 07:29:44 2020 (r361573)
+++ head/sys/netinet/ip_icmp.c Thu May 28 07:31:53 2020 (r361574)
@@ -764,7 +764,7 @@ icmp_reflect(struct mbuf *m)
struct ifnet *ifp;
struct in_ifaddr *ia;
struct in_addr t;
- struct nhop4_extended nh_ext;
+ struct nhop_object *nh;
struct mbuf *opts = NULL;
int optlen = (ip->ip_hl << 2) - sizeof(struct ip);
@@ -851,12 +851,13 @@ icmp_reflect(struct mbuf *m)
* When we don't have a route back to the packet source, stop here
* and drop the packet.
*/
- if (fib4_lookup_nh_ext(M_GETFIB(m), ip->ip_dst, 0, 0, &nh_ext) != 0) {
+ nh = fib4_lookup(M_GETFIB(m), ip->ip_dst, 0, NHR_NONE, 0);
+ if (nh == NULL) {
m_freem(m);
ICMPSTAT_INC(icps_noroute);
goto done;
}
- t = nh_ext.nh_src;
+ t = IA_SIN(ifatoia(nh->nh_ifa))->sin_addr;
match:
#ifdef MAC
mac_netinet_icmp_replyinplace(m);
Modified: head/sys/netinet/ip_output.c
==============================================================================
--- head/sys/netinet/ip_output.c Thu May 28 07:29:44 2020 (r361573)
+++ head/sys/netinet/ip_output.c Thu May 28 07:31:53 2020 (r361574)
@@ -512,11 +512,10 @@ again:
mtu = ifp->if_mtu;
src = IA_SIN(ia)->sin_addr;
} else {
- struct nhop4_extended nh;
+ struct nhop_object *nh;
- bzero(&nh, sizeof(nh));
- if (fib4_lookup_nh_ext(M_GETFIB(m), ip->ip_dst, 0, 0, &nh) !=
- 0) {
+ nh = fib4_lookup(M_GETFIB(m), ip->ip_dst, 0, NHR_NONE, 0);
+ if (nh == NULL) {
#if defined(IPSEC) || defined(IPSEC_SUPPORT)
/*
* There is no route for this packet, but it is
@@ -530,8 +529,8 @@ again:
error = EHOSTUNREACH;
goto bad;
}
- ifp = nh.nh_ifp;
- mtu = nh.nh_mtu;
+ ifp = nh->nh_ifp;
+ mtu = nh->nh_mtu;
/*
* We are rewriting here dst to be gw actually, contradicting
* comment at the beginning of the function. However, in this
@@ -540,10 +539,11 @@ again:
* function, the dst would be rewritten by ip_output_pfil().
*/
MPASS(dst == &sin);
- dst->sin_addr = nh.nh_addr;
- ia = nh.nh_ia;
- src = nh.nh_src;
- isbroadcast = (((nh.nh_flags & (NHF_HOST | NHF_BROADCAST)) ==
+ if (nh->nh_flags & NHF_GATEWAY)
+ dst->sin_addr = nh->gw4_sa.sin_addr;
+ ia = ifatoia(nh->nh_ifa);
+ src = IA_SIN(ia)->sin_addr;
+ isbroadcast = (((nh->nh_flags & (NHF_HOST | NHF_BROADCAST)) ==
(NHF_HOST | NHF_BROADCAST)) ||
((ifp->if_flags & IFF_BROADCAST) &&
in_ifaddr_broadcast(dst->sin_addr, ia)));
More information about the svn-src-all
mailing list