Hello Lee,
On 01/17/13 18:27, Leahy, Leroy P wrote:
>
> I have not built nor tested an OVMF configuration, so my
> recommendation is to work with Gerd Hoffman to:
> 1. Get his configuration working
> 2. Get sockets working
> 3. Remove the pieces that you do not want from Gerd's configuration
>
> As for sockets, it was designed to use the UEFI 2 networking stack so
> you should be using IFCONFIG instead of IPCONFIG. From these emails,
> I would suggest using a static IP address. Once the IP address is
> assigned to the adapter and verified with the command "ifconfig -l"
> then it should be possible to run the socket test applications. Note
> that for DNS lookup to work the shell's default device needs to
> contain the file /Efi/StdLib/etc/resolv.conf and it needs to point to
> your DNS servers.
(1) I thought I'd give a try to IFCONFIG (it's not documented in the
shell references that I checked). After finding "-?" in its source, I
even managed to invoke it :) and now I can ping hosts on the public
internet. Many thanks for making me aware of IFCONFIG.
(2) I ran GetServByName with "ftp" and "tftp", and it correctly returned
21/tcp & 69/udp. I think my StdLib setup is OK.
(3) I tried to transfer data from OVMF to the host, using DataSource.efi
in TCP mode. There was a byte order error in the port setting. After I
fixed that (and also corrected a few messages where htons() was used
instead of ntohs(), please see the attached patch), the transfer started
to work. Speed was about 280-300 KB/s.
(4) Regarding GetHostByName.efi (with ping & DataSource.efi being
functional): if I set "host.conf" to "hosts" only, then GetHostByName
doesn't crash (although it fails to locate "localhost" from the hosts
file.) If I add "dns" to "host.conf", the utility crashes (reboots) the
VM.
(4a) The following messages are in the debug log, printed mostly by
CoreInstallProtocolInterfaceNotify()
[MdeModulePkg/Core/Dxe/Hand/Handle.c]:
InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B EC04040
Loading driver at 0x0000D22D000 EntryPoint=0x0000D22D260 GetHostByName.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF D348E18
InstallProtocolInterface: 47C7B223-C42A-11D2-8E57-00A0C969723B F9478A0
InstallProtocolInterface: 70FB9CE0-2CB1-4FD7-80EE-AB4B6CF4B43F 0
InstallProtocolInterface: 9C756011-5D44-4EE0-BCE7-C38218FE398D F8CF898
InstallProtocolInterface: FFC659C2-4EF2-4532-B875-CD9AA4274CDE F8CF818
InstallProtocolInterface: 44E03A55-8D97-4511-BFEF-0A8BC62C25AE F8CF798
InstallProtocolInterface: 58E6ED63-1694-440B-9388-E98FED6B65AF D360E20
InstallProtocolInterface: 41D94CD2-35B6-455A-8258-D4E51334AADD D3474A0
InstallProtocolInterface: 3AD9DF29-4501-478D-B1F8-7F7FE70E50F3 D347638
<reboot>
After resolving the GUIDs manually and replacing non-NULL & NULL
pointers with the those strings themselves, and diffing the output
between GetHostByName and GetHostByDns, this is what I get:
--- by-name-1.txt 2013-01-17 21:19:58.889255938 +0100
+++ by-dns-1.txt 2013-01-17 21:19:57.961226931 +0100
@@ -1,11 +1,11 @@
InstallProtocolInterface: LoadedImage non-NULL
-Loading driver at 0x0000D22D000 EntryPoint=0x0000D22D260 GetHostByName.efi
+Loading driver at 0x0000D230000 EntryPoint=0x0000D230260 GetHostByDns.efi
InstallProtocolInterface: LoadedImageDevicePath non-NULL
InstallProtocolInterface: EfiShellInterface non-NULL
-InstallProtocolInterface: GetHostByName NULL
+InstallProtocolInterface: GetHostByDns NULL
InstallProtocolInterface: EslIp4Service non-NULL
InstallProtocolInterface: EslTcp4Service non-NULL
InstallProtocolInterface: EslUdp4Service non-NULL
InstallProtocolInterface: EfiSocketProtocol non-NULL
InstallProtocolInterface: EfiIp4Protocol non-NULL
InstallProtocolInterface: gEfiUdp4Protocol non-NULL
<reboot>
It is interesting that the Interface pointer is NULL for both GUIDs that
belong to AppPkg/Applications/Sockets/{GetHostByName,GetHostByDns}. But
I have the impression this isn't what causes the crash.
(4b) I also suspected the crash was related to something in the DNS
server's response (confusing the StdLib parser code or something after
that). When I run "GetHostByName example.com", I can see the following
traffic between the guest and the dnsmasq process running on the host:
00:24:06.579841 IP 192.168.122.82.1462 > 192.168.122.1.53: 38438+ A?
example.com. (29)
0x0000: 4500 0039 c12d 4000 ff11 44e1 c0a8 7a52 e.....@...d...zr
0x0010: c0a8 7a01 05b6 0035 0025 1e80 9626 0100 ..z....5.%...&..
0x0020: 0001 0000 0000 0000 0765 7861 6d70 6c65 .........example
0x0030: 0363 6f6d 0000 0100 01 .com.....
00:24:06.613263 IP 192.168.122.1.53 > 192.168.122.82.1462: 38438 1/2/4 A
192.0.43.10 (181)
0x0000: 4500 00d1 0000 4000 4011 c477 c0a8 7a01 E.....@.@..w..z.
0x0010: c0a8 7a52 0035 05b6 00bd 3083 9626 8180 ..zR.5....0..&..
0x0020: 0001 0001 0002 0004 0765 7861 6d70 6c65 .........example
0x0030: 0363 6f6d 0000 0100 01c0 0c00 0100 0100 .com............
0x0040: 02a2 c900 04c0 002b 0ac0 0c00 0200 0100 .......+........
0x0050: 02a2 c900 1401 610c 6961 6e61 2d73 6572 ......a.iana-ser
0x0060: 7665 7273 036e 6574 00c0 0c00 0200 0100 vers.net........
0x0070: 02a2 c900 0401 62c0 3bc0 5900 0100 0100 ......b.;.Y.....
0x0080: 0006 7a00 04c7 2b85 35c0 5900 1c00 0100 ..z...+.5.Y.....
0x0090: 0006 7a00 1020 0105 0000 8d00 0000 0000 ..z.............
0x00a0: 0000 0000 53c0 3900 0100 0100 0006 7a00 ....S.9.......z.
0x00b0: 04c7 2b84 35c0 3900 1c00 0100 0006 7a00 ..+.5.9.......z.
0x00c0: 1020 0105 0000 8c00 0000 0000 0000 0000 ................
0x00d0: 53 S
and then the VM reboots.
(4c) Ultimately I spent hours sprinkling StdLib with DEBUGs and
SerialPortWrite()s, and I "narrowed" down the reboot to the following
call stack:
gethostbyname() [BsdSocketLib/gethostnamadr.c]
gethostbyname2(..., AF_INET)
init_services()
_gethostbyhtname() [BsdSocketLib/gethostbyht.c]
_gethostbydnsname() [BsdSocketLib/gethostbydns.c]
res_search() [BsdSocketLib/res_query.c]
res_querydomain() #1
res_query()
res_send() [BsdSocketLib/res_send.c]
socket(PF_INET, SOCK_DGRAM, 0) [BsdSocketLib/socket.c]
BslSocketProtocolToFd()
recvfrom() <= 0 [BsdSocketLib/recvfrom.c]
res_close() [BsdSocketLib/res_send.c]
close() [LibC/Uefi/SysCalls.c]
_closeX()
BslSocketClose() via "fo_close" [BsdSocketLib/close.c]
BslSocketCloseWork()
EslSocketCloseStart() via "pfnCloseStart"
[EfiSocketLib/Socket.c]
RESTORE_TPL()
The SerialPortWrite() call that I added after the RESTORE_TPL() call
produces no output, the VM reboots. From RESTORE_TPL() I'm getting the
idea that this might be a race between a timer-driven part of the UDP
socket implementation (if that expression makes sense) and close().
Thanks,
Laszlo
From ad5085b275604da8f561deeb7c1c742fca5a6f0b Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Thu, 17 Jan 2013 22:59:06 +0100
Subject: [PATCH] AppPkg/.../DataSource.c: (only) sin_port/sin6_port are in
network byte order
- For writing sin_port, htons() must be used.
- For reading sin_port, ntohs() must be used.
- EFI_TCP4_ACCESS_POINT.RemotePort is in host byte order (see
StdLib/EfiSocketLib/Tcp4.c for example).
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
.../Applications/Sockets/DataSource/DataSource.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/AppPkg/Applications/Sockets/DataSource/DataSource.c
b/AppPkg/Applications/Sockets/DataSource/DataSource.c
index cf4caa2..14da6c2 100644
--- a/AppPkg/Applications/Sockets/DataSource/DataSource.c
+++ b/AppPkg/Applications/Sockets/DataSource/DataSource.c
@@ -386,7 +386,7 @@ SocketConnect (
( pRemoteAddress4->sin_addr.s_addr >> 8 ) & 0xff,
( pRemoteAddress4->sin_addr.s_addr >> 16 ) & 0xff,
( pRemoteAddress4->sin_addr.s_addr >> 24 ) & 0xff,
- htons ( pRemoteAddress4->sin_port ));
+ ntohs ( pRemoteAddress4->sin_port ));
}
else {
Print ( L"Connecting to remote system
[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",
@@ -406,7 +406,7 @@ SocketConnect (
pRemoteAddress6->sin6_addr.__u6_addr.__u6_addr8[ 13 ],
pRemoteAddress6->sin6_addr.__u6_addr.__u6_addr8[ 14 ],
pRemoteAddress6->sin6_addr.__u6_addr.__u6_addr8[ 15 ],
- htons ( pRemoteAddress6->sin6_port ));
+ ntohs ( pRemoteAddress6->sin6_port ));
}
//
@@ -441,7 +441,7 @@ SocketConnect (
( pRemoteAddress4->sin_addr.s_addr >> 8 ) & 0xff,
( pRemoteAddress4->sin_addr.s_addr >> 16 ) & 0xff,
( pRemoteAddress4->sin_addr.s_addr >> 24 ) & 0xff,
- htons ( pRemoteAddress4->sin_port ));
+ ntohs ( pRemoteAddress4->sin_port ));
}
else {
Print ( L"Connected to remote system
[%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",
@@ -461,7 +461,7 @@ SocketConnect (
pRemoteAddress6->sin6_addr.__u6_addr.__u6_addr8[ 13 ],
pRemoteAddress6->sin6_addr.__u6_addr.__u6_addr8[ 14 ],
pRemoteAddress6->sin6_addr.__u6_addr.__u6_addr8[ 15 ],
- htons ( pRemoteAddress6->sin6_port ));
+ ntohs ( pRemoteAddress6->sin6_port ));
}
}
else {
@@ -720,7 +720,7 @@ Tcp4Close (
pIpAddress[1],
pIpAddress[2],
pIpAddress[3],
- htons ( ((struct sockaddr_in *)&RemoteHostAddress)->sin_port
));
+ ntohs ( ((struct sockaddr_in *)&RemoteHostAddress)->sin_port
));
}
}
}
@@ -922,7 +922,7 @@ Tcp4Locate (
pIpAddress[1],
pIpAddress[2],
pIpAddress[3],
- htons ( ((struct sockaddr_in *)&RemoteHostAddress)->sin_port ));
+ ntohs ( ((struct sockaddr_in *)&RemoteHostAddress)->sin_port ));
bTcp4Connecting = FALSE;
}
@@ -1229,7 +1229,7 @@ Tcp4Open (
Tcp4ConfigData.AccessPoint.RemoteAddress.Addr[1] = (UINT8)( ((struct
sockaddr_in *)&RemoteHostAddress)->sin_addr.s_addr >> 8 );
Tcp4ConfigData.AccessPoint.RemoteAddress.Addr[2] = (UINT8)( ((struct
sockaddr_in *)&RemoteHostAddress)->sin_addr.s_addr >> 16 );
Tcp4ConfigData.AccessPoint.RemoteAddress.Addr[3] = (UINT8)( ((struct
sockaddr_in *)&RemoteHostAddress)->sin_addr.s_addr >> 24 );
- Tcp4ConfigData.AccessPoint.RemotePort = ((struct sockaddr_in
*)&RemoteHostAddress)->sin_port;
+ Tcp4ConfigData.AccessPoint.RemotePort = ntohs (((struct sockaddr_in
*)&RemoteHostAddress)->sin_port);
Tcp4ConfigData.AccessPoint.UseDefaultAddress = TRUE;
Tcp4ConfigData.AccessPoint.SubnetMask.Addr[0] = 0;
Tcp4ConfigData.AccessPoint.SubnetMask.Addr[1] = 0;
@@ -1288,7 +1288,7 @@ Tcp4Open (
pIpAddress[1],
pIpAddress[2],
pIpAddress[3],
- htons ( ((struct sockaddr_in *)&RemoteHostAddress)->sin_port ));
+ ntohs ( ((struct sockaddr_in *)&RemoteHostAddress)->sin_port ));
} while ( 0 );
if ( EFI_ERROR ( Status )) {
--
1.7.1
------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel