]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[ipv4] Extend routing mechanism to handle non-default routes
authorMichael Brown <mcb30@ipxe.org>
Thu, 5 Jun 2025 15:49:42 +0000 (16:49 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 10 Jun 2025 12:54:15 +0000 (13:54 +0100)
commite648d23fba09c7e0c50e205448448b132a5711b5
tree1b5e3107fec9bc32ddc87cf16d748c97862c9dc0
parent96f58646607f554b05e1c4f32e1cefe85f0346e6
[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>
src/include/ipxe/ip.h
src/net/ipv4.c
src/tests/ipv4_test.c
src/usr/route_ipv4.c