Are the changes (fixes) here primarily related to cleaning up memory when a
BGP instance is deleted?

On Thu, Dec 24, 2015 at 10:10 AM, Lou Berger <lber...@labn.net> wrote:

> Signed-off-by: Lou Berger <lber...@labn.net>
> Signed-off-by: David Lamparter <equi...@opensourcerouting.org>
> ---
>  /* Delete all kernel routes. */
>  void
>  bgp_cleanup_routes (void)
>  {
>    struct bgp *bgp;
>    struct listnode *node, *nnode;
> -  struct bgp_node *rn;
> -  struct bgp_table *table;
> -  struct bgp_info *ri;
> +  afi_t afi;
>
>    for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
>      {
> -      table = bgp->rib[AFI_IP][SAFI_UNICAST];
> +      for (afi = AFI_IP; afi < AFI_MAX; ++afi)
> +       {
> +         struct bgp_node *rn;
>
> -      for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
> -       for (ri = rn->info; ri; ri = ri->next)
> -         if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
> -             && ri->type == ZEBRA_ROUTE_BGP
> -             && ri->sub_type == BGP_ROUTE_NORMAL)
> -           bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST);
> +         bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
>
> -      table = bgp->rib[AFI_IP6][SAFI_UNICAST];
> +         /*
> +          * VPN and ENCAP tables are two-level (RD is top level)
> +          */
> +         for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
> +               rn = bgp_route_next (rn))
> +             if (rn->info)
> +                {
> +                   bgp_cleanup_table((struct bgp_table *)(rn->info),
> SAFI_MPLS_VPN);
>

VPN routes shouldn't require a bgp_cleanup_table() because they are not
installed in zebra.


> +                   bgp_table_finish ((struct bgp_table **)&(rn->info));
> +                  rn->info = NULL;
> +                  bgp_unlock_node(rn);
> +                }
>
> -      for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
> -       for (ri = rn->info; ri; ri = ri->next)
> -         if (CHECK_FLAG (ri->flags, BGP_INFO_SELECTED)
> -             && ri->type == ZEBRA_ROUTE_BGP
> -             && ri->sub_type == BGP_ROUTE_NORMAL)
> -           bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST);
>      }
>  }
>
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to