Author: melifaro
Date: Thu May 28 07:35:07 2020
New Revision: 361575
URL: https://svnweb.freebsd.org/changeset/base/361575

Log:
  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

Modified:
  head/sys/fs/nfsclient/nfs_clport.c

Modified: head/sys/fs/nfsclient/nfs_clport.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clport.c  Thu May 28 07:31:53 2020        
(r361574)
+++ head/sys/fs/nfsclient/nfs_clport.c  Thu May 28 07:35:07 2020        
(r361575)
@@ -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 *p
 #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;
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to