Why does the "RTNETLINK answers: File exists" message appear when restarting networking if the root filesystem is mounted with the _netdev option?

Solution In Progress - Updated -

Environment

  • Red Hat Enterprise Linux 6
  • initscripts-9.03.*

Issue

  • Why does the "RTNETLINK answers: File exists" message appear when restarting networking if the root filesystem is mounted with the _netdev option?
    When restarting networking using the service command (this includes stopping and then when starting networking again) you may see "RTNETLINK answers: File exists" messages, for example:
]# service network restart
**// there were no output of "Shutting down interface **".**

Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  ** RTNETLINK answers: File exists**
                                                           [  OK  ]
Bringing up interface eth1:  **RTNETLINK answers: File exists**
                                                           [  OK  ]
**RTNETLINK answers: File exists**
  • Why does the "Shutting down interface" message(s) not get printed as expected ?
  • Why does this message appear?

Resolution

  • This is the expected behaviour if the root filesystem has the _netdev mount option.

Root Cause

When the root filesystem has the _netdev mount option the /etc/rc.d/init.d/network script does not stop any networking functions. That is interfaces will not be brought down, no routes will be removed, no bonds stopped, no bridges deleted, etc. The _netdev mount option says that the device is a networking block device. If the root filesystem has the _netdev mount option, even if it does not actually require networking to be active for it to work, the system will not stop networking.

An example of when the _netdev mount option would be valid for use with the root filesystem is when your root filesystem is on an iSCSI device. If you stop networking the system is likely to hang because the root filesystem is no longer available so the commands required to restart networking are inaccessible.

  1. stop (or restart) network service:
]# service network stop

In the /etc/rc.d/init.d/network script below the code marked with ** shows where stopping networking exits. The variable rootfs contains the filesystem type of the root filesystem and the variable rootops contains the mount options. If the filesystem type is nfs or the _netdev option exists in the mount options for the root filesystem we exit and do not stop any networking on the system.

  stop)
        [ "$EUID" != "0" ] && exit 4
        # Don't shut the network down if root is on NFS or a network
        # block device.
        rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/" && $3 != "rootfs") { print $3; }}' /proc/mounts)
        rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab)

**        if [[ "$rootfs" == nfs* || "$rootopts" =~ _r?netdev ]] ; then**
**                exit 1**
**        fi**
<..SNIP..>
  restart|reload|force-reload)
        cd "$CWD"
        $0 stop
        $0 start
        rc=$?
        ;;
  *)

In this paricular case the "RTNETLINK answers: File exists" messages are caused by static routes. When starting networking and because the static routes already exist the message is printed for each static route the script attempts to add.

It is worth reiterating that this behavour is the correct and expected result when you use the _netdev mount option on the root filesystem and restart networking. Great care should be taken restarting networking in such cases if you have significantly modified your networking configuration. The old configuration will not be removed (because nothing is stopped) and the new configuration will be applied on top of your existing networking setup. This may lead to networking complications on the server.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments