Skip to contentSkip to conversation

[4885] Remove the NIC from vlan on usb destroy.

Qemu-devel Andrzej Zaborowski 1 participant 1 message Jul 17, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 4885

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4885
Author:   balrog
Date:     2008-07-17 21:00:05 +0000 (Thu, 17 Jul 2008)

Log Message:
-----------
Remove the NIC from vlan on usb destroy.

Modified Paths:
--------------
trunk/hw/usb-net.c
trunk/net.h
trunk/vl.c

Modified: trunk/hw/usb-net.c
===================================================================

hw/usb-net.c +2 -1
@@ -1418,7 +1418,8 @@
 {
     USBNetState *s = (USBNetState *) dev;
 
-    /* FIXME: delete the VLAN client and the nic */
+    /* TODO: remove the nd_table[] entry */
+    qemu_del_vlan_client(s->vc);
     rndis_clear_responsequeue(s);
     qemu_free(s);
 }

Modified: trunk/net.h
===================================================================

net.h +1 -0
@@ -28,6 +28,7 @@
                                       IOReadHandler *fd_read,
                                       IOCanRWHandler *fd_can_read,
                                       void *opaque);
+void qemu_del_vlan_client(VLANClientState *vc);
 int qemu_can_send_packet(VLANClientState *vc);
 void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
 void qemu_handler_true(void *opaque);

Modified: trunk/vl.c
===================================================================

vl.c +13 -0
@@ -3870,6 +3870,19 @@
     return vc;
 }
 
+void qemu_del_vlan_client(VLANClientState *vc)
+{
+    VLANClientState **pvc = &vc->vlan->first_client;
+
+    while (*pvc != NULL)
+        if (*pvc == vc) {
+            *pvc = vc->next;
+            free(vc);
+            break;
+        } else
+            pvc = &(*pvc)->next;
+}
+
 int qemu_can_send_packet(VLANClientState *vc1)
 {
     VLANState *vlan = vc1->vlan;