|
@@ -136,6 +136,17 @@ static void ibft_set_ipaddr_option ( struct ibft_ipaddr *ipaddr,
|
136
|
136
|
ibft_set_ipaddr ( ipaddr, in );
|
137
|
137
|
}
|
138
|
138
|
|
|
139
|
+/**
|
|
140
|
+ * Read IP address from iBFT (for debugging)
|
|
141
|
+ *
|
|
142
|
+ * @v strings iBFT string block descriptor
|
|
143
|
+ * @v string String field
|
|
144
|
+ * @ret ipaddr IP address string
|
|
145
|
+ */
|
|
146
|
+static const char * ibft_ipaddr ( struct ibft_ipaddr *ipaddr ) {
|
|
147
|
+ return inet_ntoa ( ipaddr->in );
|
|
148
|
+}
|
|
149
|
+
|
139
|
150
|
/**
|
140
|
151
|
* Allocate a string within iBFT
|
141
|
152
|
*
|
|
@@ -214,6 +225,18 @@ static int ibft_set_string_option ( struct ibft_string_block *strings,
|
214
|
225
|
return 0;
|
215
|
226
|
}
|
216
|
227
|
|
|
228
|
+/**
|
|
229
|
+ * Read string from iBFT (for debugging)
|
|
230
|
+ *
|
|
231
|
+ * @v strings iBFT string block descriptor
|
|
232
|
+ * @v string String field
|
|
233
|
+ * @ret data String content (or "<empty>")
|
|
234
|
+ */
|
|
235
|
+static const char * ibft_string ( struct ibft_string_block *strings,
|
|
236
|
+ struct ibft_string *string ) {
|
|
237
|
+ return ( ( ( char * ) strings->table ) + string->offset );
|
|
238
|
+}
|
|
239
|
+
|
217
|
240
|
/**
|
218
|
241
|
* Fill in NIC portion of iBFT
|
219
|
242
|
*
|
|
@@ -231,11 +254,16 @@ static int ibft_fill_nic ( struct ibft_nic *nic,
|
231
|
254
|
|
232
|
255
|
/* Extract values from DHCP configuration */
|
233
|
256
|
ibft_set_ipaddr_option ( &nic->ip_address, &ip_setting );
|
|
257
|
+ DBG ( "iBFT NIC IP = %s\n", ibft_ipaddr ( &nic->ip_address ) );
|
234
|
258
|
ibft_set_ipaddr_option ( &nic->gateway, &gateway_setting );
|
|
259
|
+ DBG ( "iBFT NIC gateway = %s\n", ibft_ipaddr ( &nic->gateway ) );
|
235
|
260
|
ibft_set_ipaddr_option ( &nic->dns[0], &dns_setting );
|
|
261
|
+ DBG ( "iBFT NIC DNS = %s\n", ibft_ipaddr ( &nic->dns[0] ) );
|
236
|
262
|
if ( ( rc = ibft_set_string_option ( strings, &nic->hostname,
|
237
|
263
|
&hostname_setting ) ) != 0 )
|
238
|
264
|
return rc;
|
|
265
|
+ DBG ( "iBFT NIC hostname = %s\n",
|
|
266
|
+ ibft_string ( strings, &nic->hostname ) );
|
239
|
267
|
|
240
|
268
|
/* Derive subnet mask prefix from subnet mask */
|
241
|
269
|
fetch_ipv4_setting ( NULL, &netmask_setting, &netmask_addr );
|
|
@@ -245,11 +273,15 @@ static int ibft_fill_nic ( struct ibft_nic *nic,
|
245
|
273
|
netmask_addr.s_addr >>= 1;
|
246
|
274
|
}
|
247
|
275
|
nic->subnet_mask_prefix = netmask_count;
|
|
276
|
+ DBG ( "iBFT NIC subnet = /%d\n", nic->subnet_mask_prefix );
|
248
|
277
|
|
249
|
278
|
/* Extract values from net-device configuration */
|
250
|
279
|
memcpy ( nic->mac_address, netdev->ll_addr,
|
251
|
280
|
sizeof ( nic->mac_address ) );
|
|
281
|
+ DBG ( "iBFT NIC MAC = %s\n",
|
|
282
|
+ netdev->ll_protocol->ntoa ( nic->mac_address ) );
|
252
|
283
|
nic->pci_bus_dev_func = netdev->dev->desc.location;
|
|
284
|
+ DBG ( "iBFT NIC PCI = %04x\n", nic->pci_bus_dev_func );
|
253
|
285
|
|
254
|
286
|
return 0;
|
255
|
287
|
}
|
|
@@ -269,6 +301,8 @@ static int ibft_fill_initiator ( struct ibft_initiator *initiator,
|
269
|
301
|
if ( ( rc = ibft_set_string ( strings, &initiator->initiator_name,
|
270
|
302
|
initiator_iqn ) ) != 0 )
|
271
|
303
|
return rc;
|
|
304
|
+ DBG ( "iBFT initiator hostname = %s\n",
|
|
305
|
+ ibft_string ( strings, &initiator->initiator_name ) );
|
272
|
306
|
|
273
|
307
|
return 0;
|
274
|
308
|
}
|
|
@@ -286,17 +320,23 @@ static int ibft_fill_target_chap ( struct ibft_target *target,
|
286
|
320
|
struct iscsi_session *iscsi ) {
|
287
|
321
|
int rc;
|
288
|
322
|
|
289
|
|
- if ( ! iscsi->initiator_username )
|
|
323
|
+ if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_FORWARD_REQUIRED ) )
|
290
|
324
|
return 0;
|
|
325
|
+
|
|
326
|
+ assert ( iscsi->initiator_username );
|
291
|
327
|
assert ( iscsi->initiator_password );
|
292
|
328
|
|
293
|
329
|
target->chap_type = IBFT_CHAP_ONE_WAY;
|
294
|
330
|
if ( ( rc = ibft_set_string ( strings, &target->chap_name,
|
295
|
331
|
iscsi->initiator_username ) ) != 0 )
|
296
|
332
|
return rc;
|
|
333
|
+ DBG ( "iBFT target username = %s\n",
|
|
334
|
+ ibft_string ( strings, &target->chap_name ) );
|
297
|
335
|
if ( ( rc = ibft_set_string ( strings, &target->chap_secret,
|
298
|
336
|
iscsi->initiator_password ) ) != 0 )
|
299
|
337
|
return rc;
|
|
338
|
+ DBG ( "iBFT target password = <redacted>\n" );
|
|
339
|
+
|
300
|
340
|
return 0;
|
301
|
341
|
}
|
302
|
342
|
|
|
@@ -313,19 +353,25 @@ static int ibft_fill_target_reverse_chap ( struct ibft_target *target,
|
313
|
353
|
struct iscsi_session *iscsi ) {
|
314
|
354
|
int rc;
|
315
|
355
|
|
316
|
|
- if ( ! iscsi->target_username )
|
|
356
|
+ if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_REVERSE_REQUIRED ) )
|
317
|
357
|
return 0;
|
318
|
|
- assert ( iscsi->target_password );
|
|
358
|
+
|
319
|
359
|
assert ( iscsi->initiator_username );
|
320
|
360
|
assert ( iscsi->initiator_password );
|
|
361
|
+ assert ( iscsi->target_username );
|
|
362
|
+ assert ( iscsi->target_password );
|
321
|
363
|
|
322
|
364
|
target->chap_type = IBFT_CHAP_MUTUAL;
|
323
|
365
|
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_name,
|
324
|
366
|
iscsi->target_username ) ) != 0 )
|
325
|
367
|
return rc;
|
|
368
|
+ DBG ( "iBFT target reverse username = %s\n",
|
|
369
|
+ ibft_string ( strings, &target->chap_name ) );
|
326
|
370
|
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_secret,
|
327
|
371
|
iscsi->target_password ) ) != 0 )
|
328
|
372
|
return rc;
|
|
373
|
+ DBG ( "iBFT target reverse password = <redacted>\n" );
|
|
374
|
+
|
329
|
375
|
return 0;
|
330
|
376
|
}
|
331
|
377
|
|
|
@@ -346,10 +392,14 @@ static int ibft_fill_target ( struct ibft_target *target,
|
346
|
392
|
|
347
|
393
|
/* Fill in Target values */
|
348
|
394
|
ibft_set_ipaddr ( &target->ip_address, sin_target->sin_addr );
|
|
395
|
+ DBG ( "iBFT target IP = %s\n", ibft_ipaddr ( &target->ip_address ) );
|
349
|
396
|
target->socket = ntohs ( sin_target->sin_port );
|
|
397
|
+ DBG ( "iBFT target port = %d\n", target->socket );
|
350
|
398
|
if ( ( rc = ibft_set_string ( strings, &target->target_name,
|
351
|
399
|
iscsi->target_iqn ) ) != 0 )
|
352
|
400
|
return rc;
|
|
401
|
+ DBG ( "iBFT target name = %s\n",
|
|
402
|
+ ibft_string ( strings, &target->target_name ) );
|
353
|
403
|
if ( ( rc = ibft_fill_target_chap ( target, strings, iscsi ) ) != 0 )
|
354
|
404
|
return rc;
|
355
|
405
|
if ( ( rc = ibft_fill_target_reverse_chap ( target, strings,
|