Browse Source

[iscsi] Read IPv4 settings only from the relevant network device

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
059adae434
1 changed files with 14 additions and 9 deletions
  1. 14
    9
      src/drivers/block/ibft.c

+ 14
- 9
src/drivers/block/ibft.c View File

102
 /**
102
 /**
103
  * Fill in an IP address within iBFT from configuration setting
103
  * Fill in an IP address within iBFT from configuration setting
104
  *
104
  *
105
+ * @v settings		Parent settings block, or NULL
105
  * @v ipaddr		IP address field
106
  * @v ipaddr		IP address field
106
  * @v setting		Configuration setting
107
  * @v setting		Configuration setting
107
  * @v count		Maximum number of IP addresses
108
  * @v count		Maximum number of IP addresses
108
  */
109
  */
109
-static void ibft_set_ipaddr_setting ( struct ibft_ipaddr *ipaddr,
110
+static void ibft_set_ipaddr_setting ( struct settings *settings,
111
+				      struct ibft_ipaddr *ipaddr,
110
 				      const struct setting *setting,
112
 				      const struct setting *setting,
111
 				      unsigned int count ) {
113
 				      unsigned int count ) {
112
 	struct in_addr in[count];
114
 	struct in_addr in[count];
113
 	unsigned int i;
115
 	unsigned int i;
114
 
116
 
115
-	fetch_ipv4_array_setting ( NULL, setting, in, count );
117
+	fetch_ipv4_array_setting ( settings, setting, in, count );
116
 	for ( i = 0 ; i < count ; i++ ) {
118
 	for ( i = 0 ; i < count ; i++ ) {
117
 		ibft_set_ipaddr ( &ipaddr[i], in[i] );
119
 		ibft_set_ipaddr ( &ipaddr[i], in[i] );
118
 	}
120
 	}
176
 /**
178
 /**
177
  * Fill in a string field within iBFT from configuration setting
179
  * Fill in a string field within iBFT from configuration setting
178
  *
180
  *
181
+ * @v settings		Parent settings block, or NULL
179
  * @v strings		iBFT string block descriptor
182
  * @v strings		iBFT string block descriptor
180
  * @v string		String field
183
  * @v string		String field
181
  * @v setting		Configuration setting
184
  * @v setting		Configuration setting
182
  * @ret rc		Return status code
185
  * @ret rc		Return status code
183
  */
186
  */
184
-static int ibft_set_string_setting ( struct ibft_strings *strings,
187
+static int ibft_set_string_setting ( struct settings *settings,
188
+				     struct ibft_strings *strings,
185
 				     struct ibft_string *string,
189
 				     struct ibft_string *string,
186
 				     const struct setting *setting ) {
190
 				     const struct setting *setting ) {
187
 	struct settings *origin;
191
 	struct settings *origin;
189
 	int len;
193
 	int len;
190
 	char *dest;
194
 	char *dest;
191
 
195
 
192
-	len = fetch_setting ( NULL, setting, &origin, &fetched, NULL, 0 );
196
+	len = fetch_setting ( settings, setting, &origin, &fetched, NULL, 0 );
193
 	if ( len < 0 ) {
197
 	if ( len < 0 ) {
194
 		string->offset = 0;
198
 		string->offset = 0;
195
 		string->len = 0;
199
 		string->len = 0;
231
 	struct ll_protocol *ll_protocol = netdev->ll_protocol;
235
 	struct ll_protocol *ll_protocol = netdev->ll_protocol;
232
 	struct in_addr netmask_addr = { 0 };
236
 	struct in_addr netmask_addr = { 0 };
233
 	unsigned int netmask_count = 0;
237
 	unsigned int netmask_count = 0;
238
+	struct settings *parent = netdev_settings ( netdev );
234
 	int rc;
239
 	int rc;
235
 
240
 
236
 	/* Fill in common header */
241
 	/* Fill in common header */
241
 			      IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED );
246
 			      IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED );
242
 
247
 
243
 	/* Extract values from configuration settings */
248
 	/* Extract values from configuration settings */
244
-	ibft_set_ipaddr_setting ( &nic->ip_address, &ip_setting, 1 );
249
+	ibft_set_ipaddr_setting ( parent, &nic->ip_address, &ip_setting, 1 );
245
 	DBG ( "iBFT NIC IP = %s\n", ibft_ipaddr ( &nic->ip_address ) );
250
 	DBG ( "iBFT NIC IP = %s\n", ibft_ipaddr ( &nic->ip_address ) );
246
-	ibft_set_ipaddr_setting ( &nic->gateway, &gateway_setting, 1 );
251
+	ibft_set_ipaddr_setting ( parent, &nic->gateway, &gateway_setting, 1 );
247
 	DBG ( "iBFT NIC gateway = %s\n", ibft_ipaddr ( &nic->gateway ) );
252
 	DBG ( "iBFT NIC gateway = %s\n", ibft_ipaddr ( &nic->gateway ) );
248
-	ibft_set_ipaddr_setting ( &nic->dns[0], &dns_setting,
253
+	ibft_set_ipaddr_setting ( NULL, &nic->dns[0], &dns_setting,
249
 				  ( sizeof ( nic->dns ) /
254
 				  ( sizeof ( nic->dns ) /
250
 				    sizeof ( nic->dns[0] ) ) );
255
 				    sizeof ( nic->dns[0] ) ) );
251
 	DBG ( "iBFT NIC DNS = %s", ibft_ipaddr ( &nic->dns[0] ) );
256
 	DBG ( "iBFT NIC DNS = %s", ibft_ipaddr ( &nic->dns[0] ) );
252
 	DBG ( ", %s\n", ibft_ipaddr ( &nic->dns[1] ) );
257
 	DBG ( ", %s\n", ibft_ipaddr ( &nic->dns[1] ) );
253
-	if ( ( rc = ibft_set_string_setting ( strings, &nic->hostname,
258
+	if ( ( rc = ibft_set_string_setting ( NULL, strings, &nic->hostname,
254
 					      &hostname_setting ) ) != 0 )
259
 					      &hostname_setting ) ) != 0 )
255
 		return rc;
260
 		return rc;
256
 	DBG ( "iBFT NIC hostname = %s\n",
261
 	DBG ( "iBFT NIC hostname = %s\n",
257
 	      ibft_string ( strings, &nic->hostname ) );
262
 	      ibft_string ( strings, &nic->hostname ) );
258
 
263
 
259
 	/* Derive subnet mask prefix from subnet mask */
264
 	/* Derive subnet mask prefix from subnet mask */
260
-	fetch_ipv4_setting ( NULL, &netmask_setting, &netmask_addr );
265
+	fetch_ipv4_setting ( parent, &netmask_setting, &netmask_addr );
261
 	while ( netmask_addr.s_addr ) {
266
 	while ( netmask_addr.s_addr ) {
262
 		if ( netmask_addr.s_addr & 0x1 )
267
 		if ( netmask_addr.s_addr & 0x1 )
263
 			netmask_count++;
268
 			netmask_count++;

Loading…
Cancel
Save