Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.sbin/rpcbind Pull up version 1.4:



details:   https://anonhg.NetBSD.org/src/rev/20d41a76247d
branches:  netbsd-1-5
changeset: 488881:20d41a76247d
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Sat Aug 05 17:47:14 2000 +0000

description:
Pull up version 1.4:
        When merging addresses, and no direct match is found, pick the first
        configured interface that is preferably not local or point to point.
        This appears to be what Solaris does as well.

diffstat:

 usr.sbin/rpcbind/util.c |  32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diffs (60 lines):

diff -r 2d6aa19fe9d5 -r 20d41a76247d usr.sbin/rpcbind/util.c
--- a/usr.sbin/rpcbind/util.c   Sat Aug 05 11:12:18 2000 +0000
+++ b/usr.sbin/rpcbind/util.c   Sat Aug 05 17:47:14 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.2.2.1 2000/06/23 08:16:32 hannken Exp $     */
+/*     $NetBSD: util.c,v 1.2.2.2 2000/08/05 17:47:14 fvdl Exp $        */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -108,7 +108,7 @@
 addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr,
          char *netid)
 {
-       struct ifaddrs *ifap, *ifp;
+       struct ifaddrs *ifap, *ifp, *bestif;
 #ifdef INET6
        struct sockaddr_in6 *servsin6, *sin6mask, *clntsin6, *ifsin6, *realsin6;
        struct sockaddr_in6 *newsin6;
@@ -131,6 +131,12 @@
        if (nconf == NULL)
                return NULL;
 
+       /*
+        * Local merge, just return a duplicate.
+        */
+       if (clnt_uaddr != NULL && strncmp(clnt_uaddr, "0.0.0.0.", 8) == 0)
+               return strdup(clnt_uaddr);
+
        serv_nbp = uaddr2taddr(nconf, serv_uaddr);
        if (serv_nbp == NULL)
                return NULL;
@@ -236,6 +242,28 @@
                        goto freeit;
                }
        }
+       /*
+        * Didn't find anything. Get the first possibly useful interface,
+        * preferring "normal" interfaces to point-to-point and loopback
+        * ones.
+        */
+       bestif = NULL;
+       for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) {
+               if (ifap->ifa_addr->sa_family != clnt->sa_family ||
+                   !(ifap->ifa_flags & IFF_UP))
+                       continue;
+               if (!(ifap->ifa_flags & IFF_LOOPBACK) &&
+                   !(ifap->ifa_flags & IFF_POINTOPOINT)) {
+                       bestif = ifap;
+                       break;
+               }
+               if (bestif == NULL)
+                       bestif = ifap;
+               else if ((bestif->ifa_flags & IFF_LOOPBACK) &&
+                   !(ifap->ifa_flags & IFF_LOOPBACK))
+                       bestif = ifap;
+       }
+       ifap = bestif;
 found:
        if (ifap != NULL)
                ret = taddr2uaddr(nconf, &tbuf);



Home | Main Index | Thread Index | Old Index