]> git.proxmox.com Git - mirror_frr.git/commit - lib/if.c
zebra: fix crash when interface vrf changes
authorThibaut Collet <thibaut.collet@6wind.com>
Tue, 29 May 2018 08:34:38 +0000 (10:34 +0200)
committerThibaut Collet <thibaut.collet@6wind.com>
Thu, 30 Aug 2018 12:37:59 +0000 (14:37 +0200)
commitee2f2c23ca2778feafa398e773d24da07d6f174e
tree8df2720aa15d22fab78106e98c7090c8b96935fc
parent20c87e98d8399c322f3f8da9d34ca19fd4ca1865
zebra: fix crash when interface vrf changes

This crash occurs only with netns implementation.
vrf meaning is different regarging its implementation (netns or
vrf-lite)

- With vrf-lite implementation vrf is a property of the interface that
  can be changed as the speed or the state (iproute2 command: "ip link
  set dev IF_NAME master VRF_NAME"). All interfaces of the system are in
  the same netns and so interface name is unique.
- With netns implementation vrf is a characteristic of the interface
  that CANNOT be changed: it is the id of the netns where the interface
  is located. To change the vrf of an interface (iproute2 command to
  move an interface "ip netns exec VRF_NAME1 ip link set dev IF_NAME
  netns VRF_NAME2") the interface is deleted from the old vrf and
  created in the new vrf.
  Interface name is not unique, the same name can be present in the
  different netns (typically the lo interface) and search of interface
  must be done by the tuple (interface name, netns id).

Current tests on the vrf implementation (vrf-lite or netns) are not
sufficient. In some cases (for example when an interface is moved from
a vrf X to the default vrf and then move back to VRF X) we can have a
corruption message and then a crash of zebra.

To avoid this corruption test on the vrf implementation, needed when an
interface changes, has been rewritten:
- For all interface changes except deletion the if_get_by_name function,
  that checks if an interface exists and creates or updates it if
  needed, is changed:
    * The vrf-lite implementation is unchanged: search of the interface
      is based only on the name and update the vrf-id if needed.
    * The netns implementation search of the interface is based on the
      (name, vrf-id) tuple and interface is created if not found, the
      vrf-id is never updated.
- deletion of an interface (reception of a RTM_DELLINK netlink message):
    * The vrf-lite implementation is unchanged: the interface
      information are cleared and the interface is moved to the default
      vrf if it does not belong to (to allow vrf deletion)
    * The netns implementation is changed: only the interface
      information are cleared and the interface stays in its vrf to
      avoid conflict with interface with the same name in the default
      vrf.

This implementation reverts (partially or totally):
commit 393ec5424e35 ("zebra: fix missing node attribute set in ifp")
commit e9e9b1150f0c ("lib: create interface even if name is the same")
commit 9373219c67e1 ("zebra: improve logs when replacing interface to an
other netns")
Fixes: b53686c52a59 ("zebra: delete interface that disappeared")
Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
lib/if.c
zebra/if_netlink.c
zebra/interface.c
zebra/interface.h