Source-Changes-HG archive

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

[src/trunk]: src/sys/nfs -print diskless boot related IP addresses in dot not...



details:   https://anonhg.NetBSD.org/src/rev/a64d06ca812a
branches:  trunk
changeset: 472792:a64d06ca812a
user:      drochner <drochner%NetBSD.org@localhost>
date:      Fri May 07 15:17:26 1999 +0000

description:
-print diskless boot related IP addresses in dot notation
-arrange gateway code to fall back to the old method if the new "getfile"
 is not answered (and both are enabled -- allow to switch off the new
 method for symmetry)
-handle error if setting the netmask fails

diffstat:

 sys/nfs/nfs_bootparam.c |  99 +++++++++++++++++++++++++-----------------------
 1 files changed, 51 insertions(+), 48 deletions(-)

diffs (157 lines):

diff -r ce5168edc092 -r a64d06ca812a sys/nfs/nfs_bootparam.c
--- a/sys/nfs/nfs_bootparam.c   Fri May 07 15:10:03 1999 +0000
+++ b/sys/nfs/nfs_bootparam.c   Fri May 07 15:17:26 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_bootparam.c,v 1.13 1999/04/12 01:05:01 ross Exp $  */
+/*     $NetBSD: nfs_bootparam.c,v 1.14 1999/05/07 15:17:26 drochner Exp $      */
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -115,9 +115,11 @@
        struct in_addr my_ip, arps_ip, gw_ip;
        struct sockaddr_in bp_sin;
        struct sockaddr_in *sin;
+#ifndef NFS_BOOTPARAM_NOGATEWAY
        struct nfs_dlmount *gw_ndm = 0;
        char *p;
        u_int32_t mask;
+#endif
        int error;
 
        /*
@@ -144,9 +146,8 @@
        }
 
        nd->nd_myip.s_addr = my_ip.s_addr;
-       printf("nfs_boot: client_addr=0x%x (RARP from 0x%x)\n",
-              (u_int32_t)ntohl(my_ip.s_addr),
-              (u_int32_t)ntohl(arps_ip.s_addr));
+       printf("nfs_boot: client_addr=%s (RARP from %s)\n",
+              inet_ntoa(my_ip), inet_ntoa(arps_ip));
 
        /*
         * Do enough of ifconfig(8) so that the chosen interface
@@ -179,8 +180,7 @@
                printf("nfs_boot: bootparam whoami, error=%d\n", error);
                goto delout;
        }
-       printf("nfs_boot: server_addr=0x%x\n",
-                  (u_int32_t)ntohl(sin->sin_addr.s_addr));
+       printf("nfs_boot: server_addr=%s\n", inet_ntoa(sin->sin_addr));
        printf("nfs_boot: hostname=%s\n", hostname);
 
        /*
@@ -193,7 +193,48 @@
                goto delout;
        }
 
-#ifdef NFS_BOOT_GATEWAY
+#ifndef NFS_BOOTPARAM_NOGATEWAY
+       gw_ndm = malloc(sizeof(*gw_ndm), M_NFSMNT, M_WAITOK);
+       memset((caddr_t)gw_ndm, 0, sizeof(*gw_ndm));
+       error = bp_getfile(sin, "gateway", gw_ndm);
+       if (error) {
+               /* No gateway supplied. No error, but try fallback. */
+               error = 0;
+               goto nogwrepl;
+       }
+       sin = (struct sockaddr_in *) &gw_ndm->ndm_saddr;
+       if (sin->sin_addr.s_addr == 0)
+               goto out;       /* no gateway */
+
+       /* OK, we have a gateway! */
+       printf("nfs_boot: gateway=%s\n", inet_ntoa(sin->sin_addr));
+       /* Just save it.  Caller adds the route. */
+       nd->nd_gwip = sin->sin_addr;
+
+       /* Look for a mask string after the colon. */
+       p = strchr(gw_ndm->ndm_host, ':');
+       if (p == 0)
+               goto out;       /* no netmask */
+       /* have pathname */
+       p++;    /* skip ':' */
+       mask = inet_addr(p);    /* libkern */
+       if (mask == 0)
+               goto out;       /* no netmask */
+
+       /* Have a netmask too!  Save it; update the I/F. */
+       nd->nd_mask.s_addr = mask;
+       printf("nfs_boot: my_mask=%s\n", inet_ntoa(nd->nd_mask));
+       (void)  nfs_boot_deladdress(ifp, procp, my_ip.s_addr);
+       error = nfs_boot_setaddress(ifp, procp, my_ip.s_addr,
+                                   mask, INADDR_ANY);
+       if (error) {
+               printf("nfs_boot: set ifmask, error=%d\n", error);
+               goto out;
+       }
+       goto gwok;
+nogwrepl:
+#endif
+#ifdef NFS_BOOT_GATEWAY
        /*
         * Note: we normally ignore the gateway address returned
         * by the "bootparam/whoami" RPC above, because many old
@@ -211,45 +252,6 @@
                nd->nd_gwip = gw_ip;
        }
 #endif
-       gw_ndm = malloc(sizeof(*gw_ndm), M_NFSMNT, M_WAITOK);
-       memset((caddr_t)gw_ndm, 0, sizeof(*gw_ndm));
-       error = bp_getfile(sin, "gateway", gw_ndm);
-       if (error) {
-               /* Ignore the error.  No gateway supplied. */
-               error = 0;
-               goto out;
-       }
-       sin = (struct sockaddr_in *) &gw_ndm->ndm_saddr;
-       if (sin->sin_addr.s_addr == 0)
-           goto out;   /* no gateway */
-
-       /* OK, we have a gateway! */
-       printf("nfs_boot: gateway=0x%x\n",
-                  (u_int32_t)ntohl(sin->sin_addr.s_addr));
-       /* Just save it.  Caller adds the route. */
-       nd->nd_gwip = sin->sin_addr;
-
-       /* Look for a mask string after the colon. */
-       p = strchr(gw_ndm->ndm_host, ':');
-       if (p == 0)
-               goto out;       /* no netmask */
-       /* have pathname */
-       p++;    /* skip ':' */
-       mask = inet_addr(p);    /* libkern */
-       if (mask == 0)
-               goto out;       /* no netmask */
-
-       /* Have a netmask too!  Save it; update the I/F. */
-       printf("nfs_boot: my_mask=0x%x\n",
-                  (u_int32_t)ntohl(mask));
-       nd->nd_mask.s_addr = mask;
-       (void)  nfs_boot_deladdress(ifp, procp, my_ip.s_addr);
-       error = nfs_boot_setaddress(ifp, procp, my_ip.s_addr,
-                                   mask, INADDR_ANY);
-       if (error) {
-               printf("nfs_boot: set ifmask, error=%d\n", error);
-               error = 0;      /* ignore it */
-       }
 
 delout:
        if (error)
@@ -259,8 +261,11 @@
                (void) nfs_boot_ifupdown(ifp, procp, 0);
                nfs_boot_flushrt(ifp);
        }
+#ifndef NFS_BOOTPARAM_NOGATEWAY
+gwok:
        if (gw_ndm)
                free(gw_ndm, M_NFSMNT);
+#endif
        return (error);
 }
 
@@ -471,5 +476,3 @@
        m_freem(m);
        return(0);
 }
-
-



Home | Main Index | Thread Index | Old Index