[ipv4] Use a zero address to indicate "no gateway", rather than INADDR_NONE

ipv4.c uses a gateway address of INADDR_NONE to represent "no
gateway".  It initialises the gateway address to INADDR_NONE before
calling fetch_ipv4_setting() to retrieve the configured gateway
address (if any).

However, as of commit 612f4e7 "[settings] Avoid returning
uninitialised data on error in fetch_xxx_setting()",
fetch_ipv4_setting() will zero the IP address if the setting does not
exist, rather than leaving it unaltered.

Fix by using a zero IP address to indicate "no gateway", so that a
non-existent gateway address setting will be treated as such.
This commit is contained in:
Michael Brown
2009-11-14 02:21:13 +00:00
parent 76d5e493d1
commit 2ce0d8f08b
2 changed files with 7 additions and 8 deletions

View File

@@ -36,7 +36,7 @@ void route ( void ) {
printf ( "%s: %s/", miniroute->netdev->name,
inet_ntoa ( miniroute->address ) );
printf ( "%s", inet_ntoa ( miniroute->netmask ) );
if ( miniroute->gateway.s_addr != INADDR_NONE )
if ( miniroute->gateway.s_addr )
printf ( " gw %s", inet_ntoa ( miniroute->gateway ) );
if ( ! ( miniroute->netdev->state & NETDEV_OPEN ) )
printf ( " (inaccessible)" );