]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message 3553/head
authorRenato Westphal <renato@opensourcerouting.org>
Wed, 2 Jan 2019 15:05:53 +0000 (13:05 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Wed, 2 Jan 2019 15:32:31 +0000 (13:32 -0200)
Unlike the other interface zapi messages, ZEBRA_INTERFACE_VRF_UPDATE
identifies interfaces using ifindexes and not interface names. This
is a problem because zebra always sends ZEBRA_INTERFACE_DOWN
and ZEBRA_INTERFACE_DELETE messages before sending
ZEBRA_INTERFACE_VRF_UPDATE, and the ZEBRA_INTERFACE_DELETE callback
from all daemons set the interface index to IFINDEX_INTERNAL. Hence,
when decoding a ZEBRA_INTERFACE_VRF_UPDATE message, the interface
lookup would always fail since the corresponding interface lost
its ifindex. Example (ospfd):

OSPF: Zebra: Interface[rt1-eth2] state change to down.
OSPF: Zebra: interface delete rt1-eth2 vrf default[0] index 8 flags 11143 metric 0 mtu 1500
OSPF: [EC 100663301] INTERFACE_VRF_UPDATE: Cannot find IF 8 in VRF 0

To fix this problem, use interface names instead of ifindexes to
indentify interfaces like the other interface zapi messages do.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
lib/zclient.c
zebra/zapi_msg.c

index beb3ca4f345e844131af5b4d7e91265600ac946c..d2a6c75548f41698834c1ec3efacc1f6eff85e9a 100644 (file)
@@ -1770,19 +1770,19 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,
                                                  vrf_id_t vrf_id,
                                                  vrf_id_t *new_vrf_id)
 {
-       unsigned int ifindex;
+       char ifname[INTERFACE_NAMSIZ];
        struct interface *ifp;
        vrf_id_t new_id;
 
-       /* Get interface index. */
-       ifindex = stream_getl(s);
+       /* Read interface name. */
+       stream_get(ifname, s, INTERFACE_NAMSIZ);
 
        /* Lookup interface. */
-       ifp = if_lookup_by_index(ifindex, vrf_id);
+       ifp = if_lookup_by_name(ifname, vrf_id);
        if (ifp == NULL) {
                flog_err(EC_LIB_ZAPI_ENCODE,
-                        "INTERFACE_VRF_UPDATE: Cannot find IF %u in VRF %d",
-                        ifindex, vrf_id);
+                        "INTERFACE_VRF_UPDATE: Cannot find IF %s in VRF %d",
+                        ifname, vrf_id);
                return NULL;
        }
 
index 26a3cd5b42a03fca4dd06072525006c85cd3f5c9..32614f408e6085384db76d641f2ac550b33b8686 100644 (file)
@@ -432,8 +432,8 @@ int zsend_interface_vrf_update(struct zserv *client, struct interface *ifp,
 
        zclient_create_header(s, ZEBRA_INTERFACE_VRF_UPDATE, ifp->vrf_id);
 
-       /* Fill in the ifIndex of the interface and its new VRF (id) */
-       stream_putl(s, ifp->ifindex);
+       /* Fill in the name of the interface and its new VRF (id) */
+       stream_put(s, ifp->name, INTERFACE_NAMSIZ);
        stream_putl(s, vrf_id);
 
        /* Write packet size. */