summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorhasso <hasso>2004-05-21 09:31:30 +0000
committerhasso <hasso>2004-05-21 09:31:30 +0000
commit538621f2f80ced838048fa7402e57face3b224a5 (patch)
tree1193f5948da15db665aa6d4a43027c466c0614b4 /bgpd
parent3950fda506e4db58a0ccc50156cf70f97da95bc3 (diff)
Merge graceful restart capability display and some small fixes from Zebra
repository by Rivo Nurges.
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog5
-rw-r--r--bgpd/bgp_fsm.c45
-rw-r--r--bgpd/bgp_open.c89
-rw-r--r--bgpd/bgp_open.h40
-rw-r--r--bgpd/bgp_vty.c216
-rw-r--r--bgpd/bgp_vty.h1
-rw-r--r--bgpd/bgpd.c10
-rw-r--r--bgpd/bgpd.h16
8 files changed, 267 insertions, 155 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 49b9a4c0..9ed186bd 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -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.
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index d28cd934..2874a9a0 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -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);
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index a3e86b06..ae4a7d40 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -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"
-
+#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);
diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h
index af7505a8..014bc330 100644
--- a/bgpd/bgp_open.h
+++ b/bgpd/bgp_open.h
@@ -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 *);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index dda40293..c7de8eb6 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -760,7 +760,35 @@ DEFUN (no_bgp_deterministic_med,
bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
return CMD_SUCCESS;
}
-
+
+/* "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 */
+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);
diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h
index 15ad5810..74bc1850 100644
--- a/bgpd/bgp_vty.h
+++ b/bgpd/bgp_vty.h
@@ -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);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 510e2960..47df3c83 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -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);
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index b40a68c8..818f7dc8 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -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