Browse Source

[pxe] Implicitly open network device in PXENV_UDP_OPEN

Some end-user configurations have been observed in which the first NBP
(such as GRUB2) uses the UNDI API and then transfers control to a
second NBP (such as pxelinux) which uses the UDP API.  The first NBP
closes the network device using PXENV_UNDI_CLOSE, which renders the
UDP API unable to transmit or receive packets.

The correct behaviour under these circumstances is (as often) simply
not documented by the PXE specification.  Testing with the Intel PXE
stack suggests that PXENV_UDP_OPEN will implicitly reopen the network
device if necessary, so match this behaviour.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
3df598849b
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      src/arch/x86/interface/pxe/pxe_udp.c

+ 10
- 0
src/arch/x86/interface/pxe/pxe_udp.c View File

@@ -11,6 +11,7 @@
11 11
 #include <ipxe/udp.h>
12 12
 #include <ipxe/uaccess.h>
13 13
 #include <ipxe/process.h>
14
+#include <ipxe/netdevice.h>
14 15
 #include <realmode.h>
15 16
 #include <pxe.h>
16 17
 
@@ -180,6 +181,15 @@ static PXENV_EXIT_t pxenv_udp_open ( struct s_PXENV_UDP_OPEN *pxenv_udp_open ) {
180 181
 	pxe_udp.local.sin_addr.s_addr = pxenv_udp_open->src_ip;
181 182
 	DBG ( " %s\n", inet_ntoa ( pxe_udp.local.sin_addr ) );
182 183
 
184
+	/* Open network device, if necessary */
185
+	if ( pxe_netdev && ( ! netdev_is_open ( pxe_netdev ) ) &&
186
+	     ( ( rc = netdev_open ( pxe_netdev ) ) != 0 ) ) {
187
+		DBG ( "PXENV_UDP_OPEN could not (implicitly) open %s: %s\n",
188
+		      pxe_netdev->name, strerror ( rc ) );
189
+		pxenv_udp_open->Status = PXENV_STATUS ( rc );
190
+		return PXENV_EXIT_FAILURE;
191
+	}
192
+
183 193
 	/* Open promiscuous UDP connection */
184 194
 	intf_restart ( &pxe_udp.xfer, 0 );
185 195
 	if ( ( rc = udp_open_promisc ( &pxe_udp.xfer ) ) != 0 ) {

Loading…
Cancel
Save