Ver código fonte

Use hotplug support to notify persistent reference holders when a

net_device is unregistered.
tags/v0.9.3
Michael Brown 18 anos atrás
pai
commit
bdf79ec8dc
2 arquivos alterados com 9 adições e 0 exclusões
  1. 5
    0
      src/include/gpxe/netdevice.h
  2. 4
    0
      src/net/netdevice.c

+ 5
- 0
src/include/gpxe/netdevice.h Ver arquivo

@@ -10,6 +10,7 @@
10 10
 #include <stdint.h>
11 11
 #include <gpxe/list.h>
12 12
 #include <gpxe/tables.h>
13
+#include <gpxe/hotplug.h>
13 14
 
14 15
 struct pk_buff;
15 16
 struct net_device;
@@ -137,6 +138,10 @@ struct ll_protocol {
137 138
 struct net_device {
138 139
 	/** List of network devices */
139 140
 	struct list_head list;
141
+
142
+	/** List of persistent reference holders */
143
+	struct list_head references;
144
+
140 145
 	/** Transmit packet
141 146
 	 *
142 147
 	 * @v netdev	Network device

+ 4
- 0
src/net/netdevice.c Ver arquivo

@@ -161,6 +161,7 @@ struct net_device * alloc_netdev ( size_t priv_size ) {
161 161
 
162 162
 	netdev = calloc ( 1, sizeof ( *netdev ) + priv_size );
163 163
 	if ( netdev ) {
164
+		INIT_LIST_HEAD ( &netdev->references );
164 165
 		INIT_LIST_HEAD ( &netdev->rx_queue );
165 166
 		netdev->priv = ( ( ( void * ) netdev ) + sizeof ( *netdev ) );
166 167
 	}
@@ -201,6 +202,9 @@ void unregister_netdev ( struct net_device *netdev ) {
201 202
 		free_pkb ( pkb );
202 203
 	}
203 204
 
205
+	/* Kill off any persistent references to this device */
206
+	forget_references ( &netdev->references );
207
+
204 208
 	/* Remove from device list */
205 209
 	list_del ( &netdev->list );
206 210
 	DBG ( "%s unregistered\n", netdev_name ( netdev ) );

Carregando…
Cancelar
Salvar