Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-6953

rear overwrites the ifcfg-XXX files's MAC address with another MAC address

    • None
    • Moderate
    • sst_cs_system_management
    • ssg_core_services
    • 8
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Bug Fix
    • None

      Description of problem:

      Even when restoring on exact same system, it may happen that ReaR overwrites the HWADDR field in ifcfg-XXX files with the HWADDR of another network interface present on the system.

      This is due to having /usr/share/rear/finalize/GNU/Linux/300_create_mac_mapping.sh script rely on the ifcfg-XXX file name instead of actual content (see reproducer below):
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
      14 for file in "${PATCH_FILES[@]}"; do
      15 grep -q HWADDR $file || continue
      16 dev=$(echo $file | cut d -f3)
      17 old_mac=$(grep HWADDR $file | cut -d= -f2)
      18 new_mac=$(cat /sys/class/net/$dev/address)
      :
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

      Here above on line 16, the "dev" is computed as the first part of ifcfg-XXX file name, as shown in the examples below:

      • /etc/sysconfig/network-scripts/ifcfg-FOO --> device is supposed to be FOO
      • /etc/sysconfig/network-scripts/ifcfg-FOO-BAR --> device is supposed to be FOO as well

      This code is unreliable, the device name should be collected by checking the DEVICE field in the file instead.

      Version-Release number of selected component (if applicable):

      rear-2.4+ and Upstream (but didn't test)

      How reproducible:

      Always

      Steps to Reproduce:
      1. Add another network interface to a VM

      e.g. there was "enp1s0" and you add an interface that becomes "enp7s0"

      2. Create file ifcfg-enp1s0-enp7s0 as a modified copy of ifcfg-enp1s0 with corresponding HWADDR for enp7s0

      e.g. /etc/sysconfig/network-scripts/ifcfg-enp1s0
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
      TYPE="Ethernet"
      PROXY_METHOD="none"
      BROWSER_ONLY="no"
      BOOTPROTO="dhcp"
      DEFROUTE="yes"
      IPV4_FAILURE_FATAL="no"
      IPV6INIT="yes"
      IPV6_AUTOCONF="yes"
      IPV6_DEFROUTE="yes"
      IPV6_FAILURE_FATAL="no"
      IPV6_ADDR_GEN_MODE="stable-privacy"
      NAME="enp1s0"
      UUID="40412d75-5e23-4d6b-8a42-0f2b2995b1d7"
      ONBOOT="yes"
      HWADDR=52:54:00:20:7d:fb
      DEVICE="enp1s0"
      NAME="enp1s0"
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

      and /etc/sysconfig/network-scripts/ifcfg-enp1s0-enp7s0
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
      TYPE="Ethernet"
      PROXY_METHOD="none"
      BROWSER_ONLY="no"
      BOOTPROTO="dhcp"
      DEFROUTE="yes"
      IPV4_FAILURE_FATAL="no"
      IPV6INIT="yes"
      IPV6_AUTOCONF="yes"
      IPV6_DEFROUTE="yes"
      IPV6_FAILURE_FATAL="no"
      IPV6_ADDR_GEN_MODE="stable-privacy"
      NAME="enp1s0"
      UUID="5aa1ebf2-d4d4-4dc3-9f68-6d32ab457867"
      ONBOOT="yes"
      HWADDR=52:54:00:e5:bc:d1
      DEVICE="enp7s0"
      NAME="enp7s0"
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

      3. Create a REAR backup and restore it on same system

      Actual results:

      HWADDR in /mnt/local/etc/sysconfig/network-scripts/ifcfg-enp1s0-enp7s0 becomes the one for enp1s0:
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
      HWADDR=52:54:00:20:7d:fb
      -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

      Expected results:

      Correct MAC for enp7s0 even though the ifcfg file name is weird

      Additional info:

      You may think the root cause is the weird file name, but in fact it's not really the case, in normal situations, such kind of weirdness in names happens with slaves of bonding interfaces created using NetworkManager.

            rhn-support-pcahyna Pavel Cahyna
            rhn-support-rmetrich Renaud Métrich
            Pavel Cahyna Pavel Cahyna
            Jakub Haruda Jakub Haruda
            Sarka Jana Janderkova Sarka Jana Janderkova
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: