summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_msg_read.c
diff options
context:
space:
mode:
authorChris Hall <GMCH@hestia.halldom.com>2010-01-27 22:37:55 +0000
committerChris Hall <GMCH@hestia.halldom.com>2010-01-27 22:37:55 +0000
commite29ed2adec0ef11ca1c84b40b2c98247f162f3df (patch)
treed0a65837f2a544c8e46f8ddda654e70686c531a1 /bgpd/bgp_msg_read.c
parente6d986058f23f350aa6aedac4da5fe9f3afda6e8 (diff)
downloadquagga-e29ed2adec0ef11ca1c84b40b2c98247f162f3df.tar.bz2
quagga-e29ed2adec0ef11ca1c84b40b2c98247f162f3df.tar.xz
Binding to interfaces and counting of messages.
Wired up message counters in bgp_session structure. Added fields to session for neighbor interface and neighbor update-source -- so that these can be set when connect() is done. Peering Engine resolves any interface name to an address, so that BGP Engine doesn't have to. Reinstated as much code as necessary in bgp_network to bind to specific interfaces, as set in the session. Moved setting of bgp_nexthop_set() back into Routeing Engine. Result is that only Peering Engine talks to Zebra or uses the iflist. Wired up setting of TTL. Reworked connections locking of the session mutex so more robust if/when connections are cut loose from the session. Made peer_index entry point at connection, not session. Works better in bgp_network that way. modified: bgpd/bgp_connection.c modified: bgpd/bgp_connection.h modified: bgpd/bgp_fsm.c modified: bgpd/bgp_msg_read.c modified: bgpd/bgp_msg_write.c modified: bgpd/bgp_network.c modified: bgpd/bgp_network.h modified: bgpd/bgp_peer.c modified: bgpd/bgp_peer.h modified: bgpd/bgp_peer_index.c modified: bgpd/bgp_peer_index.h modified: bgpd/bgp_session.c modified: bgpd/bgp_session.h modified: lib/prefix.h modified: lib/sockunion.c modified: lib/sockunion.h
Diffstat (limited to 'bgpd/bgp_msg_read.c')
-rw-r--r--bgpd/bgp_msg_read.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/bgpd/bgp_msg_read.c b/bgpd/bgp_msg_read.c
index 7b56e9de..7b7b1130 100644
--- a/bgpd/bgp_msg_read.c
+++ b/bgpd/bgp_msg_read.c
@@ -20,6 +20,7 @@
*/
#include <zebra.h>
+#include <time.h>
#include "bgpd/bgp_common.h"
#include "bgpd/bgp_msg_read.h"
@@ -304,6 +305,7 @@ bgp_msg_open_invalid(bgp_notify notification) ;
/*------------------------------------------------------------------------------
* Receive BGP open packet and parse it into the connection's open_recv
*
+ * NB: requires the session to be locked (connection-wise) and not NULL.
*/
static void
bgp_msg_open_receive (bgp_connection connection, bgp_size_t body_size)
@@ -317,6 +319,8 @@ bgp_msg_open_receive (bgp_connection connection, bgp_size_t body_size)
struct sucker ssr ;
unsigned holdtime ;
+ ++connection->session->stats.open_in ;
+
/* Start with an unspecific OPEN notification */
bgp_notify notification = bgp_notify_new(BGP_NOMC_OPEN,
BGP_NOMS_UNSPECIFIC, 0) ;
@@ -1343,6 +1347,8 @@ bgp_msg_capability_as4 (bgp_connection connection, sucker sr)
/*==============================================================================
* BGP UPDATE message
+ *
+ * NB: requires the session to be locked (connection-wise) and not NULL.
*/
static void
bgp_msg_update_receive (bgp_connection connection, bgp_size_t body_size)
@@ -1354,7 +1360,10 @@ bgp_msg_update_receive (bgp_connection connection, bgp_size_t body_size)
"%s [Error] Update message received while in %s State",
connection->host, LOOKUP(bgp_status_msg, connection->state)) ;
return ;
- }
+ } ;
+
+ ++connection->session->stats.update_in ;
+ connection->session->stats.update_time = time(NULL) ;
/* PRO TEM: pass raw update message across to Peering Engine */
/* TODO: decode update messages in the BGP Engine. */
@@ -1363,10 +1372,14 @@ bgp_msg_update_receive (bgp_connection connection, bgp_size_t body_size)
/*==============================================================================
* BGP KEEPALIVE message
+ *
+ * NB: requires the session to be locked (connection-wise) and not NULL.
*/
static void
bgp_msg_keepalive_receive (bgp_connection connection, bgp_size_t body_size)
{
+ ++connection->session->stats.keepalive_in ;
+
if (BGP_DEBUG (keepalive, KEEPALIVE))
zlog_debug ("%s KEEPALIVE rcvd", connection->host);
@@ -1378,6 +1391,8 @@ bgp_msg_keepalive_receive (bgp_connection connection, bgp_size_t body_size)
/*==============================================================================
* BGP NOTIFICATION message
+ *
+ * NB: requires the session to be locked (connection-wise) and not NULL.
*/
static void
bgp_msg_notify_receive (bgp_connection connection, bgp_size_t body_size)
@@ -1385,6 +1400,8 @@ bgp_msg_notify_receive (bgp_connection connection, bgp_size_t body_size)
bgp_nom_code_t code = stream_getc (connection->ibuf);
bgp_nom_subcode_t subcode = stream_getc (connection->ibuf);
+ ++connection->session->stats.notify_in ;
+
bgp_fsm_notification_exception(connection,
bgp_notify_new_with_data(code, subcode,
stream_pnt(connection->ibuf), body_size - 2)) ;
@@ -1392,6 +1409,8 @@ bgp_msg_notify_receive (bgp_connection connection, bgp_size_t body_size)
/*==============================================================================
* BGP ROUTE-REFRESH message
+ *
+ * NB: requires the session to be locked (connection-wise) and not NULL.
*/
static int
bgp_msg_orf_recv(bgp_connection connection, bgp_route_refresh rr,
@@ -1414,6 +1433,8 @@ bgp_msg_route_refresh_receive(bgp_connection connection, bgp_size_t body_size)
unsigned form ;
int ret ;
+ ++connection->session->stats.refresh_in ;
+
/* If peer does not have the capability, treat as bad message type */
switch (connection->msg_type)
@@ -1684,7 +1705,7 @@ bgp_msg_orf_prefix_recv(orf_prefix orfpe, qafx_bit_t qb, sucker sr)
memset(&orfpe->p, 0, sizeof(struct prefix)) ;
- blen = blen = (plen + 7) / 8 ;
+ blen = (plen + 7) / 8 ;
if ((left -= blen) >= 0)
{
orfpe->p.family = paf ;
@@ -1704,9 +1725,13 @@ bgp_msg_orf_prefix_recv(orf_prefix orfpe, qafx_bit_t qb, sucker sr)
/*==============================================================================
* BGP CAPABILITY message -- Dynamic Capabilities
+ *
+ * NB: requires the session to be locked (connection-wise) and not NULL.
*/
static void bgp_msg_capability_receive(bgp_connection connection,
bgp_size_t body_size)
{
+ ++connection->session->stats.dynamic_cap_in ;
+
return ;
} ;