]> git.puffer.fish Git - matthieu/frr.git/commitdiff
2003-08-13 kunihiro <kunihiro@zebra.org>
authorpaul <paul>
Wed, 13 Aug 2003 00:32:49 +0000 (00:32 +0000)
committerpaul <paul>
Wed, 13 Aug 2003 00:32:49 +0000 (00:32 +0000)
* bgpd/bgp{_fsm.c,_vty.c,d.c,d.h}: Add support for "bgp
          log-neighbor-changes" command.

bgpd/bgp_fsm.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index 64a4c1bd0ba57bc1091bb784018d17f410c39b62..3d8e957675d92c835bf51513b7abb8ead47364ff 100644 (file)
@@ -322,6 +322,14 @@ bgp_stop (struct peer *peer)
       established = 1;
       peer->dropped++;
       bgp_fsm_change_status (peer, Idle);
+
+      /* bgp log-neighbor-changes of neighbor Down */
+      if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
+       zlog_info ("%%ADJCHANGE: neighbor %s Down", peer->host);
+
+      /* set last reset time */
+      peer->resettime = time (NULL);
+
 #ifdef HAVE_SNMP
       bgpTrapBackwardTransition (peer);
 #endif /* HAVE_SNMP */
@@ -629,6 +637,11 @@ bgp_establish (struct peer *peer)
   /* Increment established count. */
   peer->established++;
   bgp_fsm_change_status (peer, Established);
+
+  /* bgp log-neighbor-changes of neighbor Up */
+  if (bgp_flag_check (peer->bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
+    zlog_info ("%%ADJCHANGE: neighbor %s Up", peer->host);
+
 #ifdef HAVE_SNMP
   bgpTrapEstablished (peer);
 #endif /* HAVE_SNMP */
index 6514ac2218e3d0f4b862596aa49ed103abb28935..39a43c0457c05cb8de322405f6bc1d106e3ae1b8 100644 (file)
@@ -878,6 +878,34 @@ DEFUN (no_bgp_bestpath_aspath_ignore,
   return CMD_SUCCESS;
 }
 \f
+/* "bgp log-neighbor-changes" configuration.  */
+DEFUN (bgp_log_neighbor_changes,
+       bgp_log_neighbor_changes_cmd,
+       "bgp log-neighbor-changes",
+       "BGP specific commands\n"
+       "Log neighbor up/down and reset reason\n")
+{
+  struct bgp *bgp;
+
+  bgp = vty->index;
+  bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+  return CMD_SUCCESS;
+}
+
+DEFUN (no_bgp_log_neighbor_changes,
+       no_bgp_log_neighbor_changes_cmd,
+       "no bgp log-neighbor-changes",
+       NO_STR
+       "BGP specific commands\n"
+       "Log neighbor up/down and reset reason\n")
+{
+  struct bgp *bgp;
+
+  bgp = vty->index;
+  bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
+  return CMD_SUCCESS;
+}
+\f
 /* "bgp bestpath med" configuration. */
 DEFUN (bgp_bestpath_med,
        bgp_bestpath_med_cmd,
@@ -6660,6 +6688,9 @@ bgp_show_peer (struct vty *vty, struct peer *p)
           p->established, p->dropped,
           VTY_NEWLINE);
 
+  vty_out (vty, "  Last reset %s%s", p->dropped ? peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN) : "never",
+          VTY_NEWLINE);
+
   if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
     {
       vty_out (vty, "  Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
@@ -7743,6 +7774,10 @@ bgp_vty_init ()
   install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
   install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
 
+  /* "bgp log-neighbor-changes" commands */
+  install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
+  install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
+
   /* "bgp bestpath med" commands */
   install_element (BGP_NODE, &bgp_bestpath_med_cmd);
   install_element (BGP_NODE, &bgp_bestpath_med2_cmd);
index f116a0cf776d1e185c4a2b34b5ca4c1170a78fd2..3a12a27c62dd305a04abada6d97a7a272f95707b 100644 (file)
@@ -752,6 +752,9 @@ peer_create (union sockunion *su, struct bgp *bgp, as_t local_as,
   /* Last read time set */
   peer->readtime = time (NULL);
 
+  /* Last reset time set */
+  peer->resettime = time (NULL);
+
   /* Default TTL set. */
   peer->ttl = (peer_sort (peer) == BGP_PEER_IBGP ? 255 : 1);
 
@@ -797,6 +800,13 @@ peer_as_change (struct peer *peer, as_t as)
   type = peer_sort (peer);
   peer->as = as;
 
+  if (bgp_config_check (peer->bgp, BGP_CONFIG_CONFEDERATION)
+      && ! bgp_confederation_peers_check (peer->bgp, as)
+      && peer->bgp->as != as)
+    peer->local_as = peer->bgp->confed_id;
+  else
+    peer->local_as = peer->bgp->as;
+
   /* Advertisement-interval reset */
   if (peer_sort (peer) == BGP_PEER_IBGP)
     peer->v_routeadv = BGP_DEFAULT_IBGP_ROUTEADV;
@@ -1634,6 +1644,15 @@ bgp_create (as_t *as, char *name)
   return bgp;
 }
 
+/* Return master of BGP. */
+struct bgp_master *
+bgp_get_master ()
+{
+  if (bm)
+    return bm;
+  return NULL;
+}
+
 /* Return first entry of BGP. */
 struct bgp *
 bgp_get_default ()
@@ -4415,6 +4434,10 @@ bgp_config_write (struct vty *vty)
        vty_out (vty, " bgp router-id %s%s", inet_ntoa (bgp->router_id), 
                 VTY_NEWLINE);
 
+      /* BGP log-neighbor-changes. */
+      if (bgp_flag_check (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES))
+       vty_out (vty, " bgp log-neighbor-changes%s", VTY_NEWLINE);
+
       /* BGP configuration. */
       if (bgp_flag_check (bgp, BGP_FLAG_ALWAYS_COMPARE_MED))
        vty_out (vty, " bgp always-compare-med%s", VTY_NEWLINE);
index 11c6bdec430fa7af795cf03b613c6d4a08dcb414..498bd07235a935a30a43ccf2731141ab06236b06 100644 (file)
@@ -96,6 +96,7 @@ struct bgp
 #define BGP_FLAG_ASPATH_IGNORE            (1 << 8)
 #define BGP_FLAG_IMPORT_CHECK             (1 << 9)
 #define BGP_FLAG_NO_FAST_EXT_FAILOVER     (1 << 10)
+#define BGP_FLAG_LOG_NEIGHBOR_CHANGES     (1 << 11)
 
   /* BGP Per AF flags */
   u_int16_t af_flags[AFI_MAX][SAFI_MAX];
@@ -263,6 +264,7 @@ struct peer
   union sockunion su;          /* Sockunion address of the peer. */
   time_t uptime;               /* Last Up/Down time */
   time_t readtime;             /* Last read time */
+  time_t resettime;            /* Last reset time */
   
   unsigned int ifindex;                /* ifindex of the BGP connection. */
   char *ifname;                        /* bind interface name. */