aboutsummaryrefslogtreecommitdiffstats
path: root/efi/udp.c
diff options
context:
space:
mode:
authorGene Cumm <gene.cumm@gmail.com>2015-10-15 20:02:29 -0400
committerGene Cumm <gene.cumm@gmail.com>2015-10-15 20:02:29 -0400
commit9e0926bb338deb5c634ccb4ee29eb4577158cfdc (patch)
tree5e1ba1ace4dc77c26fa6599b9f865f2211e8dc5d /efi/udp.c
parent066dbd3a8b83ecb67903e40ee49a792d12c7d213 (diff)
downloadsyslinux-9e0926bb338deb5c634ccb4ee29eb4577158cfdc.tar.gz
syslinux-9e0926bb338deb5c634ccb4ee29eb4577158cfdc.tar.xz
syslinux-9e0926bb338deb5c634ccb4ee29eb4577158cfdc.zip
efi: Disable UseDefaultAddress if possibly deaf
Some machines don't like UseDefaultAddress; fallback to manually configuring. HP EFI servers like DL160 Gen9 are affected. Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
Diffstat (limited to 'efi/udp.c')
-rw-r--r--efi/udp.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/efi/udp.c b/efi/udp.c
index 72447943..61397ed3 100644
--- a/efi/udp.c
+++ b/efi/udp.c
@@ -18,6 +18,9 @@ extern EFI_GUID Udp4ServiceBindingProtocol, Udp4Protocol;
*/
static struct efi_binding *udp_reader;
+static int volatile efi_udp_has_recv = 0;
+int volatile efi_net_def_addr = 1;
+
/**
* Try to configure this UDP socket
*
@@ -48,8 +51,11 @@ EFI_STATUS core_udp_configure(EFI_UDP4 *udp, EFI_UDP4_CONFIG_DATA *udata,
unmapped = 0;
}
} else {
- if (status != EFI_SUCCESS)
+ if (status != EFI_SUCCESS) {
Print(L"%s: udp->Configure() unsuccessful (%d)", f, status);
+ if (!efi_net_def_addr && (status == EFI_INVALID_PARAMETER))
+ efi_net_def_addr = 2;
+ }
unmapped = 0;
}
}
@@ -152,7 +158,13 @@ void core_udp_connect(struct pxe_pvt_inode *socket, uint32_t ip,
/* Re-use the existing local port number */
udata.StationPort = socket->net.efi.localport;
- udata.UseDefaultAddress = TRUE;
+ if (efi_net_def_addr) {
+ udata.UseDefaultAddress = TRUE;
+ } else {
+ udata.UseDefaultAddress = FALSE;
+ memcpy(&udata.StationAddress, &IPInfo.myip, sizeof(IPInfo.myip));
+ memcpy(&udata.StationAddress, &IPInfo.netmask, sizeof(IPInfo.netmask));
+ }
memcpy(&udata.RemoteAddress, &ip, sizeof(ip));
udata.RemotePort = port;
udata.TimeToLive = 64;
@@ -243,6 +255,10 @@ int core_udp_recv(struct pxe_pvt_inode *socket, void *buf, uint16_t *buf_len,
uefi_call_wrapper(udp->Cancel, 2, udp, &token);
dprintf("core_udp_recv: timed out\n");
+ if (!efi_udp_has_recv && (efi_net_def_addr == 1)) {
+ efi_net_def_addr = 0;
+ Print(L"disable UseDefaultAddress\n");
+ }
}
uefi_call_wrapper(udp->Poll, 1, udp);
@@ -257,6 +273,9 @@ int core_udp_recv(struct pxe_pvt_inode *socket, void *buf, uint16_t *buf_len,
if (rv)
goto bail;
+ if (!efi_udp_has_recv)
+ efi_udp_has_recv = 1;
+
rxdata = token.Packet.RxData;
frag = &rxdata->FragmentTable[0];
@@ -373,7 +392,13 @@ void core_udp_sendto(struct pxe_pvt_inode *socket, const void *data,
/* Re-use the existing local port number */
udata.StationPort = socket->net.efi.localport;
- udata.UseDefaultAddress = TRUE;
+ if (efi_net_def_addr) {
+ udata.UseDefaultAddress = TRUE;
+ } else {
+ udata.UseDefaultAddress = FALSE;
+ memcpy(&udata.StationAddress, &IPInfo.myip, sizeof(IPInfo.myip));
+ memcpy(&udata.StationAddress, &IPInfo.netmask, sizeof(IPInfo.netmask));
+ }
memcpy(&udata.RemoteAddress, &ip, sizeof(ip));
udata.RemotePort = port;
udata.TimeToLive = 64;