Fix routing when a gateway exists. This should probably be split into
authorMichael Brown <mcb30@etherboot.org>
Mon, 7 Aug 2006 17:51:19 +0000 (17:51 +0000)
committerMichael Brown <mcb30@etherboot.org>
Mon, 7 Aug 2006 17:51:19 +0000 (17:51 +0000)
a separate function.

src/net/ipv4.c

index ce98532..a963569 100644 (file)
@@ -311,12 +311,15 @@ static int ipv4_tx ( struct pk_buff *pkb,
        /* Use routing table to identify next hop and transmitting netdev */
        next_hop = iphdr->dest;
        list_for_each_entry ( miniroute, &miniroutes, list ) {
-               if ( ( ( ( iphdr->dest.s_addr ^ miniroute->address.s_addr ) &
-                        miniroute->netmask.s_addr ) == 0 ) ||
-                    ( miniroute->gateway.s_addr != INADDR_NONE ) ) {
+               int local, has_gw;
+
+               local = ( ( ( iphdr->dest.s_addr ^ miniroute->address.s_addr )
+                           & miniroute->netmask.s_addr ) == 0 );
+               has_gw = ( miniroute->gateway.s_addr != INADDR_NONE );
+               if ( local || has_gw ) {
                        netdev = miniroute->netdev;
                        iphdr->src = miniroute->address;
-                       if ( miniroute->gateway.s_addr != INADDR_NONE )
+                       if ( ! local )
                                next_hop = miniroute->gateway;
                        break;
                }