-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
This commit is contained in:
parent
41b78a54f1
commit
16f2b4c6a9
@ -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.
|
* Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
|
||||||
@ -115,9 +115,11 @@ nfs_bootparam(nd, procp)
|
|||||||
struct in_addr my_ip, arps_ip, gw_ip;
|
struct in_addr my_ip, arps_ip, gw_ip;
|
||||||
struct sockaddr_in bp_sin;
|
struct sockaddr_in bp_sin;
|
||||||
struct sockaddr_in *sin;
|
struct sockaddr_in *sin;
|
||||||
|
#ifndef NFS_BOOTPARAM_NOGATEWAY
|
||||||
struct nfs_dlmount *gw_ndm = 0;
|
struct nfs_dlmount *gw_ndm = 0;
|
||||||
char *p;
|
char *p;
|
||||||
u_int32_t mask;
|
u_int32_t mask;
|
||||||
|
#endif
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -144,9 +146,8 @@ nfs_bootparam(nd, procp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nd->nd_myip.s_addr = my_ip.s_addr;
|
nd->nd_myip.s_addr = my_ip.s_addr;
|
||||||
printf("nfs_boot: client_addr=0x%x (RARP from 0x%x)\n",
|
printf("nfs_boot: client_addr=%s (RARP from %s)\n",
|
||||||
(u_int32_t)ntohl(my_ip.s_addr),
|
inet_ntoa(my_ip), inet_ntoa(arps_ip));
|
||||||
(u_int32_t)ntohl(arps_ip.s_addr));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do enough of ifconfig(8) so that the chosen interface
|
* Do enough of ifconfig(8) so that the chosen interface
|
||||||
@ -179,8 +180,7 @@ nfs_bootparam(nd, procp)
|
|||||||
printf("nfs_boot: bootparam whoami, error=%d\n", error);
|
printf("nfs_boot: bootparam whoami, error=%d\n", error);
|
||||||
goto delout;
|
goto delout;
|
||||||
}
|
}
|
||||||
printf("nfs_boot: server_addr=0x%x\n",
|
printf("nfs_boot: server_addr=%s\n", inet_ntoa(sin->sin_addr));
|
||||||
(u_int32_t)ntohl(sin->sin_addr.s_addr));
|
|
||||||
printf("nfs_boot: hostname=%s\n", hostname);
|
printf("nfs_boot: hostname=%s\n", hostname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -193,7 +193,48 @@ nfs_bootparam(nd, procp)
|
|||||||
goto delout;
|
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
|
* Note: we normally ignore the gateway address returned
|
||||||
* by the "bootparam/whoami" RPC above, because many old
|
* by the "bootparam/whoami" RPC above, because many old
|
||||||
@ -211,45 +252,6 @@ nfs_bootparam(nd, procp)
|
|||||||
nd->nd_gwip = gw_ip;
|
nd->nd_gwip = gw_ip;
|
||||||
}
|
}
|
||||||
#endif
|
#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:
|
delout:
|
||||||
if (error)
|
if (error)
|
||||||
@ -259,8 +261,11 @@ out:
|
|||||||
(void) nfs_boot_ifupdown(ifp, procp, 0);
|
(void) nfs_boot_ifupdown(ifp, procp, 0);
|
||||||
nfs_boot_flushrt(ifp);
|
nfs_boot_flushrt(ifp);
|
||||||
}
|
}
|
||||||
|
#ifndef NFS_BOOTPARAM_NOGATEWAY
|
||||||
|
gwok:
|
||||||
if (gw_ndm)
|
if (gw_ndm)
|
||||||
free(gw_ndm, M_NFSMNT);
|
free(gw_ndm, M_NFSMNT);
|
||||||
|
#endif
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,5 +476,3 @@ out:
|
|||||||
m_freem(m);
|
m_freem(m);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user