|
@@ -76,6 +76,12 @@ static int aoe_send_command ( struct aoe_session *aoe ) {
|
76
|
76
|
unsigned int count;
|
77
|
77
|
unsigned int data_out_len;
|
78
|
78
|
|
|
79
|
+ /* Fail immediately if we have no netdev to send on */
|
|
80
|
+ if ( ! aoe->netdev ) {
|
|
81
|
+ aoe_done ( aoe, -ENETUNREACH );
|
|
82
|
+ return -ENETUNREACH;
|
|
83
|
+ }
|
|
84
|
+
|
79
|
85
|
/* Calculate count and data_out_len for this subcommand */
|
80
|
86
|
count = command->cb.count.native;
|
81
|
87
|
if ( count > AOE_MAX_COUNT )
|
|
@@ -259,6 +265,19 @@ struct net_protocol aoe_protocol __net_protocol = {
|
259
|
265
|
.rx = aoe_rx,
|
260
|
266
|
};
|
261
|
267
|
|
|
268
|
+/**
|
|
269
|
+ * Forget reference to net_device
|
|
270
|
+ *
|
|
271
|
+ * @v ref Persistent reference
|
|
272
|
+ */
|
|
273
|
+static void aoe_forget_netdev ( struct reference *ref ) {
|
|
274
|
+ struct aoe_session *aoe
|
|
275
|
+ = container_of ( ref, struct aoe_session, netdev_ref );
|
|
276
|
+
|
|
277
|
+ aoe->netdev = NULL;
|
|
278
|
+ ref_del ( &aoe->netdev_ref );
|
|
279
|
+}
|
|
280
|
+
|
262
|
281
|
/**
|
263
|
282
|
* Open AoE session
|
264
|
283
|
*
|
|
@@ -269,6 +288,8 @@ void aoe_open ( struct aoe_session *aoe ) {
|
269
|
288
|
sizeof ( aoe->target ) );
|
270
|
289
|
aoe->tag = AOE_TAG_MAGIC;
|
271
|
290
|
aoe->timer.expired = aoe_timer_expired;
|
|
291
|
+ aoe->netdev_ref.forget = aoe_forget_netdev;
|
|
292
|
+ ref_add ( &aoe->netdev_ref, &aoe->netdev->references );
|
272
|
293
|
list_add ( &aoe->list, &aoe_sessions );
|
273
|
294
|
}
|
274
|
295
|
|
|
@@ -278,6 +299,8 @@ void aoe_open ( struct aoe_session *aoe ) {
|
278
|
299
|
* @v aoe AoE session
|
279
|
300
|
*/
|
280
|
301
|
void aoe_close ( struct aoe_session *aoe ) {
|
|
302
|
+ if ( aoe->netdev )
|
|
303
|
+ ref_del ( &aoe->netdev_ref );
|
281
|
304
|
list_del ( &aoe->list );
|
282
|
305
|
}
|
283
|
306
|
|