[quagga-dev 8830] [PATCH] bgp: Multi-protocol BGP redistribute connected

Robert Bays robert at vyatta.com
Mon Sep 12 00:57:19 BST 2011


unable to redistribute both IPv4 and IPv6 connected routes into BGP at the same time.

reproduction steps:
vyatta# sho ip route connected 
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       I - ISIS, B - BGP, > - selected route, * - FIB route

C>* 1.1.1.0/24 is directly connected, eth1
C>* 10.211.55.0/24 is directly connected, eth0
C>* 127.0.0.0/8 is directly connected, lo
vyatta# sho ipv6 route connected 
Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3,
       I - ISIS, B - BGP, * - FIB route.

C>* ::1/128 is directly connected, lo
C>* 2000::/32 is directly connected, eth1
C * fe80::/64 is directly connected, eth1
C>* fe80::/64 is directly connected, eth0
vyatta# conf t
vyatta(config)# router bgp 1
vyatta(config-router)# redistribute connected 
vyatta(config-router)# address-family ipv6 
vyatta(config-router-af)# redistribute connected 
vyatta(config-router-af)# end
vyatta# show ip bgp
BGP table version is 0, local router ID is 10.211.55.24
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1.0/24       0.0.0.0                  1         32768 ?
*> 10.211.55.0/24   0.0.0.0                  1         32768 ?

Total number of prefixes 2
vyatta# show ipv6 bgp
No BGP network exists
vyatta#

---------------------------
robert at build-32:~/ofr/vyatta-quagga$ git diff b16c574257285f3d73cd3e4fb653fada79c55385
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index d7af349..1dcb9c5
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -904,10 +904,10 @@ bgp_redistribute_set (struct bgp *bgp, afi_t afi, int type)
   bgp->redist[afi][type] = 1;
 
   /* Return if already redistribute flag is set. */
-  if (zclient->redist[type])
+  if (zclient->redist[type] > 1)
     return CMD_WARNING;
 
-  zclient->redist[type] = 1;
+  zclient->redist[type]++;
 
   /* Return if zebra connection is not established. */
   if (zclient->sock < 0)
@@ -974,7 +974,7 @@ bgp_redistribute_unset (struct bgp *bgp, afi_t afi, int type)
   /* Return if zebra connection is disabled. */
   if (! zclient->redist[type])
     return CMD_WARNING;
-  zclient->redist[type] = 0;
+  zclient->redist[type]--;
 
   if (bgp->redist[AFI_IP][type] == 0 
       && bgp->redist[AFI_IP6][type] == 0 
@@ -982,11 +982,11 @@ bgp_redistribute_unset (struct bgp *bgp, afi_t afi, int type)
     {
       /* Send distribute delete message to zebra. */
       if (BGP_DEBUG(zebra, ZEBRA))
-       zlog_debug("Zebra send: redistribute delete %s",
+           zlog_debug("Zebra send: redistribute delete %s",
                   zebra_route_string(type));
       zebra_redistribute_send (ZEBRA_REDISTRIBUTE_DELETE, zclient, type);
     }
-  
+
   /* Withdraw redistributed routes from current BGP's routing table. */
   bgp_redistribute_withdraw (bgp, afi, type);
 
diff --git a/lib/zclient.c b/lib/zclient.c
index 52a3627..2ab336a
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -954,7 +954,7 @@ zclient_redistribute (int command, struct zclient *zclient, int type)
 
   if (command == ZEBRA_REDISTRIBUTE_ADD) 
     {
-      if (zclient->redist[type])
+      if (zclient->redist[type] && (type != 1))
          return;
       zclient->redist[type] = 1;
     }
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index a8107ae..e81ad51
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -248,7 +248,6 @@ zebra_redistribute_add (int command, struct zserv *client, int length)
   switch (type)
     {
     case ZEBRA_ROUTE_KERNEL:
-    case ZEBRA_ROUTE_CONNECT:
     case ZEBRA_ROUTE_STATIC:
     case ZEBRA_ROUTE_RIP:
     case ZEBRA_ROUTE_RIPNG:
@@ -256,10 +255,14 @@ zebra_redistribute_add (int command, struct zserv *client, int length)
     case ZEBRA_ROUTE_OSPF6:
     case ZEBRA_ROUTE_BGP:
       if (! client->redist[type])
-       {
+           {
+               client->redist[type] = 1;
+               zebra_redistribute (client, type);
+           }
+         break;    
+    case ZEBRA_ROUTE_CONNECT:
          client->redist[type] = 1;
          zebra_redistribute (client, type);
-       }
       break;
     default:
       break;


More information about the Quagga-dev mailing list