]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: fix double clearing of zif->es_info.es
authorAnuradha Karuppiah <anuradhak@cumulusnetworks.com>
Wed, 30 Sep 2020 19:03:06 +0000 (12:03 -0700)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 28 Oct 2020 18:35:48 +0000 (21:35 +0300)
This problem was accidentally introduced as a part of another fixup -
[
commit e378f5020d1af1aee587659e5602ee8c07eb05f4 (anuradhak/mh-misc-fixes, mh-misc-fixes)
Author: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Date:   Tue Sep 15 16:50:14 2020 -0700

    zebra: fix use of freed es during zebra shutdown
]

zif->es_info.es is cleared as a part of zebra_evpn_es_local_info_clear so it
cannot be passed around as a pointer from zebra_evpn_local_es_update/del.

Because of this bug removing ES from an interface resulted in
a zebra crash.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
zebra/zebra_evpn_mh.c

index 7b397df384eab3e9d61bf3a946ef0c221c4fc572..dc8a4145c53623bd052987e544e10f486e27fe1b 100644 (file)
@@ -808,6 +808,7 @@ void zebra_evpn_if_init(struct zebra_if *zif)
 void zebra_evpn_if_cleanup(struct zebra_if *zif)
 {
        vlanid_t vid;
+       struct zebra_evpn_es *es;
 
        if (!bf_is_inited(zif->vlan_bitmap))
                return;
@@ -819,8 +820,9 @@ void zebra_evpn_if_cleanup(struct zebra_if *zif)
        bf_free(zif->vlan_bitmap);
 
        /* Delete associated Ethernet Segment */
-       if (zif->es_info.es)
-               zebra_evpn_local_es_del(&zif->es_info.es);
+       es = zif->es_info.es;
+       if (es)
+               zebra_evpn_local_es_del(&es);
 }
 
 /*****************************************************************************
@@ -1448,7 +1450,7 @@ static int zebra_evpn_local_es_update(struct zebra_if *zif, uint32_t lid,
        if (!lid || is_zero_mac(sysmac)) {
                /* if in ES is attached to zif delete it */
                if (old_es)
-                       zebra_evpn_local_es_del(&zif->es_info.es);
+                       zebra_evpn_local_es_del(&old_es);
                return 0;
        }
 
@@ -1473,7 +1475,7 @@ static int zebra_evpn_local_es_update(struct zebra_if *zif, uint32_t lid,
 
        /* release the old_es against the zif */
        if (old_es)
-               zebra_evpn_local_es_del(&zif->es_info.es);
+               zebra_evpn_local_es_del(&old_es);
 
        es = zebra_evpn_es_find(&esi);
        if (es) {