-----BEGIN PGP SIGNATURE-----

Version: GnuPG v1
 
 iQEcBAABAgAGBQJWV8L6AAoJEO8Ells5jWIR3AsH/2TKLFPXXLaGYGx1Npds00NS
 mhdQ2lnFz5P1F+BBr2xNwTTzf6MIGwbsLSK6ntHZvJ5Tdsy3XhpvUoKHVzQfJabZ
 S1CveKl6UzbtZurvsa3tkyXcBHENCii2FZN+gAlPN74Qhd8D64Srg9sfwLXZJ+lU
 ApJxtH1UJgRlgjhHt0kq06e4zcpv6IbLx4ZwQMyZYY4UfK4P817/B37dcWwk0zeg
 hABs3w1YztKlWdteEp6TdI70/by3P+wLT9CwF8EzrbJ+5sfi/YAxBPYse4qOzT+B
 tYAe6I8Kh5JtPKjtKAHqb8YL60scYxDuPx/mwzfptZMTRqdbxEo5PPmrQI1ZLgo=
 =JGeE
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Fri 27 Nov 2015 02:42:02 GMT using RSA key ID 398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  tap-win32: disable broken async write path
  tap-win32: skip unexpected nodes during registry enumeration
  eepro100: Prevent two endless loops

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-11-27 10:44:42 +00:00
commit 714487515d
2 changed files with 54 additions and 11 deletions

View File

@ -774,6 +774,11 @@ static void tx_command(EEPRO100State *s)
#if 0 #if 0
uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, tbd_address + 6); uint16_t tx_buffer_el = lduw_le_pci_dma(&s->dev, tbd_address + 6);
#endif #endif
if (tx_buffer_size == 0) {
/* Prevent an endless loop. */
logout("loop in %s:%u\n", __FILE__, __LINE__);
break;
}
tbd_address += 8; tbd_address += 8;
TRACE(RXTX, logout TRACE(RXTX, logout
("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n", ("TBD (simplified mode): buffer address 0x%08x, size 0x%04x\n",
@ -855,6 +860,10 @@ static void set_multicast_list(EEPRO100State *s)
static void action_command(EEPRO100State *s) static void action_command(EEPRO100State *s)
{ {
/* The loop below won't stop if it gets special handcrafted data.
Therefore we limit the number of iterations. */
unsigned max_loop_count = 16;
for (;;) { for (;;) {
bool bit_el; bool bit_el;
bool bit_s; bool bit_s;
@ -870,6 +879,13 @@ static void action_command(EEPRO100State *s)
#if 0 #if 0
bool bit_sf = ((s->tx.command & COMMAND_SF) != 0); bool bit_sf = ((s->tx.command & COMMAND_SF) != 0);
#endif #endif
if (max_loop_count-- == 0) {
/* Prevent an endless loop. */
logout("loop in %s:%u\n", __FILE__, __LINE__);
break;
}
s->cu_offset = s->tx.link; s->cu_offset = s->tx.link;
TRACE(OTHER, TRACE(OTHER,
logout("val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n", logout("val=(cu start), status=0x%04x, command=0x%04x, link=0x%08x\n",

View File

@ -77,7 +77,12 @@
//#define DEBUG_TAP_WIN32 //#define DEBUG_TAP_WIN32
#define TUN_ASYNCHRONOUS_WRITES 1 /* FIXME: The asynch write path appears to be broken at
* present. WriteFile() ignores the lpNumberOfBytesWritten parameter
* for overlapped writes, with the result we return zero bytes sent,
* and after handling a single packet, receive is disabled for this
* interface. */
/* #define TUN_ASYNCHRONOUS_WRITES 1 */
#define TUN_BUFFER_SIZE 1560 #define TUN_BUFFER_SIZE 1560
#define TUN_MAX_BUFFER_COUNT 32 #define TUN_MAX_BUFFER_COUNT 32
@ -356,7 +361,8 @@ static int get_device_guid(
&len); &len);
if (status != ERROR_SUCCESS || name_type != REG_SZ) { if (status != ERROR_SUCCESS || name_type != REG_SZ) {
return -1; ++i;
continue;
} }
else { else {
if (is_tap_win32_dev(enum_name)) { if (is_tap_win32_dev(enum_name)) {
@ -460,27 +466,48 @@ static int tap_win32_write(tap_win32_overlapped_t *overlapped,
BOOL result; BOOL result;
DWORD error; DWORD error;
#ifdef TUN_ASYNCHRONOUS_WRITES
result = GetOverlappedResult( overlapped->handle, &overlapped->write_overlapped, result = GetOverlappedResult( overlapped->handle, &overlapped->write_overlapped,
&write_size, FALSE); &write_size, FALSE);
if (!result && GetLastError() == ERROR_IO_INCOMPLETE) if (!result && GetLastError() == ERROR_IO_INCOMPLETE)
WaitForSingleObject(overlapped->write_event, INFINITE); WaitForSingleObject(overlapped->write_event, INFINITE);
#endif
result = WriteFile(overlapped->handle, buffer, size, result = WriteFile(overlapped->handle, buffer, size,
&write_size, &overlapped->write_overlapped); &write_size, &overlapped->write_overlapped);
#ifdef TUN_ASYNCHRONOUS_WRITES
/* FIXME: we can't sensibly set write_size here, without waiting
* for the IO to complete! Moreover, we can't return zero,
* because that will disable receive on this interface, and we
* also can't assume it will succeed and return the full size,
* because that will result in the buffer being reclaimed while
* the IO is in progress. */
#error Async writes are broken. Please disable TUN_ASYNCHRONOUS_WRITES.
#else /* !TUN_ASYNCHRONOUS_WRITES */
if (!result) { if (!result) {
switch (error = GetLastError()) error = GetLastError();
{ if (error == ERROR_IO_PENDING) {
case ERROR_IO_PENDING: result = GetOverlappedResult(overlapped->handle,
#ifndef TUN_ASYNCHRONOUS_WRITES &overlapped->write_overlapped,
WaitForSingleObject(overlapped->write_event, INFINITE); &write_size, TRUE);
#endif
break;
default:
return -1;
} }
} }
#endif
if (!result) {
#ifdef DEBUG_TAP_WIN32
LPTSTR msgbuf;
error = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
&msgbuf, 0, NULL);
fprintf(stderr, "Tap-Win32: Error WriteFile %d - %s\n", error, msgbuf);
LocalFree(msgbuf);
#endif
return 0;
}
return write_size; return write_size;
} }