]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Fix wrong vrf change procedure
authoranlan_cs <vic.lan@pica8.com>
Mon, 22 May 2023 10:32:23 +0000 (18:32 +0800)
committeranlan_cs <vic.lan@pica8.com>
Thu, 13 Jul 2023 07:25:31 +0000 (15:25 +0800)
Currently the vrf change procedure for the deleted interface is after
its deletion, it causes problem for upper daemons.

Here is the problem of `bgp`:

After deletion of one **irrelevant** interface in the same vrf, its
`ifindex` is set to 0. And then, the vrf change procedure will send
"ZEBRA_INTERFACE_DOWN" to `bgpd`.

Normally, `bgp_nht_ifp_table_handle()` should igore this message for
no correlation. However, it wrongly matched `ifindex` of 0, and removed
the related routes for the down `bnc`.

Adjust the location of the vrf change procedure to fix this issue.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
zebra/interface.c

index 989763d13cd1e427391474ea1145759ab26edde5..4006f9c574a7948747952be561cc1796965f014a 100644 (file)
@@ -787,6 +787,15 @@ void if_delete_update(struct interface **pifp)
        /* Delete connected routes from the kernel. */
        if_delete_connected(ifp);
 
+       /* if the ifp is in a vrf, move it to default so vrf can be deleted if
+        * desired. This operation is not done for netns implementation to avoid
+        * collision with interface with the same name in the default vrf (can
+        * occur with this implementation whereas it is not possible with
+        * vrf-lite).
+        */
+       if (ifp->vrf->vrf_id && !vrf_is_backend_netns())
+               if_handle_vrf_change(ifp, VRF_DEFAULT);
+
        /* Send out notification on interface delete. */
        zebra_interface_delete_update(ifp);
 
@@ -800,15 +809,6 @@ void if_delete_update(struct interface **pifp)
        if_set_index(ifp, IFINDEX_INTERNAL);
        ifp->node = NULL;
 
-       /* if the ifp is in a vrf, move it to default so vrf can be deleted if
-        * desired. This operation is not done for netns implementation to avoid
-        * collision with interface with the same name in the default vrf (can
-        * occur with this implementation whereas it is not possible with
-        * vrf-lite).
-        */
-       if (ifp->vrf->vrf_id && !vrf_is_backend_netns())
-               if_handle_vrf_change(ifp, VRF_DEFAULT);
-
        UNSET_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK);
 
        /* Reset some zebra interface params to default values. */