]> git.puffer.fish Git - mirror/frr.git/commitdiff
Merge graceful restart capability display and some small fixes from Zebra
authorhasso <hasso>
Fri, 21 May 2004 09:31:30 +0000 (09:31 +0000)
committerhasso <hasso>
Fri, 21 May 2004 09:31:30 +0000 (09:31 +0000)
repository by Rivo Nurges.

bgpd/ChangeLog
bgpd/bgp_fsm.c
bgpd/bgp_open.c
bgpd/bgp_open.h
bgpd/bgp_vty.c
bgpd/bgp_vty.h
bgpd/bgpd.c
bgpd/bgpd.h

index 49b9a4c0d03deda0396de7b9618d0c34acfb597f..9ed186bd0bf79ab99fdc4b335b7b65ac59e2fc9a 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-21  Akihiro Mizutani <mizutani@net-chef.net>
+
+       * bgpd.h, bgp_open.[ch], bgp_debug.c, bgp_vty.[ch], bgp_fsm.c:
+         Graceful restart capability display.
+
 2005-05-20 Kunihiro Ishiguro  <kunihiro@ipinfusion.com>
 
        * bgp_debug.c: Cosmetical fixes and log neighbor changes.
index d28cd93401737f1c5fb029f183e49cdad6ed0af6..2874a9a08306ea03a73c4886433996a1222e2415 100644 (file)
@@ -338,7 +338,6 @@ char *peer_down_str[] =
 int
 bgp_stop (struct peer *peer)
 {
-  int established = 0;
   afi_t afi;
   safi_t safi;
   char orf_name[BUFSIZ];
@@ -346,7 +345,6 @@ bgp_stop (struct peer *peer)
   /* Increment Dropped count. */
   if (peer->status == Established)
     {
-      established = 1;
       peer->dropped++;
       bgp_fsm_change_status (peer, Idle);
 
@@ -363,11 +361,13 @@ bgp_stop (struct peer *peer)
 #ifdef HAVE_SNMP
       bgpTrapBackwardTransition (peer);
 #endif /* HAVE_SNMP */
-    }
 
-  /* Need of clear of peer. */
-  if (established)
-    bgp_clear_route_all (peer);
+      /* Reset uptime. */
+      bgp_uptime_reset (peer);
+
+      /* Need of clear of peer. */
+      bgp_clear_route_all (peer);
+    }
 
   /* Stop read and write threads when exists. */
   BGP_READ_OFF (peer->t_read);
@@ -417,39 +417,26 @@ bgp_stop (struct peer *peer)
   /* Clear remote router-id. */
   peer->remote_id.s_addr = 0;
 
-  /* Reset all negotiated variables */
-  peer->afc_nego[AFI_IP][SAFI_UNICAST] = 0;
-  peer->afc_nego[AFI_IP][SAFI_MULTICAST] = 0;
-  peer->afc_nego[AFI_IP][SAFI_MPLS_VPN] = 0;
-  peer->afc_nego[AFI_IP6][SAFI_UNICAST] = 0;
-  peer->afc_nego[AFI_IP6][SAFI_MULTICAST] = 0;
-  peer->afc_adv[AFI_IP][SAFI_UNICAST] = 0;
-  peer->afc_adv[AFI_IP][SAFI_MULTICAST] = 0;
-  peer->afc_adv[AFI_IP][SAFI_MPLS_VPN] = 0;
-  peer->afc_adv[AFI_IP6][SAFI_UNICAST] = 0;
-  peer->afc_adv[AFI_IP6][SAFI_MULTICAST] = 0;
-  peer->afc_recv[AFI_IP][SAFI_UNICAST] = 0;
-  peer->afc_recv[AFI_IP][SAFI_MULTICAST] = 0;
-  peer->afc_recv[AFI_IP][SAFI_MPLS_VPN] = 0;
-  peer->afc_recv[AFI_IP6][SAFI_UNICAST] = 0;
-  peer->afc_recv[AFI_IP6][SAFI_MULTICAST] = 0;
-
-  /* Reset route refresh flag. */
-  UNSET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV);
-  UNSET_FLAG (peer->cap, PEER_CAP_REFRESH_OLD_RCV);
-  UNSET_FLAG (peer->cap, PEER_CAP_REFRESH_NEW_RCV);
-  UNSET_FLAG (peer->cap, PEER_CAP_DYNAMIC_ADV);
-  UNSET_FLAG (peer->cap, PEER_CAP_DYNAMIC_RCV);
+  /* Clear peer capability flag. */
+  peer->cap = 0;
 
   for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
     for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
       {
+        /* Reset all negotiated variables */
+        peer->afc_nego[afi][safi] = 0;
+        peer->afc_adv[afi][safi] = 0;
+        peer->afc_recv[afi][safi] = 0;
+
        /* peer address family capability flags*/
        peer->af_cap[afi][safi] = 0;
+
        /* peer address family status flags*/
        peer->af_sflags[afi][safi] = 0;
+
        /* Received ORF prefix-filter */
        peer->orf_plist[afi][safi] = NULL;
+
         /* ORF received prefix-filter pnt */
         sprintf (orf_name, "%s.%d.%d", peer->host, afi, safi);
         prefix_bgp_orf_remove_all (orf_name);
index a3e86b06c8f2691c9ce91294be1acdd815262fce..ae4a7d4081a58e66f60c0ec99ce255c191f01985 100644 (file)
@@ -33,7 +33,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "bgpd/bgp_fsm.h"
 #include "bgpd/bgp_packet.h"
 #include "bgpd/bgp_open.h"
-\f
+#include "bgpd/bgp_vty.h"
+
 /* BGP-4 Multiprotocol Extentions lead us to the complex world. We can
    negotiate remote peer supports extentions or not. But if
    remote-peer doesn't supports negotiation process itself.  We would
@@ -373,7 +374,7 @@ bgp_capability_parse (struct peer *peer, u_char *pnt, u_char length,
               || cap.code == CAPABILITY_CODE_REFRESH_OLD)
        {
          /* Check length. */
-         if (cap.length != 0)
+         if (cap.length != CAPABILITY_CODE_REFRESH_LEN)
            {
              zlog_info ("%s Route Refresh Capability length error %d",
                         peer->host, cap.length);
@@ -395,10 +396,81 @@ bgp_capability_parse (struct peer *peer, u_char *pnt, u_char length,
       else if (cap.code == CAPABILITY_CODE_ORF
               || cap.code == CAPABILITY_CODE_ORF_OLD)
        bgp_capability_orf (peer, &cap, pnt + sizeof (struct capability));
+      else if (cap.code == CAPABILITY_CODE_RESTART)
+       {
+         struct graceful_restart_af graf;
+         u_int16_t restart_flag_time;
+         int restart_bit = 0;
+         int forwarding_bit = 0;
+         u_char *restart_pnt;
+         u_char *restart_end;
+
+         /* Check length. */
+         if (cap.length < CAPABILITY_CODE_RESTART_LEN)
+           {
+             zlog_info ("%s Graceful Restart Capability length error %d",
+                        peer->host, cap.length);
+             bgp_notify_send (peer, BGP_NOTIFY_CEASE, 0);
+             return -1;
+           }
+
+         SET_FLAG (peer->cap, PEER_CAP_RESTART_RCV);
+         restart_flag_time = ntohs(cap.mpc.afi);
+         if (CHECK_FLAG (restart_flag_time, RESTART_R_BIT))
+           restart_bit = 1;
+         UNSET_FLAG (restart_flag_time, 0xF000); 
+         peer->restart_time_rcv = restart_flag_time;
+
+         if (BGP_DEBUG (normal, NORMAL))
+           {
+             zlog_info ("%s OPEN has Graceful Restart capability", peer->host);
+             zlog_info ("%s Peer has%srestarted. Restart Time : %d",
+                        peer->host, restart_bit ? " " : " not ",
+                        peer->restart_time_rcv);
+           }
+
+         restart_pnt = pnt + 4;
+         restart_end = pnt + cap.length + 2;
+
+         while (restart_pnt < restart_end)
+           {
+             memcpy (&graf, restart_pnt, sizeof (struct graceful_restart_af));
+
+             afi = ntohs(graf.afi);
+             safi = graf.safi;
+
+             if (CHECK_FLAG (graf.flag, RESTART_F_BIT))
+               forwarding_bit = 1;
+
+             if (strcmp (afi_safi_print (afi, safi), "Unknown") == 0)
+               {
+                  if (BGP_DEBUG (normal, NORMAL))
+                    zlog_info ("%s Addr-family %d/%d(afi/safi) not supported. I gnore the Graceful Restart capability",
+                               peer->host, afi, safi);
+               }
+             else if (! peer->afc[afi][safi])
+               {
+                  if (BGP_DEBUG (normal, NORMAL))
+                     zlog_info ("%s Addr-family %d/%d(afi/safi) not enabled. Ignore the Graceful Restart capability",
+                                peer->host, afi, safi);
+               }
+             else
+               {
+                 if (BGP_DEBUG (normal, NORMAL))
+                   zlog_info ("%s Address family %s is%spreserved", peer->host,
+                              afi_safi_print (afi, safi), forwarding_bit ? " " : " not ");
+
+                 if (forwarding_bit)
+                   SET_FLAG (peer->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV);
+               }
+             forwarding_bit = 0;
+             restart_pnt += 4;
+           }
+       }
       else if (cap.code == CAPABILITY_CODE_DYNAMIC)
        {
          /* Check length. */
-         if (cap.length != 0)
+         if (cap.length != CAPABILITY_CODE_DYNAMIC_LEN)
            {
              zlog_info ("%s Dynamic Capability length error %d",
                         peer->host, cap.length);
@@ -787,6 +859,17 @@ bgp_open_capability (struct stream *s, struct peer *peer)
       stream_putc (s, CAPABILITY_CODE_DYNAMIC_LEN);
     }
 
+  /* Graceful restart capability */
+  if (bgp_flag_check (peer->bgp, BGP_FLAG_GRACEFUL_RESTART))
+    {
+      SET_FLAG (peer->cap, PEER_CAP_RESTART_ADV);
+      stream_putc (s, BGP_OPEN_OPT_CAP);
+      stream_putc (s, CAPABILITY_CODE_RESTART_LEN + 2);
+      stream_putc (s, CAPABILITY_CODE_RESTART);
+      stream_putc (s, CAPABILITY_CODE_RESTART_LEN);
+      stream_putw (s, peer->bgp->restart_time);
+     }
+
   /* Total Opt Parm Len. */
   len = stream_get_putp (s) - cp - 1;
   stream_putc_at (s, cp, len);
index af7505a8f65930cd311f5e77dacaf4ce544d50a7..014bc33068377b76ab6692fc1a1321b770d6d00f 100644 (file)
@@ -34,36 +34,48 @@ struct capability
   struct capability_mp mpc;
 };
 
-/* Multiprotocol Extensions capabilities. */
-#define CAPABILITY_CODE_MP              1
-#define CAPABILITY_CODE_MP_LEN          4
+struct graceful_restart_af
+{
+  u_int16_t afi;
+  u_char safi;
+  u_char flag;
+};
+
+/* Capability Code */
+#define CAPABILITY_CODE_MP              1 /* Multiprotocol Extensions */
+#define CAPABILITY_CODE_REFRESH         2 /* Route Refresh Capability */
+#define CAPABILITY_CODE_ORF             3 /* Cooperative Route Filtering Capability */
+#define CAPABILITY_CODE_RESTART        64 /* Graceful Restart Capability */
+#define CAPABILITY_CODE_4BYTE_AS       65 /* 4-octet AS number Capability */
+#define CAPABILITY_CODE_DYNAMIC        66 /* Dynamic Capability */
+#define CAPABILITY_CODE_REFRESH_OLD   128 /* Route Refresh Capability(cisco) */
+#define CAPABILITY_CODE_ORF_OLD       130 /* Cooperative Route Filtering Capability(cisco) */
 
-/* Route refresh capabilities. */
-#define CAPABILITY_CODE_REFRESH         2
-#define CAPABILITY_CODE_REFRESH_OLD   128
+/* Capability Length */
+#define CAPABILITY_CODE_MP_LEN          4
 #define CAPABILITY_CODE_REFRESH_LEN     0
+#define CAPABILITY_CODE_DYNAMIC_LEN     0
+#define CAPABILITY_CODE_RESTART_LEN     2 /* Receiving only case */
 
 /* Cooperative Route Filtering Capability.  */
-#define CAPABILITY_CODE_ORF             3 
-#define CAPABILITY_CODE_ORF_OLD       130
 
-/* ORF Type */
+/* ORF Type */
 #define ORF_TYPE_PREFIX                64 
 #define ORF_TYPE_PREFIX_OLD           128
 
-/* ORF Mode */
+/* ORF Mode */
 #define ORF_MODE_RECEIVE                1 
 #define ORF_MODE_SEND                   2 
 #define ORF_MODE_BOTH                   3 
 
-/* Dynamic capability.  */
-#define CAPABILITY_CODE_DYNAMIC        66
-#define CAPABILITY_CODE_DYNAMIC_LEN     0
-
 /* Capability Message Action.  */
 #define CAPABILITY_ACTION_SET           0
 #define CAPABILITY_ACTION_UNSET         1
 
+/* Graceful Restart */
+#define RESTART_R_BIT              0x8000
+#define RESTART_F_BIT              0x80
+
 int bgp_open_option_parse (struct peer *, u_char, int *);
 void bgp_open_capability (struct stream *, struct peer *);
 void bgp_capability_vty_out (struct vty *, struct peer *);
index dda4029322af2d631ce3f57595decd8e28888e64..c7de8eb6ef0a416943a97e0730d07d03fdbbffa9 100644 (file)
@@ -760,7 +760,35 @@ DEFUN (no_bgp_deterministic_med,
   bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
   return CMD_SUCCESS;
 }
-\f
+
+/* "bgp graceful-restart" configuration. */
+DEFUN (bgp_graceful_restart,
+       bgp_graceful_restart_cmd,
+       "bgp graceful-restart",
+       "BGP specific commands\n"
+       "Graceful restart capability parameters\n")
+{
+  struct bgp *bgp;
+
+  bgp = vty->index;
+  bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_bgp_graceful_restart,
+       no_bgp_graceful_restart_cmd,
+       "no bgp graceful-restart",
+       NO_STR
+       "BGP specific commands\n"
+       "Graceful restart capability parameters\n")
+{
+  struct bgp *bgp;
+
+  bgp = vty->index;
+  bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
+  return CMD_SUCCESS;
+}
+
 /* "bgp fast-external-failover" configuration. */
 DEFUN (bgp_fast_external_failover,
        bgp_fast_external_failover_cmd,
@@ -6245,6 +6273,23 @@ DEFUN (show_ipv6_mbgp_summary,
 }
 #endif /* HAVE_IPV6 */
 \f
+char *
+afi_safi_print (afi_t afi, safi_t safi)
+{
+  if (afi == AFI_IP && safi == SAFI_UNICAST)
+    return "IPv4 Unicast";
+  else if (afi == AFI_IP && safi == SAFI_MULTICAST)
+    return "IPv4 Multicast";
+  else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
+    return "VPNv4 Unicast";
+  else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
+    return "IPv6 Unicast";
+  else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
+    return "IPv6 Multicast";
+  else
+    return "Unknown";
+}
+
 /* Show BGP peer's information. */
 enum show_type
 {
@@ -6296,11 +6341,9 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
 
   filter = &p->filter[afi][safi];
 
-  vty_out (vty, " For address family: %s %s%s",
-          afi == AFI_IP6 ? "IPv6" :
-          safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4",
-          safi == SAFI_MULTICAST ? "Multicast" : "Unicast",
+  vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
           VTY_NEWLINE);
+
   if (p->af_group[afi][safi])
     vty_out (vty, "  %s peer-group member%s", p->group->name, VTY_NEWLINE);
 
@@ -6377,11 +6420,11 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
       vty_out (vty, "  Community attribute sent to this neighbor");
       if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
        && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
-       vty_out (vty, " (both)%s", VTY_NEWLINE);
+       vty_out (vty, "(both)%s", VTY_NEWLINE);
       else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
-       vty_out (vty, " (extended)%s", VTY_NEWLINE);
+       vty_out (vty, "(extended)%s", VTY_NEWLINE);
       else 
-       vty_out (vty, " (standard)%s", VTY_NEWLINE);
+       vty_out (vty, "(standard)%s", VTY_NEWLINE);
     }
   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
     {
@@ -6485,6 +6528,8 @@ bgp_show_peer (struct vty *vty, struct peer *p)
   struct bgp *bgp;
   char buf1[BUFSIZ];
   char timebuf[BGP_UPTIME_LEN];
+  afi_t afi;
+  safi_t safi;
 
   bgp = p->bgp;
 
@@ -6549,11 +6594,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
   /* Capability. */
   if (p->status == Established) 
     {
-      if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
-         || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
-         || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
-         || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)
-         || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
+      if (p->cap
          || p->afc_adv[AFI_IP][SAFI_UNICAST]
          || p->afc_recv[AFI_IP][SAFI_UNICAST]
          || p->afc_adv[AFI_IP][SAFI_MULTICAST]
@@ -6577,11 +6618,8 @@ bgp_show_peer (struct vty *vty, struct peer *p)
              if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
                vty_out (vty, " advertised");
              if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
-               {
-                 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
-                   vty_out (vty, " and");
-                 vty_out (vty, " received");
-               }
+               vty_out (vty, " %sreceived",
+                        CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
              vty_out (vty, "%s", VTY_NEWLINE);
            }
 
@@ -6595,91 +6633,61 @@ bgp_show_peer (struct vty *vty, struct peer *p)
                vty_out (vty, " advertised");
              if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
                  || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
-               {
-                 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
-                   vty_out (vty, " and");
-                 vty_out (vty, " received");
-                 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
-                     && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
-                   vty_out (vty, " (old and new)");
-                 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
-                   vty_out (vty, " (old)");
-                 else 
-                   vty_out (vty, " (new)");
-               }
-             vty_out (vty, "%s", VTY_NEWLINE);
-           }
+               vty_out (vty, " %sreceived(%s)",
+                        CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
+                        (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
+                         && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
+                        "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
 
-         /* IPv4 */
-         if (p->afc_adv[AFI_IP][SAFI_UNICAST]
-             || p->afc_recv[AFI_IP][SAFI_UNICAST]) 
-           {
-             vty_out (vty, "    Address family IPv4 Unicast:");
-             if (p->afc_adv[AFI_IP][SAFI_UNICAST]) 
-               vty_out (vty, " advertised");
-             if (p->afc_recv[AFI_IP][SAFI_UNICAST])
-               {
-                 if (p->afc_adv[AFI_IP][SAFI_UNICAST])
-                   vty_out (vty, " and");
-                 vty_out (vty, " received");
-               }
              vty_out (vty, "%s", VTY_NEWLINE);
            }
-         if (p->afc_adv[AFI_IP][SAFI_MULTICAST] || p->afc_recv[AFI_IP][SAFI_MULTICAST]) 
-           {
-             vty_out (vty, "    Address family IPv4 Multicast:");
-             if (p->afc_adv[AFI_IP][SAFI_MULTICAST]) 
-               vty_out (vty, " advertised");
-             if (p->afc_recv[AFI_IP][SAFI_MULTICAST])
+
+         /* Multiprotocol Extensions */
+         for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
+           for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
+             if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
                {
-                 if (p->afc_adv[AFI_IP][SAFI_MULTICAST])
-                   vty_out (vty, " and");
-                 vty_out (vty, " received");
-               }
-             vty_out (vty, "%s", VTY_NEWLINE);
-           }
-         if (p->afc_adv[AFI_IP][SAFI_MPLS_VPN] || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) 
+                 vty_out (vty, "    Address family %s:", afi_safi_print (afi, safi));
+                 if (p->afc_adv[afi][safi]) 
+                   vty_out (vty, " advertised");
+                 if (p->afc_recv[afi][safi])
+                   vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
+                 vty_out (vty, "%s", VTY_NEWLINE);
+               } 
+
+         /* Gracefull Restart */
+         if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
+             || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
            {
-             vty_out (vty, "    Address family VPNv4 Unicast:");
-             if (p->afc_adv[AFI_IP][SAFI_MPLS_VPN]) 
+             vty_out (vty, "    Graceful Restart Capabilty:");
+             if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
                vty_out (vty, " advertised");
-             if (p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
-               {
-                 if (p->afc_adv[AFI_IP][SAFI_MPLS_VPN])
-                   vty_out (vty, " and");
-                 vty_out (vty, " received");
-               }
+             if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
+               vty_out (vty, " %sreceived",
+                        CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
              vty_out (vty, "%s", VTY_NEWLINE);
-           }
-         /* IPv6 */
-#ifdef HAVE_IPV6
-         if (p->afc_adv[AFI_IP6][SAFI_UNICAST] || p->afc_recv[AFI_IP6][SAFI_UNICAST]) 
-           {
-             vty_out (vty, "    Address family IPv6 Unicast:");
-             if (p->afc_adv[AFI_IP6][SAFI_UNICAST]) 
-               vty_out (vty, " advertised");
-             if (p->afc_recv[AFI_IP6][SAFI_UNICAST])
-               {
-                 if (p->afc_adv[AFI_IP6][SAFI_UNICAST])
-                   vty_out (vty, " and");
-                 vty_out (vty, " received");
-               }
-             vty_out (vty, "%s", VTY_NEWLINE);
-           }
-         if (p->afc_adv[AFI_IP6][SAFI_MULTICAST] || p->afc_recv[AFI_IP6][SAFI_MULTICAST]) 
-           {
-             vty_out (vty, "    Address family IPv6 Multicast:");
-             if (p->afc_adv[AFI_IP6][SAFI_MULTICAST]) 
-               vty_out (vty, " advertised");
-             if (p->afc_recv[AFI_IP6][SAFI_MULTICAST])
+
+             if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
                {
-                 if (p->afc_adv[AFI_IP6][SAFI_MULTICAST])
-                   vty_out (vty, " and");
-                 vty_out (vty, " received");
+                 int restart_af_count = 0;
+
+                 vty_out (vty, "      Remote Restart timer is %d seconds%s",
+                          p->restart_time_rcv, VTY_NEWLINE);   
+                 vty_out (vty, "      Address families preserved by peer:%s        ", VTY_NEWLINE);
+
+                 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
+                   for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
+                     if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
+                       {
+                         vty_out (vty, "%s%s", restart_af_count ? ", " : "",
+                                  afi_safi_print (afi, safi));
+                         restart_af_count++;
+                     }
+                 if (! restart_af_count)
+                   vty_out (vty, "none");
+                 vty_out (vty, "%s", VTY_NEWLINE);
                }
-             vty_out (vty, "%s", VTY_NEWLINE);
            }
-#endif /* HAVE_IPV6 */
        }
     }
 
@@ -6717,18 +6725,10 @@ bgp_show_peer (struct vty *vty, struct peer *p)
   vty_out (vty, "%s", VTY_NEWLINE);
 
   /* Address Family Information */
-  if (p->afc[AFI_IP][SAFI_UNICAST])
-    bgp_show_peer_afi (vty, p, AFI_IP, SAFI_UNICAST);
-  if (p->afc[AFI_IP][SAFI_MULTICAST])
-    bgp_show_peer_afi (vty, p, AFI_IP, SAFI_MULTICAST);
-  if (p->afc[AFI_IP][SAFI_MPLS_VPN])
-    bgp_show_peer_afi (vty, p, AFI_IP, SAFI_MPLS_VPN);
-#ifdef HAVE_IPV6
-  if (p->afc[AFI_IP6][SAFI_UNICAST])
-    bgp_show_peer_afi (vty, p, AFI_IP6, SAFI_UNICAST);
-  if (p->afc[AFI_IP6][SAFI_MULTICAST])
-    bgp_show_peer_afi (vty, p, AFI_IP6, SAFI_MULTICAST);
-#endif /* HAVE_IPV6 */
+  for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
+    for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
+      if (p->afc[afi][safi])
+       bgp_show_peer_afi (vty, p, afi, safi);
 
   vty_out (vty, "  Connections established %d; dropped %d%s",
           p->established, p->dropped,
@@ -7849,6 +7849,12 @@ bgp_vty_init ()
   /* "bgp deterministic-med" commands */
   install_element (BGP_NODE, &bgp_deterministic_med_cmd);
   install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
+
+#if 0
+  /* "bgp graceful-restart" commands */
+  install_element (BGP_NODE, &bgp_graceful_restart_cmd);
+  install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
+#endif /* 0 */
  
   /* "bgp fast-external-failover" commands */
   install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
index 15ad58105a732f1a35b031117e2c9f925a1323e1..74bc18508900f141aa4fb4185c268afe9c9ffbe1 100644 (file)
@@ -19,3 +19,4 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
 void bgp_vty_init ();
+char *afi_safi_print (afi_t, safi_t);
index 510e2960d1c8de4be3b8164ac85d2b7a4205bbb5..47df3c83e110b8098a8fdb7710909c4ebf3c68b4 100644 (file)
@@ -515,7 +515,6 @@ bgp_default_local_preference_set (struct bgp *bgp, u_int32_t local_pref)
   if (! bgp)
     return -1;
 
-  bgp_config_set (bgp, BGP_CONFIG_DEFAULT_LOCAL_PREF);
   bgp->default_local_pref = local_pref;
 
   return 0;
@@ -527,7 +526,6 @@ bgp_default_local_preference_unset (struct bgp *bgp)
   if (! bgp)
     return -1;
 
-  bgp_config_unset (bgp, BGP_CONFIG_DEFAULT_LOCAL_PREF);
   bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF;
 
   return 0;
@@ -1685,6 +1683,8 @@ bgp_create (as_t *as, char *name)
   bgp->default_local_pref = BGP_DEFAULT_LOCAL_PREF;
   bgp->default_holdtime = BGP_DEFAULT_HOLDTIME;
   bgp->default_keepalive = BGP_DEFAULT_KEEPALIVE;
+  bgp->restart_time = BGP_DEFAULT_RESTART_TIME;
+  bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
 
   bgp->as = *as;
 
@@ -4612,7 +4612,11 @@ bgp_config_write (struct vty *vty)
       /* BGP deterministic-med. */
       if (bgp_flag_check (bgp, BGP_FLAG_DETERMINISTIC_MED))
        vty_out (vty, " bgp deterministic-med%s", VTY_NEWLINE);
-      
+
+      /* BGP graceful-restart. */
+      if (bgp_flag_check (bgp, BGP_FLAG_GRACEFUL_RESTART))
+       vty_out (vty, " bgp graceful-restart%s", VTY_NEWLINE);
+
       /* BGP bestpath method. */
       if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE))
        vty_out (vty, " bgp bestpath as-path ignore%s", VTY_NEWLINE);
index b40a68c80b8822b19c50b9a5de24fda084a1f50f..818f7dc836b2efd00d0ed3bfd07f480b0d624033 100644 (file)
@@ -70,7 +70,6 @@ struct bgp
 #define BGP_CONFIG_ROUTER_ID              (1 << 0)
 #define BGP_CONFIG_CLUSTER_ID             (1 << 1)
 #define BGP_CONFIG_CONFEDERATION          (1 << 2)
-#define BGP_CONFIG_DEFAULT_LOCAL_PREF     (1 << 3)
 
   /* BGP router identifier.  */
   struct in_addr router_id;
@@ -97,6 +96,7 @@ struct bgp
 #define BGP_FLAG_IMPORT_CHECK             (1 << 9)
 #define BGP_FLAG_NO_FAST_EXT_FAILOVER     (1 << 10)
 #define BGP_FLAG_LOG_NEIGHBOR_CHANGES     (1 << 11)
+#define BGP_FLAG_GRACEFUL_RESTART         (1 << 12)
 
   /* BGP Per AF flags */
   u_int16_t af_flags[AFI_MAX][SAFI_MAX];
@@ -136,6 +136,10 @@ struct bgp
   /* BGP default timer.  */
   u_int32_t default_holdtime;
   u_int32_t default_keepalive;
+
+  /* BGP graceful restart */
+  u_int16_t restart_time;
+  u_int16_t stalepath_time;
 };
 
 /* BGP peer-group support. */
@@ -291,6 +295,8 @@ struct peer
 #define PEER_CAP_REFRESH_NEW_RCV            (1 << 2) /* refresh rfc received */
 #define PEER_CAP_DYNAMIC_ADV                (1 << 3) /* dynamic advertised */
 #define PEER_CAP_DYNAMIC_RCV                (1 << 4) /* dynamic received */
+#define PEER_CAP_RESTART_ADV                (1 << 5) /* restart advertised */
+#define PEER_CAP_RESTART_RCV                (1 << 6) /* restart received */
 
   /* Capability Flags.*/
   u_int16_t af_cap[AFI_MAX][SAFI_MAX];
@@ -300,6 +306,10 @@ struct peer
 #define PEER_CAP_ORF_PREFIX_RM_RCV          (1 << 3) /* receive-mode received */
 #define PEER_CAP_ORF_PREFIX_SM_OLD_RCV      (1 << 4) /* send-mode received */
 #define PEER_CAP_ORF_PREFIX_RM_OLD_RCV      (1 << 5) /* receive-mode received */
+#define PEER_CAP_RESTART_AF_RCV             (1 << 6) /* graceful restart received */
+
+  /* Gracefull Restart */
+  u_int16_t restart_time_rcv;
 
   /* Global configuration flags. */
   u_int32_t flags;
@@ -641,6 +651,10 @@ struct bgp_nlri
 /* BGP default local preference.  */
 #define BGP_DEFAULT_LOCAL_PREF                 100
 
+/* BGP graceful restart  */
+#define BGP_DEFAULT_RESTART_TIME               120
+#define BGP_DEFAULT_STALEPATH_TIME             360
+
 /* SAFI which used in open capability negotiation.  */
 #define BGP_SAFI_VPNV4                         128
 #define BGP_SAFI_VPNV6                         129