[quagga-dev 8126] Re: [PATCH 07/10] bgpd: fix errors in aggregate address command

Balaji G balajig81 at gmail.com
Sun Aug 8 12:12:25 BST 2010


Applied, Thanks.

Cheers,
  - Balaji

On Thu, Aug 5, 2010 at 10:56 PM, Stephen Hemminger <shemminger at vyatta.com>wrote:

> From: Robert Bays <rbays at vyatta.com>
> This fixes locking and other issues with aggregate set/unset command
>
>
> --- a/bgpd/bgp_route.c  2010-08-05 09:33:09.589352356 -0700
> +++ b/bgpd/bgp_route.c  2010-08-05 09:40:28.743456345 -0700
> @@ -4986,9 +4986,8 @@ bgp_aggregate_delete (struct bgp *bgp, s
>  #define AGGREGATE_AS_SET       1
>
>  static int
> -bgp_aggregate_set (struct vty *vty, const char *prefix_str,
> -                   afi_t afi, safi_t safi,
> -                  u_char summary_only, u_char as_set)
> +bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
> +                     afi_t afi, safi_t safi)
>  {
>   int ret;
>   struct prefix p;
> @@ -5009,34 +5008,33 @@ bgp_aggregate_set (struct vty *vty, cons
>   bgp = vty->index;
>
>   /* Old configuration check. */
> -  rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
> -
> -  if (rn->info)
> +  rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
> +  if (! rn)
>     {
> -      vty_out (vty, "There is already same aggregate network.%s",
> VTY_NEWLINE);
> -      bgp_unlock_node (rn);
> +      vty_out (vty, "%% There is no aggregate-address configuration.%s",
> +               VTY_NEWLINE);
>       return CMD_WARNING;
>     }
>
> -  /* Make aggregate address structure. */
> -  aggregate = bgp_aggregate_new ();
> -  aggregate->summary_only = summary_only;
> -  aggregate->as_set = as_set;
> -  aggregate->safi = safi;
> -  rn->info = aggregate;
> +  aggregate = rn->info;
> +  if (aggregate->safi & SAFI_UNICAST)
> +    bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
> +  if (aggregate->safi & SAFI_MULTICAST)
> +    bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
>
> -  /* Aggregate address insert into BGP routing table. */
> -  if (safi & SAFI_UNICAST)
> -    bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
> -  if (safi & SAFI_MULTICAST)
> -    bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
> +  /* Unlock aggregate address configuration. */
> +  rn->info = NULL;
> +  bgp_aggregate_free (aggregate);
> +  bgp_unlock_node (rn);
> +  bgp_unlock_node (rn);
>
>   return CMD_SUCCESS;
>  }
>
>  static int
> -bgp_aggregate_unset (struct vty *vty, const char *prefix_str,
> -                     afi_t afi, safi_t safi)
> +bgp_aggregate_set (struct vty *vty, const char *prefix_str,
> +                   afi_t afi, safi_t safi,
> +                  u_char summary_only, u_char as_set)
>  {
>   int ret;
>   struct prefix p;
> @@ -5057,25 +5055,32 @@ bgp_aggregate_unset (struct vty *vty, co
>   bgp = vty->index;
>
>   /* Old configuration check. */
> -  rn = bgp_node_lookup (bgp->aggregate[afi][safi], &p);
> -  if (! rn)
> +  rn = bgp_node_get (bgp->aggregate[afi][safi], &p);
> +
> +  if (rn->info)
>     {
> -      vty_out (vty, "%% There is no aggregate-address configuration.%s",
> -              VTY_NEWLINE);
> -      return CMD_WARNING;
> +      vty_out (vty, "There is already same aggregate network.%s",
> VTY_NEWLINE);
> +      /* remove  old entry */
> +      ret = bgp_aggregate_unset (vty, prefix_str, afi, safi);
> +      if (ret)
> +        {
> +          vty_out (vty, "Error deleteing aggregate%s", VTY_NEWLINE);
> +         return CMD_WARNING;
> +        }
>     }
>
> -  aggregate = rn->info;
> -  if (aggregate->safi & SAFI_UNICAST)
> -    bgp_aggregate_delete (bgp, &p, afi, SAFI_UNICAST, aggregate);
> -  if (aggregate->safi & SAFI_MULTICAST)
> -    bgp_aggregate_delete (bgp, &p, afi, SAFI_MULTICAST, aggregate);
> +  /* Make aggregate address structure. */
> +  aggregate = bgp_aggregate_new ();
> +  aggregate->summary_only = summary_only;
> +  aggregate->as_set = as_set;
> +  aggregate->safi = safi;
> +  rn->info = aggregate;
>
> -  /* Unlock aggregate address configuration. */
> -  rn->info = NULL;
> -  bgp_aggregate_free (aggregate);
> -  bgp_unlock_node (rn);
> -  bgp_unlock_node (rn);
> +  /* Aggregate address insert into BGP routing table. */
> +  if (safi & SAFI_UNICAST)
> +    bgp_aggregate_add (bgp, &p, afi, SAFI_UNICAST, aggregate);
> +  if (safi & SAFI_MULTICAST)
> +    bgp_aggregate_add (bgp, &p, afi, SAFI_MULTICAST, aggregate);
>
>   return CMD_SUCCESS;
>  }
>
>
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev at lists.quagga.net
> http://lists.quagga.net/mailman/listinfo/quagga-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quagga.net/pipermail/quagga-dev/attachments/20100808/47d8b203/attachment-0001.html>


More information about the Quagga-dev mailing list