mirror of
https://github.com/ipxe/ipxe
synced 2025-12-18 18:40:24 +03:00
[ipv4] Extend routing mechanism to handle non-default routes
Extend the definition of an IPv4 routing table entry to allow for the expression of non-default gateways for specified off-link subnets, and of on-link secondary subnets (where we can send directly to the destination address even though our source address is not within the subnet). This more precise definition also allows us to correctly handle routing in the (uncommon for iPXE) case when multiple network interfaces are open concurrently and more than one interface has a default gateway. The common case of a single IPv4 address/netmask and a default gateway now results in two routing table entries. To retain backwards compatibility with existing documentation (and to avoid on-screen clutter), the "route" command prints default gateways on the same line as the locally assigned address. There is therefore no change in output from the "route" command unless explicit additional (off-link or on-link) routes are present. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -297,6 +297,36 @@ static void ipv4_test_exec ( void ) {
|
||||
"192.168.87.1", &net4, "192.168.86.1", 0 );
|
||||
ipv4_route_ok ( "192.168.96.1", NULL, NULL, NULL, NULL, 0 );
|
||||
testnet_remove_ok ( &net4 );
|
||||
|
||||
/* Multiple interfaces */
|
||||
testnet_ok ( &net0 );
|
||||
testnet_ok ( &net1 );
|
||||
testnet_ok ( &net2 );
|
||||
testnet_close_ok ( &net1 );
|
||||
ipv4_route_ok ( "192.168.0.9", NULL,
|
||||
"192.168.0.9", &net0, "192.168.0.1", 0 );
|
||||
ipv4_route_ok ( "10.31.31.1", NULL,
|
||||
"10.31.31.1", &net2, "10.31.31.0", 0 );
|
||||
testnet_close_ok ( &net0 );
|
||||
testnet_open_ok ( &net1 );
|
||||
ipv4_route_ok ( "192.168.0.9", NULL,
|
||||
"192.168.0.9", &net1, "192.168.0.2", 0 );
|
||||
ipv4_route_ok ( "10.31.31.1", NULL,
|
||||
"10.31.31.1", &net2, "10.31.31.0", 0 );
|
||||
testnet_close_ok ( &net2 );
|
||||
ipv4_route_ok ( "8.8.8.8", NULL,
|
||||
"192.168.0.254", &net1, "192.168.0.2", 0 );
|
||||
testnet_close_ok ( &net1 );
|
||||
testnet_open_ok ( &net0 );
|
||||
ipv4_route_ok ( "8.8.8.8", NULL,
|
||||
"192.168.0.254", &net0, "192.168.0.1", 0 );
|
||||
testnet_close_ok ( &net0 );
|
||||
testnet_open_ok ( &net2 );
|
||||
ipv4_route_ok ( "8.8.8.8", NULL,
|
||||
"10.31.31.1", &net2, "10.31.31.0", 0 );
|
||||
testnet_remove_ok ( &net2 );
|
||||
testnet_remove_ok ( &net1 );
|
||||
testnet_remove_ok ( &net0 );
|
||||
}
|
||||
|
||||
/** IPv4 self-test */
|
||||
|
||||
Reference in New Issue
Block a user