aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-05-29 11:56:05 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2012-05-29 11:56:05 -0700
commit82b3f770ede649c876ae224b344bc8f169b562d5 (patch)
tree98dda9b000ef833fe89d418ffa8867b7aca545a1
parent5175cff5ee89f23b135282eef79367043f20cb67 (diff)
downloadsyslinux-82b3f770ede649c876ae224b344bc8f169b562d5.tar.gz
syslinux-82b3f770ede649c876ae224b344bc8f169b562d5.tar.xz
syslinux-82b3f770ede649c876ae224b344bc8f169b562d5.zip
pxe: stop using trackbuf for DHCP packets
Get rid of yet another trackbuf usage. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--core/fs/pxe/dhcp_option.c6
-rw-r--r--core/fs/pxe/pxe.c30
-rw-r--r--core/fs/pxe/pxe.h2
3 files changed, 23 insertions, 15 deletions
diff --git a/core/fs/pxe/dhcp_option.c b/core/fs/pxe/dhcp_option.c
index 50f2de04..f63d4a91 100644
--- a/core/fs/pxe/dhcp_option.c
+++ b/core/fs/pxe/dhcp_option.c
@@ -227,12 +227,10 @@ static void parse_dhcp_options(const void *option, int size, uint8_t opt_filter)
* LocalDomain - Local domain name
* MAC_len, MAC - Client identifier, if MAC_len == 0
*
- * This assumes the DHCP packet is in "trackbuf".
- *
*/
-void parse_dhcp(int pkt_len)
+void parse_dhcp(const void *pkt, size_t pkt_len)
{
- struct bootp_t *dhcp = (struct bootp_t *)trackbuf;
+ const struct bootp_t *dhcp = (const struct bootp_t *)pkt;
int opt_len;
IPInfo.ipv4 = 4; /* This is IPv4 only for now... */
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index 7b63d17b..b8156afc 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -340,13 +340,13 @@ static void ack_packet(struct inode *inode, uint16_t ack_num)
/**
- * Get a DHCP packet from the PXE stack into the trackbuf
+ * Get a DHCP packet from the PXE stack into a lowmem buffer
*
* @param: type, packet type
* @return: buffer size
*
*/
-static int pxe_get_cached_info(int type)
+static int pxe_get_cached_info(int type, char *buf, size_t bufsiz)
{
int err;
static __lowmem struct s_PXENV_GET_CACHED_INFO get_cached_info;
@@ -354,8 +354,8 @@ static int pxe_get_cached_info(int type)
get_cached_info.Status = 0;
get_cached_info.PacketType = type;
- get_cached_info.BufferSize = 8192;
- get_cached_info.Buffer = FAR_PTR(trackbuf);
+ get_cached_info.BufferSize = bufsiz;
+ get_cached_info.Buffer = FAR_PTR(buf);
err = pxe_call(PXENV_GET_CACHED_INFO, &get_cached_info);
if (err) {
printf("PXE API call failed, error %04x\n", err);
@@ -1450,6 +1450,14 @@ static void network_init(void)
{
struct bootp_t *bp = (struct bootp_t *)trackbuf;
int pkt_len;
+ char *dhcp_packet;
+ const size_t dhcp_max_packet = 4096;
+
+ dhcp_packet = lmalloc(dhcp_max_packet);
+ if (!dhcp_packet) {
+ printf("Out of low memory\n");
+ kaboom();
+ }
*LocalDomain = 0; /* No LocalDomain received */
@@ -1457,8 +1465,8 @@ static void network_init(void)
* Get the DHCP client identifiers (query info 1)
*/
printf("Getting cached packet ");
- pkt_len = pxe_get_cached_info(1);
- parse_dhcp(pkt_len);
+ pkt_len = pxe_get_cached_info(1, dhcp_packet, dhcp_max_packet);
+ parse_dhcp(dhcp_packet, pkt_len);
/*
* We don't use flags from the request packet, so
* this is a good time to initialize DHCPMagic...
@@ -1474,8 +1482,8 @@ static void network_init(void)
* Get the BOOTP/DHCP packet that brought us file (and an IP
* address). This lives in the DHCPACK packet (query info 2)
*/
- pkt_len = pxe_get_cached_info(2);
- parse_dhcp(pkt_len);
+ pkt_len = pxe_get_cached_info(2, dhcp_packet, dhcp_max_packet);
+ parse_dhcp(dhcp_packet, pkt_len);
/*
* Save away MAC address (assume this is in query info 2. If this
* turns out to be problematic it might be better getting it from
@@ -1489,10 +1497,12 @@ static void network_init(void)
* Get the boot file and other info. This lives in the CACHED_REPLY
* packet (query info 3)
*/
- pkt_len = pxe_get_cached_info(3);
- parse_dhcp(pkt_len);
+ pkt_len = pxe_get_cached_info(3, dhcp_packet, dhcp_max_packet);
+ parse_dhcp(dhcp_packet, pkt_len);
printf("\n");
+ lfree(dhcp_packet);
+
make_bootif_string();
make_sysuuid_string();
ip_init();
diff --git a/core/fs/pxe/pxe.h b/core/fs/pxe/pxe.h
index 1e6fa76a..47ed8f06 100644
--- a/core/fs/pxe/pxe.h
+++ b/core/fs/pxe/pxe.h
@@ -235,7 +235,7 @@ bool ip_ok(uint32_t);
int pxe_call(int, void *);
/* dhcp_options.c */
-void parse_dhcp(int);
+void parse_dhcp(const void *, size_t);
/* dnsresolv.c */
int dns_mangle(char **, const char *);