unsigned int count;
unsigned int data_out_len;
+ /* Fail immediately if we have no netdev to send on */
+ if ( ! aoe->netdev ) {
+ aoe_done ( aoe, -ENETUNREACH );
+ return -ENETUNREACH;
+ }
+
/* Calculate count and data_out_len for this subcommand */
count = command->cb.count.native;
if ( count > AOE_MAX_COUNT )
.rx = aoe_rx,
};
+/**
+ * Forget reference to net_device
+ *
+ * @v ref Persistent reference
+ */
+static void aoe_forget_netdev ( struct reference *ref ) {
+ struct aoe_session *aoe
+ = container_of ( ref, struct aoe_session, netdev_ref );
+
+ aoe->netdev = NULL;
+ ref_del ( &aoe->netdev_ref );
+}
+
/**
* Open AoE session
*
sizeof ( aoe->target ) );
aoe->tag = AOE_TAG_MAGIC;
aoe->timer.expired = aoe_timer_expired;
+ aoe->netdev_ref.forget = aoe_forget_netdev;
+ ref_add ( &aoe->netdev_ref, &aoe->netdev->references );
list_add ( &aoe->list, &aoe_sessions );
}
* @v aoe AoE session
*/
void aoe_close ( struct aoe_session *aoe ) {
+ if ( aoe->netdev )
+ ref_del ( &aoe->netdev_ref );
list_del ( &aoe->list );
}