mirror of https://github.com/ipxe/ipxe.git
Use hotplug support to notify persistent reference holders when a
net_device is unregistered.pull/1/head
parent
0063725d28
commit
bdf79ec8dc
|
@ -10,6 +10,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <gpxe/list.h>
|
#include <gpxe/list.h>
|
||||||
#include <gpxe/tables.h>
|
#include <gpxe/tables.h>
|
||||||
|
#include <gpxe/hotplug.h>
|
||||||
|
|
||||||
struct pk_buff;
|
struct pk_buff;
|
||||||
struct net_device;
|
struct net_device;
|
||||||
|
@ -137,6 +138,10 @@ struct ll_protocol {
|
||||||
struct net_device {
|
struct net_device {
|
||||||
/** List of network devices */
|
/** List of network devices */
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
|
|
||||||
|
/** List of persistent reference holders */
|
||||||
|
struct list_head references;
|
||||||
|
|
||||||
/** Transmit packet
|
/** Transmit packet
|
||||||
*
|
*
|
||||||
* @v netdev Network device
|
* @v netdev Network device
|
||||||
|
|
|
@ -161,6 +161,7 @@ struct net_device * alloc_netdev ( size_t priv_size ) {
|
||||||
|
|
||||||
netdev = calloc ( 1, sizeof ( *netdev ) + priv_size );
|
netdev = calloc ( 1, sizeof ( *netdev ) + priv_size );
|
||||||
if ( netdev ) {
|
if ( netdev ) {
|
||||||
|
INIT_LIST_HEAD ( &netdev->references );
|
||||||
INIT_LIST_HEAD ( &netdev->rx_queue );
|
INIT_LIST_HEAD ( &netdev->rx_queue );
|
||||||
netdev->priv = ( ( ( void * ) netdev ) + sizeof ( *netdev ) );
|
netdev->priv = ( ( ( void * ) netdev ) + sizeof ( *netdev ) );
|
||||||
}
|
}
|
||||||
|
@ -201,6 +202,9 @@ void unregister_netdev ( struct net_device *netdev ) {
|
||||||
free_pkb ( pkb );
|
free_pkb ( pkb );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Kill off any persistent references to this device */
|
||||||
|
forget_references ( &netdev->references );
|
||||||
|
|
||||||
/* Remove from device list */
|
/* Remove from device list */
|
||||||
list_del ( &netdev->list );
|
list_del ( &netdev->list );
|
||||||
DBG ( "%s unregistered\n", netdev_name ( netdev ) );
|
DBG ( "%s unregistered\n", netdev_name ( netdev ) );
|
||||||
|
|
Loading…
Reference in New Issue