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,12 +311,15 @@ static int ipv4_tx ( struct pk_buff *pkb,
311 311
 	/* Use routing table to identify next hop and transmitting netdev */
312 312
 	next_hop = iphdr->dest;
313 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 320
 			netdev = miniroute->netdev;
318 321
 			iphdr->src = miniroute->address;
319
-			if ( miniroute->gateway.s_addr != INADDR_NONE )
322
+			if ( ! local )
320 323
 				next_hop = miniroute->gateway;
321 324
 			break;
322 325
 		}

Loading…
Cancel
Save