Bug 19677

Summary: If no GATEWAYDEV, all interfaces try to set default route
Product: [Retired] Red Hat Linux Reporter: Pekka Savola <pekkas>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 7.1CC: dr, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-01-30 22:20:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pekka Savola 2000-10-24 12:17:15 UTC
Fresh install of RHL7.0 with two interfaces.

The installer did not specify GATEWAYDEV in /etc/sysconfig/network.

However, when there is no GATEWAYDEV, and default route has been configured 
with GATEWAY in /etc/sysconfig/network, all interfaces try to add it and
fail with SIOCADDRT.

This happens at:
---
    if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
 	# set up default gateway
	if [ "${GATEWAY}" != "" ]; then
            route add default gw ${GATEWAY} ${DEVICE}
            DEFGW=${GATEWAY}
---

This _might_ have been caused by the fact that in RHL7.0, all interfaces
save for eth0 are disabled by default.

Fixing this without breaking stuff which use something other than ethX
requires some thought
(else you could just assume that eth0 == default gateway unless otherwise
specified).  Perhaps the correct place to fix this would be at install
time.

Comment 1 Bill Nottingham 2001-01-29 23:58:28 UTC
Does this still happen with the beta?

Comment 2 Pekka Savola 2001-01-30 15:19:01 UTC
Yes.  This can be seen with 'service network restart', which gives like:

Jan 30 16:26:07 install5 network: Shutting down interface eth1:  succeeded
Jan 30 16:26:08 install5 modprobe: modprobe: Can't locate module irlan0
Jan 30 16:26:08 install5 syslogd: sendto: Network is unreachable
Jan 30 16:26:08 install5 syslogd: sendto: Network is unreachable
Jan 30 16:26:08 install5 sysctl: net.ipv4.ip_forward = 0
Jan 30 16:26:08 install5 sysctl: net.ipv4.conf.all.rp_filter = 1
Jan 30 16:26:08 install5 sysctl: kernel.sysrq = 0
Jan 30 16:26:08 install5 network: Setting network parameters:  succeeded
Jan 30 16:26:08 install5 ifup: SIOCADDRT: Network is unreachable
Jan 30 16:26:08 install5 network: Bringing up interface lo:  succeeded
Jan 30 16:26:09 install5 network: Bringing up interface eth1:  succeeded

Note ifup line, as before.


Comment 3 Bill Nottingham 2001-01-30 21:23:50 UTC
Hmm... we could always ping the gateway, to see if it's
reachable at that address. But that's a hack.

Comment 4 Bill Nottingham 2001-01-30 21:37:36 UTC
We could certainly special-case lo to not try and add it; that would
eliminate some of the messages.

Comment 5 Bill Nottingham 2001-01-30 21:50:37 UTC
OK, here's the fix that's going into initscripts-5.60-1; it
seems correct.

Change the test from:

if [ "${GATEWAY}" != "" ]; then

to 

if [ "${GATEWAY}" != "" -a "`ipcalc --network ${GATEWAY} ${NETMASK}`" = "`ipcalc
--network ${IPADDR} ${NETMASK}`" ]; then


Comment 6 Bill Nottingham 2001-01-30 21:54:30 UTC
(of course, replace the second ipcalc call with just ${NETWORK} *thwap*)

Comment 7 Pekka Savola 2001-01-30 22:20:12 UTC
This doesn't exactly work, but the idea is sound.

ipcalc --network ${GATEWAY} ${NETMASK} returns something like

NETWORK=1.2.3.4

not 1.2.3.4 ;-)

There are ways to get around this, but it might be useful to add a feature in ipcalc that'd omit
NETWORK=, NETMASK= etc. too.

I did this with:

if [ "${GATEWAY}" != "" -a "`ipcalc --network ${GATEWAY} ${NETMASK}`" = "NETWORK=${NETWORK}" ]; then

and the original bug disappeared. A bit hackish.


Comment 8 Bill Nottingham 2001-01-30 22:22:45 UTC
Oops, yeah. Disregard the parenthetical comment entirely. :)

It's hackish, but it seems the quickest way to determine if you're
adding the gateway on a reasonably appropriate interface.