Browse Source

Fix routing when a gateway exists. This should probably be split into

a separate function.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
885a630ddf
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      src/net/ipv4.c

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

311
 	/* Use routing table to identify next hop and transmitting netdev */
311
 	/* Use routing table to identify next hop and transmitting netdev */
312
 	next_hop = iphdr->dest;
312
 	next_hop = iphdr->dest;
313
 	list_for_each_entry ( miniroute, &miniroutes, list ) {
313
 	list_for_each_entry ( miniroute, &miniroutes, list ) {
314
-		if ( ( ( ( iphdr->dest.s_addr ^ miniroute->address.s_addr ) &
315
-			 miniroute->netmask.s_addr ) == 0 ) ||
316
-		     ( miniroute->gateway.s_addr != INADDR_NONE ) ) {
314
+		int local, has_gw;
315
+
316
+		local = ( ( ( iphdr->dest.s_addr ^ miniroute->address.s_addr )
317
+			    & miniroute->netmask.s_addr ) == 0 );
318
+		has_gw = ( miniroute->gateway.s_addr != INADDR_NONE );
319
+		if ( local || has_gw ) {
317
 			netdev = miniroute->netdev;
320
 			netdev = miniroute->netdev;
318
 			iphdr->src = miniroute->address;
321
 			iphdr->src = miniroute->address;
319
-			if ( miniroute->gateway.s_addr != INADDR_NONE )
322
+			if ( ! local )
320
 				next_hop = miniroute->gateway;
323
 				next_hop = miniroute->gateway;
321
 			break;
324
 			break;
322
 		}
325
 		}

Loading…
Cancel
Save