Browse Source

Simplify ipv4_tx() by not having a separate "source" variable now that

we are constructing the IP header ourselves.

Formatting fix-ups (80 column limit is mandatory!)
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
35557914e3
1 changed files with 5 additions and 7 deletions
  1. 5
    7
      src/net/ipv4.c

+ 5
- 7
src/net/ipv4.c View File

@@ -238,7 +238,6 @@ int ipv4_tx ( struct pk_buff *pkb, uint16_t trans_proto, struct in_addr *dest )
238 238
 	struct ipv4_miniroute *miniroute;
239 239
 	struct net_device *netdev = NULL;
240 240
 	struct in_addr next_hop;
241
-	struct in_addr source;
242 241
 	uint8_t ll_dest_buf[MAX_LL_ADDR_LEN];
243 242
 	const uint8_t *ll_dest = ll_dest_buf;
244 243
 	int rc;
@@ -273,7 +272,7 @@ int ipv4_tx ( struct pk_buff *pkb, uint16_t trans_proto, struct in_addr *dest )
273 272
 			 miniroute->netmask.s_addr ) == 0 ) ||
274 273
 		     ( miniroute->gateway.s_addr != INADDR_NONE ) ) {
275 274
 			netdev = miniroute->netdev;
276
-			source = miniroute->address;
275
+			iphdr->src = miniroute->address;
277 276
 			if ( miniroute->gateway.s_addr != INADDR_NONE )
278 277
 				next_hop = miniroute->gateway;
279 278
 			break;
@@ -286,8 +285,6 @@ int ipv4_tx ( struct pk_buff *pkb, uint16_t trans_proto, struct in_addr *dest )
286 285
 		goto err;
287 286
 	}
288 287
 
289
-	/* Copy the source address, after this the IP header is complete */
290
-	memcpy ( &iphdr->src, &source, sizeof ( struct in_addr ) );
291 288
 	/* Calculate the transport layer checksum */
292 289
 	ipv4_tx_csum ( pkb, trans_proto );
293 290
 
@@ -312,8 +309,10 @@ int ipv4_tx ( struct pk_buff *pkb, uint16_t trans_proto, struct in_addr *dest )
312 309
 		ll_dest_buf[5] = next_hop_bytes[3];
313 310
 	} else {
314 311
 		/* Unicast address: resolve via ARP */
315
-		if ( ( rc = arp_resolve ( netdev, &ipv4_protocol, &next_hop, &source, ll_dest_buf ) ) != 0 ) {
316
-			DBG ( "No ARP entry for %s\n", inet_ntoa ( iphdr->dest ) );
312
+		if ( ( rc = arp_resolve ( netdev, &ipv4_protocol, &next_hop,
313
+					  &iphdr->src, ll_dest_buf ) ) != 0 ) {
314
+			DBG ( "No ARP entry for %s\n",
315
+			      inet_ntoa ( iphdr->dest ) );
317 316
 			goto err;
318 317
 		}
319 318
 	}
@@ -322,7 +321,6 @@ int ipv4_tx ( struct pk_buff *pkb, uint16_t trans_proto, struct in_addr *dest )
322 321
 	return net_tx ( pkb, netdev, &ipv4_protocol, ll_dest );
323 322
 
324 323
  err:
325
-	/* Warning: Allowing this function to execute causes bochs to go into an infinite loop */
326 324
 	free_pkb ( pkb );
327 325
 	return rc;
328 326
 }

Loading…
Cancel
Save