Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[pxe] Obey lists of PXE Boot Servers and associated Discovery Control…
… bits

Various combinations of options 43.6, 43.7 and 43.8 dictate which
servers we send Boot Server Discovery requests to, and which servers
we should accept responses from.  Obey these options, and remove the
explicit specification of a single Boot Server from start_pxebs() and
dependent functions.
  • Loading branch information
Michael Brown committed Feb 5, 2009
1 parent ff2b308 commit 881f1f5
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 62 deletions.
17 changes: 4 additions & 13 deletions src/hci/commands/dhcp_cmd.c
Expand Up @@ -109,7 +109,7 @@ static int dhcp_exec ( int argc, char **argv ) {
*/
static void pxebs_syntax ( char **argv ) {
printf ( "Usage:\n"
" %s <interface> <discovery_ip> <server_type>\n"
" %s <interface> <server_type>\n"
"\n"
"Perform PXE Boot Server discovery\n",
argv[0] );
Expand All @@ -128,10 +128,8 @@ static int pxebs_exec ( int argc, char **argv ) {
{ NULL, 0, NULL, 0 },
};
const char *netdev_txt;
const char *pxe_server_txt;
const char *pxe_type_txt;
struct net_device *netdev;
struct in_addr pxe_server;
unsigned int pxe_type;
char *end;
int c;
Expand All @@ -148,34 +146,27 @@ static int pxebs_exec ( int argc, char **argv ) {
return 1;
}
}

/* Need exactly one interface name remaining after the options */
if ( optind != ( argc - 3 ) ) {
if ( optind != ( argc - 2 ) ) {
pxebs_syntax ( argv );
return 1;
}
netdev_txt = argv[optind];
pxe_server_txt = argv[ optind + 1 ];
pxe_type_txt = argv[ optind + 2 ];
pxe_type_txt = argv[ optind + 1 ];

/* Parse arguments */
netdev = find_netdev ( netdev_txt );
if ( ! netdev ) {
printf ( "No such interface: %s\n", netdev_txt );
return 1;
}
if ( inet_aton ( pxe_server_txt, &pxe_server ) == 0 ) {
printf ( "Bad discovery IP address: %s\n", pxe_server_txt );
return 1;
}
pxe_type = strtoul ( pxe_type_txt, &end, 0 );
if ( *end ) {
printf ( "Bad server type: %s\n", pxe_type_txt );
return 1;
}

/* Perform Boot Server Discovery */
if ( ( rc = pxebs ( netdev, pxe_server, pxe_type ) ) != 0 ) {
if ( ( rc = pxebs ( netdev, pxe_type ) ) != 0 ) {
printf ( "Could not discover boot server on %s: %s\n",
netdev->name, strerror ( rc ) );
return 1;
Expand Down
18 changes: 17 additions & 1 deletion src/include/gpxe/dhcp.h
Expand Up @@ -100,6 +100,19 @@ enum dhcp_pxe_discovery_control {
/** PXE boot server multicast address */
#define DHCP_PXE_BOOT_SERVER_MCAST DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 7 )

/** PXE boot servers */
#define DHCP_PXE_BOOT_SERVERS DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 8 )

/** PXE boot server */
struct dhcp_pxe_boot_server {
/** "Type" */
uint16_t type;
/** Number of IPv4 addresses */
uint8_t num_ip;
/** IPv4 addresses */
struct in_addr ip[0];
} __attribute__ (( packed ));

/** PXE boot menu */
#define DHCP_PXE_BOOT_MENU DHCP_ENCAP_OPT ( DHCP_VENDOR_ENCAP, 9 )

Expand Down Expand Up @@ -574,6 +587,9 @@ struct dhcphdr {
/** Maximum time that we will wait for ProxyDHCP responses */
#define PROXYDHCP_MAX_TIMEOUT ( 2 * TICKS_PER_SEC )

/** Maximum time that we will wait for Boot Server responses */
#define PXEBS_MAX_TIMEOUT ( 3 * TICKS_PER_SEC )

/** Settings block name used for DHCP responses */
#define DHCP_SETTINGS_NAME "dhcp"

Expand All @@ -593,6 +609,6 @@ extern int dhcp_create_request ( struct dhcp_packet *dhcppkt,
void *data, size_t max_len );
extern int start_dhcp ( struct job_interface *job, struct net_device *netdev );
extern int start_pxebs ( struct job_interface *job, struct net_device *netdev,
struct in_addr pxe_server, unsigned int pxe_type );
unsigned int pxe_type );

#endif /* _GPXE_DHCP_H */
3 changes: 1 addition & 2 deletions src/include/usr/dhcpmgmt.h
Expand Up @@ -10,7 +10,6 @@
struct net_device;

extern int dhcp ( struct net_device *netdev );
extern int pxebs ( struct net_device *netdev, struct in_addr pxe_server,
unsigned int pxe_type );
extern int pxebs ( struct net_device *netdev, unsigned int pxe_type );

#endif /* _USR_DHCPMGMT_H */

0 comments on commit 881f1f5

Please sign in to comment.