]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: IPv4 MP-BGP Routes addition and deletion
authorG.Balaji <balajig81@gmail.com>
Sat, 26 Nov 2011 17:58:42 +0000 (21:58 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 23 Jan 2012 10:30:33 +0000 (14:30 +0400)
This patch contains the following:
1. Addition of IPv4 SAFI_MULTICAST BGP routes into the BGP Multicast RIB.
2. Deletion of IPv4 SAFI_MULTICAST BGP routes from the BGP Multicast RIB.

bgpd/bgp_route.c
bgpd/bgp_zebra.c
bgpd/bgp_zebra.h
lib/zclient.c
lib/zclient.h

index 68d05484798221cd6c37283175439fc03f1d1681..3e5e9c2fef83661dcca13a90e221f5d584c95eac 100644 (file)
@@ -1491,7 +1491,7 @@ bgp_process_main (struct work_queue *wq, void *data)
       if (! CHECK_FLAG (old_select->flags, BGP_INFO_ATTR_CHANGED))
         {
           if (CHECK_FLAG (old_select->flags, BGP_INFO_IGP_CHANGED))
-            bgp_zebra_announce (p, old_select, bgp);
+            bgp_zebra_announce (p, old_select, bgp, safi);
           
           UNSET_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED);
           return WQ_SUCCESS;
@@ -1514,20 +1514,20 @@ bgp_process_main (struct work_queue *wq, void *data)
     }
 
   /* FIB update. */
-  if (safi == SAFI_UNICAST && ! bgp->name &&
-      ! bgp_option_check (BGP_OPT_NO_FIB))
+  if ((safi == SAFI_UNICAST || safi == SAFI_MULTICAST) && (! bgp->name &&
+      ! bgp_option_check (BGP_OPT_NO_FIB)))
     {
       if (new_select 
          && new_select->type == ZEBRA_ROUTE_BGP 
          && new_select->sub_type == BGP_ROUTE_NORMAL)
-       bgp_zebra_announce (p, new_select, bgp);
+       bgp_zebra_announce (p, new_select, bgp, safi);
       else
        {
          /* Withdraw the route from the kernel. */
          if (old_select 
              && old_select->type == ZEBRA_ROUTE_BGP
              && old_select->sub_type == BGP_ROUTE_NORMAL)
-           bgp_zebra_withdraw (p, old_select);
+           bgp_zebra_withdraw (p, old_select, safi);
        }
     }
     
@@ -1810,7 +1810,7 @@ bgp_update_rsclient (struct peer *rsclient, afi_t afi, safi_t safi,
   bgp_attr_unintern (&attr_new2);
 
   /* IPv4 unicast next hop check.  */
-  if (afi == AFI_IP && safi == SAFI_UNICAST)
+  if ((afi == AFI_IP) && ((safi == SAFI_UNICAST) || safi == SAFI_MULTICAST))
     {
      /* Next hop must not be 0.0.0.0 nor Class D/E address. */
       if (new_attr.nexthop.s_addr == 0
@@ -2934,7 +2934,7 @@ bgp_cleanup_routes (void)
          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);
+           bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST);
 
       table = bgp->rib[AFI_IP6][SAFI_UNICAST];
 
@@ -2943,7 +2943,7 @@ bgp_cleanup_routes (void)
          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);
+           bgp_zebra_withdraw (&rn->p, ri,SAFI_UNICAST);
     }
 }
 
index 76c519cbe0c3c302e0d650a4299fc97551a510df..baf76fb052d84050d4faf53f0687ab0d3ae88fa1 100644 (file)
@@ -643,7 +643,7 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote,
 }
 
 void
-bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp)
+bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, safi_t safi)
 {
   int flags;
   u_char distance;
@@ -678,6 +678,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp)
 
       api.type = ZEBRA_ROUTE_BGP;
       api.message = 0;
+      api.safi = safi;
       SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
       api.nexthop_num = 1;
       api.nexthop = &nexthop;
@@ -778,7 +779,7 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp)
 }
 
 void
-bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info)
+bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi)
 {
   int flags;
   struct peer *peer;
@@ -812,6 +813,7 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info)
 
       api.type = ZEBRA_ROUTE_BGP;
       api.message = 0;
+      api.safi = safi;
       SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
       api.nexthop_num = 1;
       api.nexthop = &nexthop;
index bd9538642067e1ad10650bdf304a0ef73a5be094..1351333f739d42424882d088820879322abd07f6 100644 (file)
@@ -25,8 +25,8 @@ extern void bgp_zebra_init (void);
 extern int bgp_if_update_all (void);
 extern int bgp_config_write_redistribute (struct vty *, struct bgp *, afi_t, safi_t,
                                   int *);
-extern void bgp_zebra_announce (struct prefix *, struct bgp_info *, struct bgp *);
-extern void bgp_zebra_withdraw (struct prefix *, struct bgp_info *);
+extern void bgp_zebra_announce (struct prefix *, struct bgp_info *, struct bgp *, safi_t);
+extern void bgp_zebra_withdraw (struct prefix *, struct bgp_info *, safi_t);
 
 extern int bgp_redistribute_set (struct bgp *, afi_t, int);
 extern int bgp_redistribute_rmap_set (struct bgp *, afi_t, int, const char *);
index 12d113e7760832c497dc4c77b2354801ea04853a..0c3461e71b9f20948cd68fabcf7e2162c967e4be 100644 (file)
@@ -476,6 +476,7 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p,
   stream_putc (s, api->type);
   stream_putc (s, api->flags);
   stream_putc (s, api->message);
+  stream_putw (s, api->safi);
 
   /* Put prefix information. */
   psize = PSIZE (p->prefixlen);
index 5c3db382d87074859be4773956f9466c5ebdc0a8..8b3e71af89c87607bb9e3c4d2d52f772573269b6 100644 (file)
@@ -108,6 +108,8 @@ struct zapi_ipv4
 
   u_char message;
 
+  safi_t safi;
+
   u_char nexthop_num;
   struct in_addr **nexthop;