瀏覽代碼

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

a separate function.
tags/v0.9.3
Michael Brown 18 年之前
父節點
當前提交
885a630ddf
共有 1 個檔案被更改,包括 7 行新增4 行删除
  1. 7
    4
      src/net/ipv4.c

+ 7
- 4
src/net/ipv4.c 查看文件

@@ -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…
取消
儲存