]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/rfapi/vnc_export_table.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / bgpd / rfapi / vnc_export_table.c
index 36e5a49fe340bdb32871b3a21b50dd9d95f04c06..4b6bacae9646eabdbc2763187163bc0f0c148a1f 100644 (file)
@@ -1,28 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  *
  * Copyright 2009-2016, LabN Consulting, L.L.C.
  *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
  */
 
 
 #include "lib/zebra.h"
 #include "lib/prefix.h"
-#include "lib/table.h"
+#include "lib/agg_table.h"
 #include "lib/memory.h"
 #include "lib/vty.h"
 
 #include "bgpd/rfapi/rfapi_import.h"
 #include "bgpd/rfapi/vnc_debug.h"
 
-struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type,
-                              struct prefix *p)
+struct agg_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type,
+                            const struct prefix *p)
 {
-       struct route_table *t = NULL;
-       struct route_node *rn = NULL;
+       struct agg_table *t = NULL;
+       struct agg_node *rn = NULL;
        afi_t afi;
 
        if (!bgp || !bgp->rfapi)
@@ -50,27 +36,27 @@ struct route_node *vnc_etn_get(struct bgp *bgp, vnc_export_type_t type,
        switch (type) {
        case EXPORT_TYPE_BGP:
                if (!bgp->rfapi->rt_export_bgp[afi])
-                       bgp->rfapi->rt_export_bgp[afi] = route_table_init();
+                       bgp->rfapi->rt_export_bgp[afi] = agg_table_init();
                t = bgp->rfapi->rt_export_bgp[afi];
                break;
 
        case EXPORT_TYPE_ZEBRA:
                if (!bgp->rfapi->rt_export_zebra[afi])
-                       bgp->rfapi->rt_export_zebra[afi] = route_table_init();
+                       bgp->rfapi->rt_export_zebra[afi] = agg_table_init();
                t = bgp->rfapi->rt_export_zebra[afi];
                break;
        }
 
        if (t)
-               rn = route_node_get(t, p);
+               rn = agg_node_get(t, p);
        return rn;
 }
 
-struct route_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type,
-                                 struct prefix *p)
+struct agg_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type,
+                               const struct prefix *p)
 {
-       struct route_table *t = NULL;
-       struct route_node *rn = NULL;
+       struct agg_table *t = NULL;
+       struct agg_node *rn = NULL;
        afi_t afi;
 
        if (!bgp || !bgp->rfapi)
@@ -82,27 +68,27 @@ struct route_node *vnc_etn_lookup(struct bgp *bgp, vnc_export_type_t type,
        switch (type) {
        case EXPORT_TYPE_BGP:
                if (!bgp->rfapi->rt_export_bgp[afi])
-                       bgp->rfapi->rt_export_bgp[afi] = route_table_init();
+                       bgp->rfapi->rt_export_bgp[afi] = agg_table_init();
                t = bgp->rfapi->rt_export_bgp[afi];
                break;
 
        case EXPORT_TYPE_ZEBRA:
                if (!bgp->rfapi->rt_export_zebra[afi])
-                       bgp->rfapi->rt_export_zebra[afi] = route_table_init();
+                       bgp->rfapi->rt_export_zebra[afi] = agg_table_init();
                t = bgp->rfapi->rt_export_zebra[afi];
                break;
        }
 
        if (t)
-               rn = route_node_lookup(t, p);
+               rn = agg_node_lookup(t, p);
        return rn;
 }
 
 struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype,
-                                   struct prefix *p, struct peer *peer,
+                                   const struct prefix *p, struct peer *peer,
                                    uint8_t type, uint8_t subtype)
 {
-       struct route_node *etn;
+       struct agg_node *etn;
        struct vnc_export_info *eti;
 
        etn = vnc_etn_get(bgp, etype, p);
@@ -117,10 +103,9 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype,
        }
 
        if (eti) {
-               route_unlock_node(etn);
+               agg_unlock_node(etn);
        } else {
                eti = XCALLOC(MTYPE_RFAPI_ETI, sizeof(struct vnc_export_info));
-               assert(eti);
                eti->node = etn;
                eti->peer = peer;
                peer_lock(peer);
@@ -135,7 +120,7 @@ struct vnc_export_info *vnc_eti_get(struct bgp *bgp, vnc_export_type_t etype,
 
 void vnc_eti_delete(struct vnc_export_info *goner)
 {
-       struct route_node *etn;
+       struct agg_node *etn;
        struct vnc_export_info *eti;
        struct vnc_export_info *eti_prev = NULL;
 
@@ -161,15 +146,16 @@ void vnc_eti_delete(struct vnc_export_info *goner)
        goner->node = NULL;
        XFREE(MTYPE_RFAPI_ETI, goner);
 
-       route_unlock_node(etn);
+       agg_unlock_node(etn);
 }
 
 struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp,
                                           vnc_export_type_t etype,
-                                          struct prefix *p, struct peer *peer,
-                                          uint8_t type, uint8_t subtype)
+                                          const struct prefix *p,
+                                          struct peer *peer, uint8_t type,
+                                          uint8_t subtype)
 {
-       struct route_node *etn;
+       struct agg_node *etn;
        struct vnc_export_info *eti;
 
        etn = vnc_etn_lookup(bgp, etype, p);
@@ -184,7 +170,7 @@ struct vnc_export_info *vnc_eti_checktimer(struct bgp *bgp,
                }
        }
 
-       route_unlock_node(etn);
+       agg_unlock_node(etn);
 
        if (eti && eti->timer)
                return eti;