Przeglądaj źródła

[pxe] Support cached DHCP packets in .kkpxe images

If we don't unload the PXE stack before executing gPXE, automatically
take advantage of the cached DHCPACK that the underlying/parent PXE
stack can provide. If that cached DHCPACK contains option 175.178, or
the user sets the use-cached setting before invoking DHCP, the real
DHCP request will be skipped and the cached DHCPACK will be used for
network configuration. Otherwise, the cached settings block is thrown
away as soon as a fresh one is acquired.

Signed-off-by: Marty Connor <mdc@etherboot.org>
tags/v1.0.0-rc1
Joshua Oreman 15 lat temu
rodzic
commit
9e9cc8c60f

+ 69
- 0
src/arch/i386/interface/pxeparent/pxeparent_dhcp.c Wyświetl plik

@@ -0,0 +1,69 @@
1
+/*
2
+ * Copyright (C) 2009 Joshua Oreman <oremanj@rwcr.net>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+FILE_LICENCE ( GPL2_OR_LATER );
20
+
21
+#include <string.h>
22
+#include <gpxe/dhcp.h>
23
+#include <gpxe/netdevice.h>
24
+#include <undipreload.h>
25
+#include <pxeparent.h>
26
+#include <realmode.h>
27
+#include <pxe_api.h>
28
+
29
+/**
30
+ * Present cached DHCP packet if it exists
31
+ */
32
+void __weak_impl ( get_cached_dhcpack ) ( void ) {
33
+	struct undi_device *undi;
34
+	struct s_PXENV_GET_CACHED_INFO get_cached_info;
35
+	int rc;
36
+
37
+	/* Use preloaded UNDI device to get at PXE entry point */
38
+	undi = &preloaded_undi;
39
+	if ( ! undi->entry.segment ) {
40
+		DBG ( "PXEDHCP no preloaded UNDI device found\n" );
41
+		return;
42
+	}
43
+
44
+	/* Check that stack is available to get cached info */
45
+	if ( ! ( undi->flags & UNDI_FL_KEEP_ALL ) ) {
46
+		DBG ( "PXEDHCP stack was unloaded, no cache available\n" );
47
+		return;
48
+	}
49
+
50
+	/* Obtain cached DHCP packet */
51
+	memset ( &get_cached_info, 0, sizeof ( get_cached_info ) );
52
+	get_cached_info.PacketType = PXENV_PACKET_TYPE_DHCP_ACK;
53
+
54
+	if ( ( rc = pxeparent_call ( undi->entry, PXENV_GET_CACHED_INFO,
55
+				     &get_cached_info,
56
+				     sizeof ( get_cached_info ) ) ) != 0 ) {
57
+		DBG ( "PXEDHCP GET_CACHED_INFO failed: %s\n", strerror ( rc ) );
58
+		return;
59
+	}
60
+
61
+	DBG ( "PXEDHCP got cached info at %04x:%04x length %d\n",
62
+	      get_cached_info.Buffer.segment, get_cached_info.Buffer.offset,
63
+	      get_cached_info.BufferSize );
64
+
65
+	/* Present cached DHCP packet */
66
+	store_cached_dhcpack ( real_to_user ( get_cached_info.Buffer.segment,
67
+					      get_cached_info.Buffer.offset ),
68
+			       get_cached_info.BufferSize );
69
+}

+ 3
- 0
src/arch/i386/prefix/kkpxeprefix.S Wyświetl plik

@@ -5,6 +5,9 @@
5 5
 
6 6
 FILE_LICENCE ( GPL2_OR_LATER )
7 7
 
8
+/* Since we have the whole stack, we can use cached DHCP information */
9
+REQUEST_OBJECT ( pxeparent_dhcp )
10
+
8 11
 #define PXELOADER_KEEP_UNDI
9 12
 #define PXELOADER_KEEP_PXE
10 13
 #include "pxeprefix.S"

Ładowanie…
Anuluj
Zapisz