[syslinux:master] efi/udp.c: Save UDP Port in core_udp_open()

syslinux-bot for H. Peter Anvin hpa at zytor.com
Fri Jan 31 21:42:05 PST 2014


Commit-ID:  73c4268bd1399273b295f899087cef6aabf0721d
Gitweb:     http://www.syslinux.org/commit/73c4268bd1399273b295f899087cef6aabf0721d
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sun, 10 Nov 2013 08:44:06 -0500
Committer:  Gene Cumm <gene.cumm at gmail.com>
CommitDate: Wed, 29 Jan 2014 11:55:14 -0500

efi/udp.c: Save UDP Port in core_udp_open()

core_udp_open() should obtain a UDP port allocation and save it for
  core_udp_connect() and core_udp_sendto() to reuse.

Author:        H. Peter Anvin <hpa at zytor.com>
Signed-off-by: Gene Cumm <gene.cumm at gmail.com>

---
 efi/udp.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/efi/udp.c b/efi/udp.c
index 59bb426..8169025 100644
--- a/efi/udp.c
+++ b/efi/udp.c
@@ -50,6 +50,18 @@ int core_udp_open(struct pxe_pvt_inode *socket)
 
     socket->net.efi.binding = b;
 
+    /*
+     * Save the random local port number that the UDPv4 Protocol
+     * Driver picked for us. The TFTP protocol uses the local port
+     * number as the TID.
+     */
+    status = uefi_call_wrapper(udp->GetModeData, 5, udp,
+			       &udata, NULL, NULL, NULL);
+    if (status != EFI_SUCCESS)
+	Print(L"Failed to get UDP mode data: %d\n", status);
+    else
+	socket->net.efi.localport = udata.StationPort;
+
     return 0;
 
 bail:
@@ -112,21 +124,6 @@ void core_udp_connect(struct pxe_pvt_inode *socket, uint32_t ip,
 	Print(L"Failed to configure UDP: %d\n", status);
 	return;
     }
-
-    /*
-     * If this is the first time connecting, save the random local port
-     * number that the UDPv4 Protocol Driver picked for us. The TFTP
-     * protocol uses the local port number as the TID, and it needs to
-     * be consistent across connect()/disconnect() calls.
-     */
-    if (!socket->net.efi.localport) {
-	status = uefi_call_wrapper(udp->GetModeData, 5, udp,
-				   &udata, NULL, NULL, NULL);
-	if (status != EFI_SUCCESS)
-	    Print(L"Failed to get UDP mode data: %d\n", status);
-	else
-	    socket->net.efi.localport = udata.StationPort;
-    }
 }
 
 /**


More information about the Syslinux-commits mailing list