Make NFS address selection use fib4_lookup().
fib4_lookup_nh_ represents pre-epoch generation of fib api, providing less guarantees over pointer validness and requiring on-stack data copying. Switch call to use new fib4_lookup(), allowing to eventually deprecate old api. Differential Revision: https://reviews.freebsd.org/D24977
This commit is contained in:
parent
5f29c9b8e0
commit
79ea6f1c8c
@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet/if_ether.h>
|
||||
#include <netinet6/ip6_var.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/route/nhop.h>
|
||||
|
||||
#include <fs/nfsclient/nfs_kdtrace.h>
|
||||
|
||||
@ -976,24 +977,29 @@ nfscl_getmyip(struct nfsmount *nmp, struct in6_addr *paddr, int *isinet6p)
|
||||
#endif
|
||||
#ifdef INET
|
||||
if (nmp->nm_nam->sa_family == AF_INET) {
|
||||
struct epoch_tracker et;
|
||||
struct nhop_object *nh;
|
||||
struct sockaddr_in *sin;
|
||||
struct nhop4_extended nh_ext;
|
||||
struct in_addr addr = {};
|
||||
|
||||
sin = (struct sockaddr_in *)nmp->nm_nam;
|
||||
NET_EPOCH_ENTER(et);
|
||||
CURVNET_SET(CRED_TO_VNET(nmp->nm_sockreq.nr_cred));
|
||||
error = fib4_lookup_nh_ext(fibnum, sin->sin_addr, 0, 0,
|
||||
&nh_ext);
|
||||
nh = fib4_lookup(fibnum, sin->sin_addr, 0, NHR_NONE, 0);
|
||||
CURVNET_RESTORE();
|
||||
if (error != 0)
|
||||
if (nh != NULL)
|
||||
addr = IA_SIN(ifatoia(nh->nh_ifa))->sin_addr;
|
||||
NET_EPOCH_EXIT(et);
|
||||
if (nh == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (IN_LOOPBACK(ntohl(nh_ext.nh_src.s_addr))) {
|
||||
if (IN_LOOPBACK(ntohl(addr.s_addr))) {
|
||||
/* Ignore loopback addresses */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
*isinet6p = 0;
|
||||
*((struct in_addr *)paddr) = nh_ext.nh_src;
|
||||
*((struct in_addr *)paddr) = addr;
|
||||
|
||||
return (u_int8_t *)paddr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user