pcnet: Do not receive external frames in loopback mode
authorJan Kiszka <jan.kiszka@siemens.com>
Tue, 19 Oct 2010 15:03:24 +0000 (17:03 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Sun, 21 Nov 2010 15:16:57 +0000 (09:16 -0600)
While not explicitly stated in the spec, it was observed on real systems
that enabling loopback testing on the pcnet controller disables
reception of external frames. And some legacy software relies on it, so
provide this behavior.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/pcnet.c

index b52935adf13ddf977461a91ba74708c33c32ef7c..f970bdaf3c4f8f053ff265354069d1342b105f80 100644 (file)
@@ -1048,9 +1048,10 @@ ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_)
     int crc_err = 0;
     int size = size_;
 
-    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size)
+    if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size ||
+        (CSR_LOOP(s) && !s->looptest)) {
         return -1;
-
+    }
 #ifdef PCNET_DEBUG
     printf("pcnet_receive size=%d\n", size);
 #endif