diff options
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp.h | 14 | ||||
-rw-r--r-- | bgpd/bgp_advertise.h | 4 | ||||
-rw-r--r-- | bgpd/bgp_aspath.h | 7 | ||||
-rw-r--r-- | bgpd/bgp_btoa.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_clist.c | 8 | ||||
-rw-r--r-- | bgpd/bgp_common.c | 1 | ||||
-rw-r--r-- | bgpd/bgp_common.h | 7 | ||||
-rw-r--r-- | bgpd/bgp_connection.c | 9 | ||||
-rw-r--r-- | bgpd/bgp_connection.h | 6 | ||||
-rw-r--r-- | bgpd/bgp_debug.c | 38 | ||||
-rw-r--r-- | bgpd/bgp_dump.c | 24 | ||||
-rw-r--r-- | bgpd/bgp_engine.h | 52 | ||||
-rw-r--r-- | bgpd/bgp_main.c | 92 | ||||
-rw-r--r-- | bgpd/bgp_msg_write.h | 3 | ||||
-rw-r--r-- | bgpd/bgp_notification.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_notification.h | 6 | ||||
-rw-r--r-- | bgpd/bgp_open_state.c | 18 | ||||
-rw-r--r-- | bgpd/bgp_open_state.h | 10 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_peer.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_peer_index.c | 23 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_route_refresh.c | 7 | ||||
-rw-r--r-- | bgpd/bgp_route_refresh.h | 12 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 25 | ||||
-rw-r--r-- | bgpd/bgp_session.c | 9 | ||||
-rw-r--r-- | bgpd/bgp_session.h | 10 | ||||
-rw-r--r-- | bgpd/bgp_snmp.c | 38 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 272 | ||||
-rw-r--r-- | bgpd/bgpd.c | 3 | ||||
-rw-r--r-- | bgpd/bgpd.h | 8 |
31 files changed, 391 insertions, 345 deletions
@@ -30,7 +30,7 @@ #define _GMCH_BGP_H "19-Dec-2009" -#include <stdint.h> +#include "misc.h" #include "confirm.h" /*############################################################################## @@ -815,7 +815,8 @@ typedef U8 BGP_ATT_ORIGIN_T ; /* one byte of data ! */ VALUE(BGP_ATT_ORIGIN_L = sizeof(BGP_ATT_ORIGIN_T)) ; -enum BGP_ATT_ORG { +enum BGP_ATT_ORG +{ BGP_ATT_ORG_MIN = 0, BGP_ATT_ORG_IGP = 0, /* NLRI is interior to originating AS */ @@ -851,7 +852,8 @@ typedef U32 BGP_ATT_ASPS_AS4_T ; /* AS Path Segment Types......................................................*/ -enum BGP_AS_SEG { +enum BGP_AS_SEG +{ BGP_AS_SET = 1, BGP_AS_SEQUENCE = 2, BGP_AS_CONFED_SEQUENCE = 3, /* RFC5065 */ @@ -862,7 +864,8 @@ enum BGP_AS_SEG { #define AS4(h, l) (((h) << 16) + (l)) -enum BGP_ASN { +enum BGP_ASN +{ BGP_ASN_NULL = 0, /* Reserved */ BGP_ASN_RES1_S = 64496, /* Start of Reservation 1 (0xFBF0) */ @@ -962,7 +965,8 @@ enum BGP_ATT_COM_MS_RES2 = 0xFFFF /* 0xFFFF_0000..0xFFFF_FFFF are reserved */ } ; -enum BGP_COMM { +enum BGP_COMM +{ BGP_ATT_COM_RES1_S = 0x00000000, BGP_ATT_COM_INTERNET = 0x00000000, diff --git a/bgpd/bgp_advertise.h b/bgpd/bgp_advertise.h index ca92238a..afa812f6 100644 --- a/bgpd/bgp_advertise.h +++ b/bgpd/bgp_advertise.h @@ -21,9 +21,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGP_ADVERTISE_H #define _QUAGGA_BGP_ADVERTISE_H -#ifndef Inline -#define Inline static inline -#endif +#include "lib/misc.h" /* BGP advertise FIFO. */ typedef struct bgp_advertise* bgp_advertise ; diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h index 74eb775c..49a3a5be 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -21,12 +21,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGP_ASPATH_H #define _QUAGGA_BGP_ASPATH_H -#include <stdbool.h> - -/* Macro in case there are particular compiler issues. */ -#ifndef Inline - #define Inline static inline -#endif +#include "lib/misc.h" /* AS path segment type. */ #define AS_SET 1 diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c index 7c708814..42cd0da2 100644 --- a/bgpd/bgp_btoa.c +++ b/bgpd/bgp_btoa.c @@ -18,8 +18,6 @@ along with GNU Zebra; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <zebra.h> - #include "zebra.h" #include "stream.h" #include "log.h" @@ -91,11 +89,11 @@ attr_parse (struct stream *s, u_int16_t len) aspath.str = aspath_make_str_count (&aspath); printf ("ASPATH: %s\n", aspath.str); free (aspath.str); - + stream_forward (s, length); } break; - case BGP_ATTR_NEXT_HOP: + case BGP_ATTR_NEXT_HOP: { struct in_addr nexthop; nexthop.s_addr = stream_get_ipv4 (s); @@ -144,7 +142,7 @@ main (int argc, char **argv) perror ("fopen"); exit (1); } - + while (1) { stream_reset (s); @@ -279,7 +277,7 @@ main (int argc, char **argv) sip.s_addr = stream_get_ipv4 (s); dip.s_addr = stream_get_ipv4 (s); - + printf ("saddr: %s\n", inet_ntoa (sip)); printf ("daddr: %s\n", inet_ntoa (dip)); diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index 9c57cb65..ecf1a526 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -127,7 +127,7 @@ community_list_lookup (struct community_list_handler *ch, if (!table) return NULL; - return symbol_get_value(symbol_seek(table, name)) ; + return symbol_get_value(symbol_lookup(table, name, no_add)) ; } static struct community_list * @@ -145,7 +145,7 @@ community_list_get (struct community_list_handler *ch, if (!table) return NULL; - sym = symbol_find(table, name) ; + sym = symbol_lookup(table, name, add) ; list = symbol_get_value(sym) ; if (!list) { @@ -768,10 +768,10 @@ community_list_terminate (struct community_list_handler *ch) { struct community_list *list ; - while ((list = symbol_table_ream_keep(&ch->community_list))) + while ((list = symbol_table_ream(&ch->community_list, keep_it))) community_list_delete(list) ; - while ((list = symbol_table_ream_keep(&ch->extcommunity_list))) + while ((list = symbol_table_ream(&ch->extcommunity_list, keep_it))) community_list_delete(list) ; XFREE (MTYPE_COMMUNITY_LIST_HANDLER, ch); diff --git a/bgpd/bgp_common.c b/bgpd/bgp_common.c index cfee5ca2..8a3a57ff 100644 --- a/bgpd/bgp_common.c +++ b/bgpd/bgp_common.c @@ -18,6 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include "misc.h" #include "bgpd/bgp_common.h" #include "lib/zassert.h" diff --git a/bgpd/bgp_common.h b/bgpd/bgp_common.h index a1f4df42..e115bfd5 100644 --- a/bgpd/bgp_common.h +++ b/bgpd/bgp_common.h @@ -22,18 +22,13 @@ #ifndef _QUAGGA_BGP_COMMON_H #define _QUAGGA_BGP_COMMON_H -#include <stdint.h> -#include <stdbool.h> +#include "misc.h" #include <sys/socket.h> #include "bgpd/bgp.h" #include "qafi_safi.h" #include "lib/zassert.h" -#ifndef Inline -#define Inline static inline -#endif - /*============================================================================== * Here are a number of "incomplete" declarations, which allow a number of * bgpd structures to refer to each other. diff --git a/bgpd/bgp_connection.c b/bgpd/bgp_connection.c index d7997dba..24c86230 100644 --- a/bgpd/bgp_connection.c +++ b/bgpd/bgp_connection.c @@ -20,8 +20,9 @@ */ #include <zebra.h> -#include "bgpd/bgp_connection.h" +#include "misc.h" +#include "bgpd/bgp_connection.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_engine.h" @@ -154,7 +155,7 @@ bgp_connection_init_new(bgp_connection connection, bgp_session session, /* Link back to session, point at its mutex and point session here */ connection->session = session ; - connection->p_mutex = &session->mutex ; + connection->p_mutex = session->mutex ; connection->lock_count = 0 ; /* no question about it */ connection->ordinal = ordinal ; @@ -347,7 +348,7 @@ bgp_connection_free(bgp_connection connection) /* Free any components which still exist */ connection->qf = qps_file_free(connection->qf) ; connection->hold_timer = qtimer_free(connection->hold_timer) ; - connection->keepalive_timer = qtimer_free(connection->hold_timer) ; + connection->keepalive_timer = qtimer_free(connection->keepalive_timer) ; bgp_notify_unset(&connection->notification) ; bgp_open_state_unset(&connection->open_recv) ; @@ -678,7 +679,7 @@ bgp_connection_stop(bgp_connection connection, bool stop_writer) connection->notification_pending = 0 ; /* Empty out the pending queue and remove from connection queue */ - mqueue_local_reset_keep(&connection->pending_queue) ; + mqueue_local_reset(&connection->pending_queue, keep_it) ; bgp_connection_queue_del(connection) ; /* If required: set write buffer *unwritable* (and empty). */ diff --git a/bgpd/bgp_connection.h b/bgpd/bgp_connection.h index ead222f9..4df1fbca 100644 --- a/bgpd/bgp_connection.h +++ b/bgpd/bgp_connection.h @@ -22,7 +22,7 @@ #ifndef _QUAGGA_BGP_CONNECTION_H #define _QUAGGA_BGP_CONNECTION_H -#include <stdbool.h> +#include "lib/misc.h" #include "lib/mqueue.h" #include "lib/qpthreads.h" @@ -40,10 +40,6 @@ #include "bgpd/bgp_notification.h" #include "bgpd/bgp_msg_read.h" -#ifndef Inline -#define Inline static inline -#endif - /*============================================================================== * The BGP Finite State Machine: states and events * diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index eda146dd..83e6400a 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -367,7 +367,7 @@ DEFUN (debug_bgp_as4, BGP_STR "BGP AS4 actions\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (as4, AS4); else { @@ -385,7 +385,7 @@ DEFUN (no_debug_bgp_as4, BGP_STR "BGP AS4 actions\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (as4, AS4); else { @@ -410,7 +410,7 @@ DEFUN (debug_bgp_as4_segment, "BGP AS4 actions\n" "BGP AS4 aspath segment handling\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (as4, AS4_SEGMENT); else { @@ -429,7 +429,7 @@ DEFUN (no_debug_bgp_as4_segment, "BGP AS4 actions\n" "BGP AS4 aspath segment handling\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (as4, AS4_SEGMENT); else { @@ -454,7 +454,7 @@ DEFUN (debug_bgp_fsm, BGP_STR "BGP Finite State Machine\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (fsm, FSM); else { @@ -472,7 +472,7 @@ DEFUN (no_debug_bgp_fsm, BGP_STR "Finite State Machine\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (fsm, FSM); else { @@ -496,7 +496,7 @@ DEFUN (debug_bgp_events, BGP_STR "BGP events\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (events, EVENTS); else { @@ -514,7 +514,7 @@ DEFUN (no_debug_bgp_events, BGP_STR "BGP events\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (events, EVENTS); else { @@ -538,7 +538,7 @@ DEFUN (debug_bgp_filter, BGP_STR "BGP filters\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (filter, FILTER); else { @@ -556,7 +556,7 @@ DEFUN (no_debug_bgp_filter, BGP_STR "BGP filters\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (filter, FILTER); else { @@ -580,7 +580,7 @@ DEFUN (debug_bgp_keepalive, BGP_STR "BGP keepalives\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (keepalive, KEEPALIVE); else { @@ -598,7 +598,7 @@ DEFUN (no_debug_bgp_keepalive, BGP_STR "BGP keepalives\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (keepalive, KEEPALIVE); else { @@ -622,7 +622,7 @@ DEFUN (debug_bgp_update, BGP_STR "BGP updates\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) { DEBUG_ON (update, UPDATE_IN); DEBUG_ON (update, UPDATE_OUT); @@ -645,7 +645,7 @@ DEFUN (debug_bgp_update_direct, "Inbound updates\n" "Outbound updates\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) { if (strncmp ("i", argv[0], 1) == 0) { @@ -684,7 +684,7 @@ DEFUN (no_debug_bgp_update, BGP_STR "BGP updates\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) { DEBUG_OFF (update, UPDATE_IN); DEBUG_OFF (update, UPDATE_OUT); @@ -711,7 +711,7 @@ DEFUN (debug_bgp_normal, DEBUG_STR BGP_STR) { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (normal, NORMAL); else { @@ -728,7 +728,7 @@ DEFUN (no_debug_bgp_normal, DEBUG_STR BGP_STR) { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (normal, NORMAL); else { @@ -751,7 +751,7 @@ DEFUN (debug_bgp_zebra, BGP_STR "BGP Zebra messages\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (zebra, ZEBRA); else { @@ -769,7 +769,7 @@ DEFUN (no_debug_bgp_zebra, BGP_STR "BGP Zebra messages\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (zebra, ZEBRA); else { diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index d76b5699..7c36825c 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -21,6 +21,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include <zebra.h> #include "log.h" +#include "vty.h" #include "stream.h" #include "sockunion.h" #include "command.h" @@ -28,6 +29,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "thread.h" #include "linklist.h" #include "bgpd/bgp_table.h" +#include "qpath.h" +#include "qstring.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_route.h" @@ -97,8 +100,8 @@ bgp_dump_open_file (struct bgp_dump *bgp_dump) int ret; time_t clock; struct tm tm; - char fullpath[MAXPATHLEN]; - char realpath[MAXPATHLEN]; + qpath path ; + qstring name ; mode_t oldumask; time (&clock); @@ -106,11 +109,17 @@ bgp_dump_open_file (struct bgp_dump *bgp_dump) if (bgp_dump->filename[0] != DIRECTORY_SEP) { - sprintf (fullpath, "%s/%s", vty_get_cwd (), bgp_dump->filename); - ret = strftime (realpath, MAXPATHLEN, fullpath, &tm); + path = vty_getcwd(NULL) ; + qpath_append_str(path, bgp_dump->filename) ; } else - ret = strftime (realpath, MAXPATHLEN, bgp_dump->filename, &tm); + path = qpath_set(NULL, bgp_dump->filename) ; + + name = qs_new_size(NULL, qpath_len(path) + 60) ; + + ret = strftime (qs_char_nn(name), qs_len_nn(name), qpath_string(path), &tm); + + qpath_free(path) ; if (ret == 0) { @@ -123,11 +132,12 @@ bgp_dump_open_file (struct bgp_dump *bgp_dump) oldumask = umask(0777 & ~LOGFILE_MASK); - bgp_dump->fp = fopen (realpath, "w"); + bgp_dump->fp = fopen (qs_char_nn(name), "w"); if (bgp_dump->fp == NULL) { - zlog_warn("bgp_dump_open_file: %s: %s", realpath, errtoa(errno, 0).str); + zlog_warn("bgp_dump_open_file: %s: %s", qs_char_nn(name), + errtoa(errno, 0).str); umask(oldumask); return NULL; } diff --git a/bgpd/bgp_engine.h b/bgpd/bgp_engine.h index ceec1b2f..821d8127 100644 --- a/bgpd/bgp_engine.h +++ b/bgpd/bgp_engine.h @@ -22,23 +22,45 @@ #ifndef _QUAGGA_BGP_ENGINE_H #define _QUAGGA_BGP_ENGINE_H +#include "lib/misc.h" + #include "bgpd/bgpd.h" #include "lib/mqueue.h" #include "lib/qpnexus.h" #include "lib/log.h" -#ifndef Inline -#define Inline static inline +/*============================================================================== + * BGP_ENGINE_DEBUG setting + * + * Set to 1 if defined, but blank. + * Set to QDEBUG if not defined. + * + * Force to 0 if BGP_ENGINE_NO_DEBUG is defined and not zero. + * + * So: defaults to same as QDEBUG, but no matter what QDEBUG is set to: + * + * * can set BGP_ENGINE_DEBUG == 0 to turn off debug + * * or set BGP_ENGINE_DEBUG != 0 to turn on debug + * * or set BGP_ENGINE_NO_DEBUG != to force debug off + */ +#ifdef BGP_ENGINE_DEBUG /* If defined, make it 1 or 0 */ +# if IS_BLANK_OPTION(BGP_ENGINE_DEBUG) +# undef BGP_ENGINE_DEBUG +# define BGP_ENGINE_DEBUG 1 +# endif +#else /* If not defined, follow QDEBUG */ +# define BGP_ENGINE_DEBUG QDEBUG #endif -enum { qdebug = -#ifdef QDEBUG - 1 -#else - 0 +#ifdef BGP_ENGINE_NO_DEBUG /* Override, if defined */ +# if IS_NOT_ZERO_OPTION(BGP_ENGINE_NO_DEBUG) +# undef BGP_ENGINE_DEBUG +# define BGP_ENGINE_DEBUG 0 +# endif #endif -}; + +enum { bgp_engine_debug = BGP_ENGINE_DEBUG } ; /*============================================================================== * @@ -70,7 +92,7 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) ++stats->count ; - qpt_mutex_lock(&mq->mutex) ; + qpt_mutex_lock(mq->mutex) ; if (mq->count > stats->max) stats->max = mq->count ; @@ -81,7 +103,7 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) if (stats->count < 1000) { - qpt_mutex_unlock(&mq->mutex) ; + qpt_mutex_unlock(mq->mutex) ; return ; } ; @@ -96,7 +118,7 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) assert(my_count == mq->count) ; - qpt_mutex_unlock(&mq->mutex) ; + qpt_mutex_unlock(mq->mutex) ; average = stats->total * 1000 ; average = (average / stats->count) + 5 ; @@ -119,10 +141,10 @@ bgp_queue_logging(const char* name, mqueue_queue mq, struct queue_stats* stats) /* Send given message to the BGP Engine -- priority/ordinary */ Inline void -bgp_to_bgp_engine(mqueue_block mqb, enum mqb_rank priority) +bgp_to_bgp_engine(mqueue_block mqb, mqb_rank_b priority) { mqueue_enqueue(bgp_nexus->queue, mqb, priority) ; - if (qdebug) + if (bgp_engine_debug) bgp_queue_logging("BGP Engine", bgp_nexus->queue, &bgp_engine_queue_stats) ; } ; @@ -133,10 +155,10 @@ bgp_to_bgp_engine(mqueue_block mqb, enum mqb_rank priority) /* Send given message to the Routing Engine -- priority/ordinary */ Inline void -bgp_to_routing_engine(mqueue_block mqb, enum mqb_rank priority) +bgp_to_routing_engine(mqueue_block mqb, mqb_rank_b priority) { mqueue_enqueue(routing_nexus->queue, mqb, priority) ; - if (qdebug) + if (bgp_engine_debug) bgp_queue_logging("Routing Engine", routing_nexus->queue, &routing_engine_queue_stats) ; } ; diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 60b66533..38fbb7e4 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -18,15 +18,15 @@ along with GNU Zebra; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <zebra.h> -#include <stdbool.h> +#include "zebra.h" +#include "misc.h" #include "vector.h" #include "vty.h" #include "command.h" #include "getopt.h" #include "thread.h" -#include <lib/version.h> +#include "lib/version.h" #include "memory.h" #include "prefix.h" #include "log.h" @@ -118,13 +118,13 @@ static zebra_capabilities_t _caps_p [] = struct zebra_privs_t bgpd_privs = { #if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, + .user = QUAGGA_USER, + .group = QUAGGA_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, #endif - .caps_p = _caps_p, + .caps_p = _caps_p, .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]), .cap_num_i = 0, }; @@ -184,7 +184,7 @@ void sigusr2 (void); /* prototypes */ static void bgp_exit (int); -static void init_second_stage(int pthreads); +static void init_second_stage(bool pthreads); static void bgp_in_thread_init(void); static void routing_start(void) ; static void routing_finish(void) ; @@ -206,10 +206,6 @@ static struct quagga_signal_t bgp_signals[] = .handler = &sigusr1, }, { - .signal = SIGUSR2, - .handler = &sigusr2, - }, - { .signal = SIGINT, .handler = &sigint, }, @@ -240,14 +236,17 @@ sighup (void) } -/* SIGINT handler. */ +/* SIGINT and SIGTERM handler. */ void sigint (void) { zlog_notice ("Terminating on signal"); + vty_reset_because("Terminating"); + /* tell the routing engine to send notifies to peers and wait - * for all sessions to be disabled */ + * for all sessions to be disabled, then terminate. + */ sigterm_enqueue(); } @@ -258,17 +257,6 @@ sigusr1 (void) zlog_rotate (NULL); } -/* SIGUSR2 handler. */ -void -sigusr2 (void) -{ - /* Used to signal message queues */ - if (qpthreads_enabled) - return; - else - exit(1); -} - /*------------------------------------------------------------------------------ * Final exit code... * @@ -301,6 +289,7 @@ bgp_exit (int status) /* reverse bgp_zebra_init/if_init */ if (retain_mode) if_add_hook (IF_DELETE_HOOK, NULL); + for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp)) { struct listnode *c_node, *c_nnode; @@ -351,6 +340,7 @@ bgp_exit (int status) cmd_terminate (); vty_terminate (); + if (zclient) zclient_free (zclient); if (zlookup) @@ -366,10 +356,10 @@ bgp_exit (int status) if (qpthreads_enabled) { - qpn_reset_free(routing_nexus); - qpn_reset_free(bgp_nexus); + qpn_reset(routing_nexus, free_it); + qpn_reset(bgp_nexus, free_it); } ; - cli_nexus = qpn_reset_free(cli_nexus); + cli_nexus = qpn_reset(cli_nexus, free_it); if (CONF_BGP_DEBUG (normal, NORMAL)) log_memstats_stderr ("bgpd"); @@ -388,8 +378,8 @@ bgp_exit (int status) * * 1. if it's there, invoke the command in the usual way * - * 2. if it's not there, invoke the command but with a NULL set of arguments, - * which signals the "default" nature of the call. + * 2. if it's not there, invoke the command but with a *negative* count of + * arguments, which signals the "default" nature of the call. * * This mechanism is used so that the "threaded_cmd" is the time at which * second stage initialisation is done. (But only once -- not on rereading @@ -404,8 +394,8 @@ DEFUN_HID_CALL (threaded, "threaded", "Use pthreads\n") { - if (argv != NULL) - config_threaded = 1 ; /* Explicit command => turn on threading */ + if (argc == 0) + config_threaded = true ; /* Explicit command => turn on threading */ if (!done_2nd_stage_init) init_second_stage(config_threaded) ; @@ -421,7 +411,7 @@ DEFUN_HID_CALL (threaded, * the message queues are available for the configuration data. */ static void -init_second_stage(int pthreads) +init_second_stage(bool pthreads) { assert(!done_2nd_stage_init) ; @@ -431,13 +421,13 @@ init_second_stage(int pthreads) bgp_peer_index_mutex_init(); /* Make nexus for main thread, always needed */ - cli_nexus = qpn_init_new(cli_nexus, 1); /* main thread */ + cli_nexus = qpn_init_new(cli_nexus, true); /* main thread */ /* if using pthreads create additional nexus */ if (qpthreads_enabled) { - bgp_nexus = qpn_init_new(bgp_nexus, 0); - routing_nexus = qpn_init_new(routing_nexus, 0); + bgp_nexus = qpn_init_new(bgp_nexus, false); + routing_nexus = qpn_init_new(routing_nexus, false); } else { @@ -495,9 +485,8 @@ main (int argc, char **argv) /* Set umask before anything for security */ umask (0027); -#ifdef QDEBUG - fprintf(stderr, "%s\n", debug_banner); -#endif + if (qdebug) + fprintf(stderr, "%s\n", debug_banner); qlib_init_first_stage(); @@ -599,7 +588,11 @@ main (int argc, char **argv) /* Initializations. */ srand (time (NULL)); signal_init (master, Q_SIGC(bgp_signals), bgp_signals); - zprivs_init (&bgpd_privs); + + cmd_getcwd() ; /* while have privilege */ + + zprivs_init (&bgpd_privs); /* lowers privileges */ + cmd_init (1); install_element (CONFIG_NODE, &threaded_cmd); vty_init (master); @@ -648,9 +641,9 @@ main (int argc, char **argv) vty_start(vty_addr, vty_port, BGP_VTYSH_PATH); /* Print banner. */ -#ifdef QDEBUG - zlog_notice("%s", debug_banner); -#endif + if (qdebug) + zlog_notice("%s", debug_banner); + zlog_notice ("BGPd %s%s starting: vty@%d, bgp@%s:%d", QUAGGA_VERSION, (qpthreads_enabled ? " pthreaded" : ""), @@ -725,8 +718,6 @@ routing_background(void) /*------------------------------------------------------------------------------ * SIGHUP: message sent to Routeing engine and the action it then takes. - * - * TODO: should SIGHUP be a priority message (!) */ static void sighup_enqueue(void) @@ -744,16 +735,17 @@ sighup_action(mqueue_block mqb, mqb_flag_t flag) { zlog_info ("bgpd restarting!"); - bgp_terminate (0, 0); /* send notifies */ + bgp_terminate (false, false); /* send notifies */ bgp_reset (); - /* Reload config file. */ - vty_read_config (config_file, config_default); + /* Reload config file -- no special first command, now */ + vty_read_config_first_cmd_special(config_file, config_default, + NULL, config_ignore_warnings) ; - /* Create VTY's socket */ + /* Create VTY's socket */ vty_restart(vty_addr, vty_port, BGP_VTYSH_PATH); - /* Try to return to normal operation. */ + /* Try to return to normal operation. */ } mqb_free(mqb); @@ -807,7 +799,7 @@ sigterm_action(mqueue_block mqb, mqb_flag_t flag) */ program_terminating = true ; - bgp_terminate(1, retain_mode); + bgp_terminate(true, retain_mode); qpn_add_hook_function(&routing_nexus->foreground, program_terminate_if_all_peers_deleted) ; diff --git a/bgpd/bgp_msg_write.h b/bgpd/bgp_msg_write.h index 77bfc1f2..8867e06f 100644 --- a/bgpd/bgp_msg_write.h +++ b/bgpd/bgp_msg_write.h @@ -24,8 +24,7 @@ #ifndef _QUAGGA_BGP_MSG_WRITE_H #define _QUAGGA_BGP_MSG_WRITE_H -#include <stdint.h> -#include <stdbool.h> +#include "misc.h" #include "bgpd/bgp_common.h" #include "bgpd/bgp_connection.h" diff --git a/bgpd/bgp_notification.c b/bgpd/bgp_notification.c index 7dd68c63..d70491c9 100644 --- a/bgpd/bgp_notification.c +++ b/bgpd/bgp_notification.c @@ -20,8 +20,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include "misc.h" -#include <string.h> #include <netinet/in.h> #include "lib/zassert.h" diff --git a/bgpd/bgp_notification.h b/bgpd/bgp_notification.h index 20e96063..755f431e 100644 --- a/bgpd/bgp_notification.h +++ b/bgpd/bgp_notification.h @@ -24,13 +24,9 @@ #ifndef _QUAGGA_BGP_NOTIFY_H #define _QUAGGA_BGP_NOTIFY_H -#include <stddef.h> +#include "lib/misc.h" #include "bgpd/bgp_common.h" -#ifndef Inline -#define Inline static inline -#endif - /*============================================================================== * BGP NOTIFICATION message codes. */ diff --git a/bgpd/bgp_open_state.c b/bgpd/bgp_open_state.c index 9ca9617e..e1dbaeaf 100644 --- a/bgpd/bgp_open_state.c +++ b/bgpd/bgp_open_state.c @@ -48,7 +48,7 @@ bgp_open_state_init_new(bgp_open_state state) else memset(state, 0, sizeof(struct bgp_open_state)) ; - vector_init_new(&state->unknowns, 0) ; + vector_init_new(state->unknowns, 0) ; return state ; } @@ -66,10 +66,10 @@ bgp_open_state_free(bgp_open_state state) if (state != NULL) { - while ((unknown = vector_ream_keep(&state->unknowns)) != NULL) + while ((unknown = vector_ream(state->unknowns, keep_it)) != NULL) XFREE(MTYPE_TMP, unknown) ; - while ((afi_safi = vector_ream_keep(&state->afi_safi)) != NULL) + while ((afi_safi = vector_ream(state->afi_safi, keep_it)) != NULL) XFREE(MTYPE_TMP, afi_safi) ; XFREE(MTYPE_BGP_OPEN_STATE, state) ; @@ -222,7 +222,7 @@ bgp_open_state_unknown_add(bgp_open_state state, uint8_t code, if (length != 0) memcpy(unknown->value, value, length) ; - vector_push_item(&state->unknowns, unknown) ; + vector_push_item(state->unknowns, unknown) ; } ; /*------------------------------------------------------------------------------ @@ -231,7 +231,7 @@ bgp_open_state_unknown_add(bgp_open_state state, uint8_t code, extern int bgp_open_state_unknown_count(bgp_open_state state) { - return vector_end(&state->unknowns) ; + return vector_end(state->unknowns) ; } ; /*------------------------------------------------------------------------------ @@ -240,7 +240,7 @@ bgp_open_state_unknown_count(bgp_open_state state) extern bgp_cap_unknown bgp_open_state_unknown_cap(bgp_open_state state, unsigned index) { - return vector_get_item(&state->unknowns, index) ; + return vector_get_item(state->unknowns, index) ; } ; /*============================================================================== @@ -264,7 +264,7 @@ bgp_open_state_afi_safi_add(bgp_open_state state, iAFI_t afi, iSAFI_t safi, afi_safi->safi = safi ; afi_safi->cap_code = cap_code ; - vector_push_item(&state->afi_safi, afi_safi) ; + vector_push_item(state->afi_safi, afi_safi) ; return afi_safi ; } ; @@ -275,7 +275,7 @@ bgp_open_state_afi_safi_add(bgp_open_state state, iAFI_t afi, iSAFI_t safi, extern int bgp_open_state_afi_safi_count(bgp_open_state state) { - return vector_end(&state->afi_safi) ; + return vector_end(state->afi_safi) ; } ; /*------------------------------------------------------------------------------ @@ -284,7 +284,7 @@ bgp_open_state_afi_safi_count(bgp_open_state state) extern bgp_cap_afi_safi bgp_open_state_afi_safi_cap(bgp_open_state state, unsigned index) { - return vector_get_item(&state->afi_safi, index) ; + return vector_get_item(state->afi_safi, index) ; } ; /*============================================================================== diff --git a/bgpd/bgp_open_state.h b/bgpd/bgp_open_state.h index 8c30712b..e88deda0 100644 --- a/bgpd/bgp_open_state.h +++ b/bgpd/bgp_open_state.h @@ -22,16 +22,12 @@ #ifndef _QUAGGA_BGP_OPEN_STATE_H #define _QUAGGA_BGP_OPEN_STATE_H -#include <stdint.h> +#include "misc.h" #include "bgpd/bgp.h" #include "bgpd/bgp_common.h" #include "lib/vector.h" -#ifndef Inline -#define Inline static inline -#endif - /*============================================================================== * BGP Open State. * @@ -114,8 +110,8 @@ struct bgp_open_state bool has_restarted ; /* Restart State flag */ unsigned restart_time ; /* Restart Time in seconds */ - struct vector unknowns ; /* list of bgp_cap_unknown */ - struct vector afi_safi ; /* various afi/safi capabilities */ + vector_t unknowns ; /* list of bgp_cap_unknown */ + vector_t afi_safi ; /* various afi/safi capabilities */ } ; /*============================================================================== diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index b21cec4e..3052eeba 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -780,7 +780,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi, bgp_orf_entry orfpe = NULL; struct prefix_list *plist = NULL; struct orf_prefix orfp; - vector_index i; + vector_index_t i; int orf_refresh = 0; enum prefix_list_type pe_type; @@ -1838,7 +1838,7 @@ bgp_route_refresh_recv(bgp_peer peer, bgp_route_refresh rr) { afi_t afi; safi_t safi; - vector_index i; + vector_index_t i, e; char name[BUFSIZ]; int ret; @@ -1853,11 +1853,11 @@ bgp_route_refresh_recv(bgp_peer peer, bgp_route_refresh rr) ret = snprintf (name, BUFSIZ, "%s.%d.%d", peer->host, afi, safi); assert(ret < BUFSIZ); - if (rr->entries.end > 0) + if ((e = bgp_orf_get_count(rr)) > 0) { - for (i = 0; i < rr->entries.end; ++i) + for (i = 0; i < e; ++i) { - bgp_orf_entry orfep = vector_slot(&rr->entries, i); + bgp_orf_entry orfep = vector_slot(rr->entries, i); /* ignore unknown */ if (orfep->unknown) diff --git a/bgpd/bgp_peer.c b/bgpd/bgp_peer.c index 45d4ca0e..196f0d54 100644 --- a/bgpd/bgp_peer.c +++ b/bgpd/bgp_peer.c @@ -464,7 +464,7 @@ bgp_session_has_disabled(bgp_session session) session->state = bgp_session_sDisabled ; /* Immediately discard any other messages for this session. */ - mqueue_revoke(routing_nexus->queue, session) ; + mqueue_revoke(routing_nexus->queue, session, 0) ; /* If the session is marked "delete_me", do that. * diff --git a/bgpd/bgp_peer_index.c b/bgpd/bgp_peer_index.c index 518a22bc..d3c90598 100644 --- a/bgpd/bgp_peer_index.c +++ b/bgpd/bgp_peer_index.c @@ -18,6 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include "misc.h" #include "lib/zassert.h" @@ -59,7 +60,7 @@ */ static struct symbol_table bgp_peer_index ; /* lookup by 'name' */ -static struct vector bgp_peer_id_index ; /* lookup by peer-id */ +static vector_t bgp_peer_id_index ; /* lookup by peer-id */ static qpt_mutex bgp_peer_index_mutex = NULL ; @@ -112,7 +113,7 @@ bgp_peer_index_init(void* parent) sockunion_symbol_hash, /* "name" is an IP Address */ NULL) ; /* no value change call-back */ - vector_init_new(&bgp_peer_id_index, bgp_peer_id_unit) ; + vector_init_new(bgp_peer_id_index, bgp_peer_id_unit) ; /* Initialise table entirely empty */ bgp_peer_id_table = NULL ; @@ -149,11 +150,11 @@ bgp_peer_index_reset(void) bgp_peer_id_table_chunk chunk ; /* Ream out the peer id vector -- checking that all entries are empty */ - while ((entry = vector_ream_keep(&bgp_peer_id_index)) != NULL) + while ((entry = vector_ream(bgp_peer_id_index, keep_it)) != NULL) passert((entry->peer == NULL) && (entry->next_free != entry)) ; /* Discard body of symbol table -- must be empty ! */ - symbol_table_reset_keep(&bgp_peer_index) ; + symbol_table_reset(&bgp_peer_index, keep_it) ; /* Discard the empty chunks of entries */ while (bgp_peer_id_table != NULL) @@ -204,7 +205,7 @@ bgp_peer_index_register(bgp_peer peer, union sockunion* su) entry = bgp_peer_id_free_head ; bgp_peer_id_free_head = entry->next_free ; - assert(vector_get_item(&bgp_peer_id_index, entry->id) == entry) ; + assert(vector_get_item(bgp_peer_id_index, entry->id) == entry) ; /* Initialise the entry -- the id is already set */ entry->peer = peer ; @@ -213,7 +214,7 @@ bgp_peer_index_register(bgp_peer peer, union sockunion* su) peer->index_entry = entry; /* Insert the new entry into the symbol table. */ - entry = symbol_set_value(symbol_find(&bgp_peer_index, su), entry) ; + entry = symbol_set_value(symbol_lookup(&bgp_peer_index, su, add), entry) ; BGP_PEER_INDEX_UNLOCK() ; /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ @@ -241,7 +242,7 @@ bgp_peer_index_deregister(bgp_peer peer, union sockunion* su) BGP_PEER_INDEX_LOCK() ; /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ - sym = symbol_seek(&bgp_peer_index, su) ; + sym = symbol_lookup(&bgp_peer_index, su, no_add) ; passert(sym != NULL) ; entry = symbol_delete(sym) ; @@ -288,7 +289,7 @@ bgp_peer_index_seek_entry(union sockunion* su) /* Only the Routing Engine can add/delete entries -- so no lock required */ - entry = symbol_get_value(symbol_seek(&bgp_peer_index, su)) ; + entry = symbol_get_value(symbol_lookup(&bgp_peer_index, su, no_add)) ; if (entry != NULL) assert((entry->peer != NULL) && (entry->next_free = entry)) ; @@ -340,7 +341,7 @@ bgp_peer_index_seek_accept(union sockunion* su, bool* p_found) BGP_PEER_INDEX_LOCK() ; /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ - entry = symbol_get_value(symbol_seek(&bgp_peer_index, su)) ; + entry = symbol_get_value(symbol_lookup(&bgp_peer_index, su, no_add)) ; if (entry != NULL) { @@ -375,7 +376,7 @@ static void bgp_peer_id_table_free_entry(bgp_peer_index_entry entry) { assert((entry != NULL) && (entry->id < bgp_peer_id_count)) ; - assert(vector_get_item(&bgp_peer_id_index, entry->id) == entry) ; + assert(vector_get_item(bgp_peer_id_index, entry->id) == entry) ; if (bgp_peer_id_free_head == NULL) bgp_peer_id_free_head = entry ; @@ -424,7 +425,7 @@ bgp_peer_id_table_make_ids(void) while (id_new < bgp_peer_id_count) { - vector_set_item(&bgp_peer_id_index, id_new, entry) ; + vector_set_item(bgp_peer_id_index, id_new, entry) ; entry->id = id_new ; bgp_peer_id_table_free_entry(entry) ; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index bcf23db5..34d580b8 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -11564,7 +11564,7 @@ DEFUN (show_ip_bgp_view_rsclient_prefix, if (argc == 3) peer = peer_lookup_in_view (vty, argv[0], argv[1]); else - peer = peer_lookup_in_view (vty, NULL, argv[0]); + peer = peer_lookup_in_view (vty, NULL, argv[0]); if (! peer) return CMD_WARNING; @@ -11653,11 +11653,11 @@ DEFUN (show_bgp_view_ipv4_safi_rsclient_prefix, vty_out (vty, "%% Activate the neighbor for the address family first%s", VTY_NEWLINE); return CMD_WARNING; -} + } if ( ! CHECK_FLAG (peer->af_flags[AFI_IP][safi], PEER_FLAG_RSERVER_CLIENT)) -{ + { vty_out (vty, "%% Neighbor is not a Route-Server client%s", VTY_NEWLINE); return CMD_WARNING; diff --git a/bgpd/bgp_route_refresh.c b/bgpd/bgp_route_refresh.c index 5c2b6e5c..252183e4 100644 --- a/bgpd/bgp_route_refresh.c +++ b/bgpd/bgp_route_refresh.c @@ -18,6 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include "misc.h" #include <string.h> @@ -60,7 +61,7 @@ bgp_route_refresh_new(iAFI_t afi, iSAFI_t safi, unsigned count) rr->afi = afi ; rr->safi = safi ; - vector_init_new(&rr->entries, count) ; + vector_init_new(rr->entries, count) ; /* rest of bgp_route_refresh zeroised -- not relevant when vector empty */ @@ -74,7 +75,7 @@ extern void bgp_route_refresh_free(bgp_route_refresh rr) { bgp_orf_entry entry ; - while((entry = vector_ream_keep(&rr->entries)) != NULL) + while((entry = vector_ream(rr->entries, keep_it)) != NULL) XFREE(MTYPE_BGP_ORF_ENTRY, entry) ; XFREE(MTYPE_BGP_ROUTE_REFRESH, rr) ; @@ -130,7 +131,7 @@ bgp_orf_entry_new(bgp_route_refresh rr, uint8_t orf_type, bgp_form_t form, orfe->form = form ; orfe->unknown = (unknown_size != 0) ; - vector_push_item(&rr->entries, orfe) ; + vector_push_item(rr->entries, orfe) ; return orfe ; } ; diff --git a/bgpd/bgp_route_refresh.h b/bgpd/bgp_route_refresh.h index b44ca9e0..78324ff4 100644 --- a/bgpd/bgp_route_refresh.h +++ b/bgpd/bgp_route_refresh.h @@ -22,16 +22,12 @@ #ifndef _QUAGGA_BGP_ROUTE_REFRESH_H #define _QUAGGA_BGP_ROUTE_REFRESH_H -#include <stddef.h> +#include "lib/misc.h" #include "bgpd/bgp_common.h" #include "lib/prefix.h" #include "lib/plist.h" -#ifndef Inline -#define Inline static inline -#endif - /*============================================================================== * Structures to hold ROUTE-REFRESH and ORF */ @@ -81,7 +77,7 @@ struct bgp_route_refresh iAFI_t afi ; /* NB: Internet AFI/SAFI */ iSAFI_t safi ; - struct vector entries ; /* empty => simple ROUTE-REFRESH */ + vector_t entries ; /* empty => simple ROUTE-REFRESH */ bool defer ; /* otherwise: immediate */ @@ -120,13 +116,13 @@ bgp_orf_add_unknown(bgp_route_refresh rr, uint8_t orf_type, bgp_size_t length, Inline unsigned bgp_orf_get_count(bgp_route_refresh rr) { - return vector_end(&rr->entries) ; + return vector_end(rr->entries) ; } ; Inline bgp_orf_entry bgp_orf_get_entry(bgp_route_refresh rr, unsigned index) { - return vector_get_item(&rr->entries, index) ; + return vector_get_item(rr->entries, index) ; } ; #endif /* _QUAGGA_BGP_ROUTE_REFRESH_H */ diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 33e2c9cd..f9bf2844 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1461,11 +1461,11 @@ route_set_community_delete (void *rule, struct prefix *prefix, community_free (merge); /* HACK: if the old community is not intern'd, - * we should free it here, or all reference to it may be lost. - * Really need to cleanup attribute caching sometime. + * we should free it here, or all references to it may be lost. + * Really need to clean up attribute caching sometime. */ if (old->refcnt == 0) - community_free (old); + community_free(old) ; if (new->size == 0) { @@ -1605,9 +1605,9 @@ route_set_ecommunity_soo (void *rule, struct prefix *prefix, if (! ecom) return RMAP_OKAY; - + old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity; - + if (old_ecom) new_ecom = ecommunity_merge (ecommunity_dup (old_ecom), ecom); else @@ -1632,7 +1632,7 @@ route_set_ecommunity_soo_compile (const char *arg) ecom = ecommunity_str2com (arg, ECOMMUNITY_SITE_ORIGIN, 0); if (! ecom) return NULL; - + return ecommunity_intern (ecom); } @@ -2991,7 +2991,7 @@ DEFUN (set_metric, ALIAS (set_metric, set_metric_addsub_cmd, - "set metric <+/-metric>", + "set metric <-2147483647-+2147483647>", SET_STR "Metric value for destination routing protocol\n" "Add or subtract metric\n") @@ -3081,7 +3081,7 @@ ALIAS (no_set_weight, DEFUN (set_aspath_prepend, set_aspath_prepend_cmd, - "set as-path prepend ." CMD_AS_RANGE, + "set as-path prepend .ASNs", SET_STR "Transform BGP AS_PATH attribute\n" "Prepend to the as-path\n" @@ -3119,7 +3119,7 @@ DEFUN (no_set_aspath_prepend, ALIAS (no_set_aspath_prepend, no_set_aspath_prepend_val_cmd, - "no set as-path prepend ." CMD_AS_RANGE, + "no set as-path prepend .ASns", NO_STR SET_STR "Transform BGP AS_PATH attribute\n" @@ -3128,7 +3128,7 @@ ALIAS (no_set_aspath_prepend, DEFUN (set_aspath_exclude, set_aspath_exclude_cmd, - "set as-path exclude ." CMD_AS_RANGE, + "set as-path exclude .ASNs", SET_STR "Transform BGP AS-path attribute\n" "Exclude from the as-path\n" @@ -3165,7 +3165,7 @@ DEFUN (no_set_aspath_exclude, ALIAS (no_set_aspath_exclude, no_set_aspath_exclude_val_cmd, - "no set as-path exclude ." CMD_AS_RANGE, + "no set as-path exclude .ASNs", NO_STR SET_STR "Transform BGP AS_PATH attribute\n" @@ -3177,7 +3177,8 @@ DEFUN (set_community, "set community .AA:NN", SET_STR "BGP community attribute\n" - "Community number in aa:nn format or local-AS|no-advertise|no-export|internet or additive\n") + "Community number in aa:nn format or """ + "local-AS|no-advertise|no-export|internet or additive\n") { int i; int first = 0; diff --git a/bgpd/bgp_session.c b/bgpd/bgp_session.c index 99077907..7e04e216 100644 --- a/bgpd/bgp_session.c +++ b/bgpd/bgp_session.c @@ -18,6 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include "misc.h" #include "bgpd/bgp_session.h" #include "bgpd/bgp_common.h" @@ -124,7 +125,7 @@ bgp_session_init_new(bgp_peer peer) session = XCALLOC(MTYPE_BGP_SESSION, sizeof(struct bgp_session)) ; - qpt_mutex_init_new(&session->mutex, qpt_mutex_recursive) ; + qpt_mutex_init_new(session->mutex, qpt_mutex_recursive) ; session->peer = peer ; bgp_peer_lock(peer) ; /* Account for the session->peer pointer */ @@ -240,7 +241,7 @@ bgp_session_delete(bgp_peer peer) BGP_SESSION_UNLOCK(session) ; /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ - qpt_mutex_destroy(&session->mutex, 0) ; + qpt_mutex_destroy(session->mutex, 0) ; /* Proceed to dismantle the session. */ @@ -462,7 +463,7 @@ bgp_session_disable(bgp_peer peer, bgp_notify notification) /* Can revoke whatever may be queued already. Will revoke again when the * disable is acknowledged to finally clear the session out of the queue. */ - mqueue_revoke(routing_nexus->queue, session) ; + mqueue_revoke(routing_nexus->queue, session, 0) ; /* Now change to limping state */ session->state = bgp_session_sLimping; @@ -518,7 +519,7 @@ bgp_session_do_disable(mqueue_block mqb, mqb_flag_t flag) if (flag == mqb_action) { /* Immediately discard any other messages for this session. */ - mqueue_revoke(bgp_nexus->queue, session) ; + mqueue_revoke(bgp_nexus->queue, session, 0) ; /* Get the FSM to send any notification and close connections */ bgp_fsm_disable_session(session, args->notification) ; diff --git a/bgpd/bgp_session.h b/bgpd/bgp_session.h index 24bb5cd6..f8cfa547 100644 --- a/bgpd/bgp_session.h +++ b/bgpd/bgp_session.h @@ -22,8 +22,8 @@ #ifndef _QUAGGA_BGP_SESSION_H #define _QUAGGA_BGP_SESSION_H -#include <stdbool.h> #include <zebra.h> +#include "lib/misc.h" #include "bgpd/bgp_common.h" #include "bgpd/bgp_engine.h" @@ -37,10 +37,6 @@ #include "lib/sockunion.h" #include "lib/mqueue.h" -#ifndef Inline -#define Inline static inline -#endif - /*============================================================================== * BGP Session data structure. * @@ -310,12 +306,12 @@ MQB_ARGS_SIZE_OK(bgp_session_ttl_args) ; inline static void BGP_SESSION_LOCK(bgp_session session) { - qpt_mutex_lock(&session->mutex) ; + qpt_mutex_lock(session->mutex) ; } ; inline static void BGP_SESSION_UNLOCK(bgp_session session) { - qpt_mutex_unlock(&session->mutex) ; + qpt_mutex_unlock(session->mutex) ; } ; /*============================================================================== diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index eaa41e6c..3f56fb25 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -44,13 +44,13 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_route.h" #include "bgpd/bgp_fsm.h" #include "bgpd/bgp_snmp.h" - + /* BGP4-MIB described in RFC1657. */ #define BGP4MIB 1,3,6,1,2,1,15 /* BGP TRAP. */ #define BGPESTABLISHED 1 -#define BGPBACKWARDTRANSITION 2 +#define BGPBACKWARDTRANSITION 2 /* BGP MIB bgpVersion. */ #define BGPVERSION 0 @@ -118,7 +118,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #define OCTET_STRING ASN_OCTET_STR #define IPADDRESS ASN_IPADDRESS #define GAUGE32 ASN_UNSIGNED - + /* Declare static local variables for convenience. */ SNMP_LOCAL_VARIABLES @@ -143,7 +143,7 @@ static u_char *bgp4PathAttrTable (struct variable *, oid [], size_t *, int, size_t *, WriteMethod **); /* static u_char *bgpTraps (); */ -struct variable bgp_variables[] = +struct variable bgp_variables[] = { /* BGP version. */ {BGPVERSION, OCTET_STRING, RONLY, bgpVersion, @@ -247,7 +247,7 @@ struct variable bgp_variables[] = 3, {6, 1, 14}}, }; - + static u_char * bgpVersion (struct variable *v, oid name[], size_t *length, int exact, size_t *var_len, WriteMethod **write_method) @@ -343,7 +343,7 @@ bgp_peer_lookup_next (struct in_addr *src) } static struct peer * -bgpPeerTable_lookup (struct variable *v, oid name[], size_t *length, +bgpPeerTable_lookup (struct variable *v, oid name[], size_t *length, struct in_addr *addr, int exact) { struct peer *peer = NULL; @@ -364,9 +364,9 @@ bgpPeerTable_lookup (struct variable *v, oid name[], size_t *length, { len = *length - v->namelen; if (len > 4) len = 4; - + oid2in_addr (name + v->namelen, len, addr); - + peer = bgp_peer_lookup_next (addr); if (peer == NULL) @@ -391,12 +391,12 @@ write_bgpPeerTable (int action, u_char *var_val, struct peer *peer; long intval; size_t bigsize = SNMP_MAX_LEN; - - if (var_val_type != ASN_INTEGER) + + if (var_val_type != ASN_INTEGER) { return SNMP_ERR_WRONGTYPE; } - if (var_val_len != sizeof (long)) + if (var_val_len != sizeof (long)) { return SNMP_ERR_WRONGLENGTH; } @@ -597,7 +597,7 @@ bgpPeerTable (struct variable *v, oid name[], size_t *length, default: return NULL; break; - } + } return NULL; } @@ -664,7 +664,7 @@ bgp4PathAttrLookup (struct variable *v, oid name[], size_t *length, oid2in_addr (offset, IN_ADDR_SIZE, &su.sin.sin_addr); /* Lookup node. */ - rn = bgp_node_lookup (bgp->rib[AFI_IP][SAFI_UNICAST], + rn = bgp_node_lookup (bgp->rib[AFI_IP][SAFI_UNICAST], (struct prefix *) addr); if (rn) { @@ -687,7 +687,7 @@ bgp4PathAttrLookup (struct variable *v, oid name[], size_t *length, { if (len > IN_ADDR_SIZE) len = IN_ADDR_SIZE; - + oid2in_addr (offset, len, &addr->prefix); offset += IN_ADDR_SIZE; @@ -726,12 +726,12 @@ bgp4PathAttrLookup (struct variable *v, oid name[], size_t *length, for (binfo = rn->info; binfo; binfo = binfo->info_next) { if (binfo->peer->su.sin.sin_family == AF_INET - && ntohl (paddr.s_addr) + && ntohl (paddr.s_addr) < ntohl (binfo->peer->su.sin.sin_addr.s_addr)) { if (min) { - if (ntohl (binfo->peer->su.sin.sin_addr.s_addr) + if (ntohl (binfo->peer->su.sin.sin_addr.s_addr) < ntohl (min->peer->su.sin.sin_addr.s_addr)) min = binfo; } @@ -749,7 +749,7 @@ bgp4PathAttrLookup (struct variable *v, oid name[], size_t *length, offset += IN_ADDR_SIZE; *offset = rn->p.prefixlen; offset++; - oid_copy_addr (offset, &min->peer->su.sin.sin_addr, + oid_copy_addr (offset, &min->peer->su.sin.sin_addr, IN_ADDR_SIZE); addr->prefix = rn->p.u.prefix4; addr->prefixlen = rn->p.prefixlen; @@ -773,7 +773,7 @@ bgp4PathAttrTable (struct variable *v, oid name[], size_t *length, struct bgp *bgp; struct bgp_info *binfo; struct prefix_ipv4 addr; - + bgp = bgp_get_default (); if (! bgp) return NULL; @@ -843,7 +843,7 @@ bgp4PathAttrTable (struct variable *v, oid name[], size_t *length, } return NULL; } - + /* BGP Traps. */ struct trap_object bgpTrapList[] = { diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 48d8ecbe..40efd6b8 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -57,9 +57,7 @@ extern struct in_addr router_id_zebra; afi_t bgp_node_afi (struct vty *vty) { - enum node_type node = vty_get_node(vty) ; - - if (node == BGP_IPV6_NODE || node == BGP_IPV6M_NODE) + if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE) return AFI_IP6; return AFI_IP; } @@ -69,11 +67,9 @@ bgp_node_afi (struct vty *vty) safi_t bgp_node_safi (struct vty *vty) { - enum node_type node = vty_get_node(vty) ; - - if (node == BGP_VPNV4_NODE) + if (vty->node == BGP_VPNV4_NODE) return SAFI_MPLS_VPN; - if (node == BGP_IPV4M_NODE || node == BGP_IPV6M_NODE) + if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE) return SAFI_MULTICAST; return SAFI_UNICAST; } @@ -323,12 +319,13 @@ DEFUN_DEPRECATED (neighbor_version, } /* "router bgp" commands. */ -DEFUN (router_bgp, - router_bgp_cmd, - "router bgp " CMD_AS_RANGE, - ROUTER_STR - BGP_STR - AS_STR) +DEFUN_ATTR (router_bgp, + router_bgp_cmd, + "router bgp " CMD_AS_RANGE, + ROUTER_STR + BGP_STR + AS_STR, + CMD_ATTR_NODE + BGP_NODE) { int ret; as_t as; @@ -347,9 +344,11 @@ DEFUN (router_bgp, vty_out (vty, "Please specify 'bgp multiple-instance' first%s", VTY_NEWLINE); return CMD_WARNING; + case BGP_ERR_AS_MISMATCH: vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); return CMD_WARNING; + case BGP_ERR_INSTANCE_MISMATCH: vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE); vty_out (vty, "BGP instance is already running; AS is %u%s", @@ -357,20 +356,21 @@ DEFUN (router_bgp, return CMD_WARNING; } - vty_set_node(vty, BGP_NODE) ; + vty->node = BGP_NODE ; vty->index = bgp; return CMD_SUCCESS; } -ALIAS (router_bgp, - router_bgp_view_cmd, - "router bgp " CMD_AS_RANGE " view WORD", - ROUTER_STR - BGP_STR - AS_STR - "BGP view\n" - "view name\n") +ALIAS_ATTR (router_bgp, + router_bgp_view_cmd, + "router bgp " CMD_AS_RANGE " view WORD", + ROUTER_STR + BGP_STR + AS_STR + "BGP view\n" + "view name\n", + CMD_ATTR_NODE + BGP_NODE) /* "no router bgp" commands. */ DEFUN (no_router_bgp, @@ -606,7 +606,7 @@ ALIAS (no_bgp_confederation_identifier, DEFUN (bgp_confederation_peers, bgp_confederation_peers_cmd, - "bgp confederation peers ." CMD_AS_RANGE, + "bgp confederation peers .ASs", "BGP specific commands\n" "AS confederation parameters\n" "Peer ASs in BGP confederation\n" @@ -636,7 +636,7 @@ DEFUN (bgp_confederation_peers, DEFUN (no_bgp_confederation_peers, no_bgp_confederation_peers_cmd, - "no bgp confederation peers ." CMD_AS_RANGE, + "no bgp confederation peers .ASs", NO_STR "BGP specific commands\n" "AS confederation parameters\n" @@ -4050,90 +4050,118 @@ DEFUN (no_neighbor_ttl_security, } /* Address family configuration. */ -DEFUN (address_family_ipv4, - address_family_ipv4_cmd, - "address-family ipv4", - "Enter Address Family command mode\n" - "Address family\n") -{ - vty_set_node(vty, BGP_IPV4_NODE) ; +DEFUN_ATTR (address_family_ipv4, + address_family_ipv4_cmd, + "address-family ipv4", + "Enter Address Family command mode\n" + "Address family\n", + CMD_ATTR_NODE + BGP_IPV4_NODE) +{ + vty->node = BGP_IPV4_NODE ; return CMD_SUCCESS; } -DEFUN (address_family_ipv4_safi, - address_family_ipv4_safi_cmd, - "address-family ipv4 (unicast|multicast)", - "Enter Address Family command mode\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n") +DEFUN_ATTR (address_family_ipv4_safi_unicast, + address_family_ipv4_safi_unicast_cmd, + "address-family ipv4 unicast", + "Enter Address Family command mode\n" + "Address family\n" + "Address Family modifier\n", + CMD_ATTR_NODE + BGP_IPV4_NODE) { - if (strncmp (argv[0], "m", 1) == 0) - vty_set_node(vty, BGP_IPV4M_NODE) ; - else - vty_set_node(vty, BGP_IPV4_NODE) ; + vty->node = BGP_IPV4_NODE ; + return CMD_SUCCESS; +} +DEFUN_ATTR (address_family_ipv4_safi_multicast, + address_family_ipv4_safi_multicast_cmd, + "address-family ipv4 multicast", + "Enter Address Family command mode\n" + "Address family\n" + "Address Family modifier\n", + CMD_ATTR_NODE + BGP_IPV4M_NODE) +{ + vty->node = BGP_IPV4M_NODE ; return CMD_SUCCESS; } -DEFUN (address_family_ipv6, - address_family_ipv6_cmd, - "address-family ipv6", - "Enter Address Family command mode\n" - "Address family\n") +DEFUN_ATTR (address_family_ipv6, + address_family_ipv6_cmd, + "address-family ipv6", + "Enter Address Family command mode\n" + "Address family\n", + CMD_ATTR_NODE + BGP_IPV6_NODE) { - vty_set_node(vty, BGP_IPV6_NODE) ; + vty->node = BGP_IPV6_NODE ; return CMD_SUCCESS; } -DEFUN (address_family_ipv6_safi, - address_family_ipv6_safi_cmd, - "address-family ipv6 (unicast|multicast)", - "Enter Address Family command mode\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n") +DEFUN_ATTR (address_family_ipv6_safi_unicast, + address_family_ipv6_safi_unicast_cmd, + "address-family ipv6 unicast", + "Enter Address Family command mode\n" + "Address family\n" + "Address Family modifier\n", + CMD_ATTR_NODE + BGP_IPV6_NODE) { - if (strncmp (argv[0], "m", 1) == 0) - vty_set_node(vty, BGP_IPV6M_NODE) ; - else - vty_set_node(vty, BGP_IPV6_NODE) ; + vty->node = BGP_IPV6_NODE ; + return CMD_SUCCESS; +} +DEFUN_ATTR (address_family_ipv6_safi_multicast, + address_family_ipv6_safi_multicast_cmd, + "address-family ipv6 multicast", + "Enter Address Family command mode\n" + "Address family\n" + "Address Family modifier\n", + CMD_ATTR_NODE + BGP_IPV6M_NODE) +{ + vty->node = BGP_IPV6M_NODE ; return CMD_SUCCESS; } -DEFUN (address_family_vpnv4, - address_family_vpnv4_cmd, - "address-family vpnv4", - "Enter Address Family command mode\n" - "Address family\n") +DEFUN_ATTR (address_family_vpnv4, + address_family_vpnv4_cmd, + "address-family vpnv4", + "Enter Address Family command mode\n" + "Address family\n", + CMD_ATTR_NODE + BGP_VPNV4_NODE) { - vty_set_node(vty, BGP_VPNV4_NODE) ; + vty->node = BGP_VPNV4_NODE ; return CMD_SUCCESS; } -ALIAS (address_family_vpnv4, +ALIAS_ATTR (address_family_vpnv4, address_family_vpnv4_unicast_cmd, "address-family vpnv4 unicast", "Enter Address Family command mode\n" "Address family\n" - "Address Family Modifier\n") + "Address Family Modifier\n", + CMD_ATTR_NODE + BGP_VPNV4_NODE) -DEFUN (exit_address_family, - exit_address_family_cmd, - "exit-address-family", - "Exit from Address Family configuration mode\n") +DEFUN_ATTR (exit_address_family, + exit_address_family_cmd, + "exit-address-family", + "Exit from Address Family configuration mode\n", + CMD_ATTR_NODE + BGP_NODE) { - enum node_type node = vty_get_node(vty) ; + node_type_t node = vty->node ; - if (node == BGP_IPV4_NODE + if ( node == BGP_IPV4_NODE || node == BGP_IPV4M_NODE || node == BGP_VPNV4_NODE || node == BGP_IPV6_NODE || node == BGP_IPV6M_NODE) - vty_set_node(vty, BGP_NODE); - return CMD_SUCCESS; -} + { + vty->node = BGP_NODE ; + return CMD_SUCCESS ; + } + else + { + vty_out(vty, "%% No address family to leave\n") ; + return CMD_WARNING ; + } ; +} ; /* BGP clear sort. */ typedef enum @@ -6651,52 +6679,55 @@ DEFUN (show_bgp_memory, BGP_STR "Global BGP memory statistics\n") { + mem_stats_t mst[1] ; char memstrbuf[MTYPE_MEMSTR_LEN]; unsigned long count; + mem_get_stats(mst) ; + /* RIB related usage stats */ - count = mtype_stats_alloc (MTYPE_BGP_NODE); + count = mem_get_alloc(mst, MTYPE_BGP_NODE); vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_node)), VTY_NEWLINE); - count = mtype_stats_alloc (MTYPE_BGP_ROUTE); + count = mem_get_alloc(mst, MTYPE_BGP_ROUTE); vty_out (vty, "%ld BGP routes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_info)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) + if ((count = mem_get_alloc(mst, MTYPE_BGP_ROUTE_EXTRA))) vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_info_extra)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) + if ((count = mem_get_alloc(mst, MTYPE_BGP_STATIC))) vty_out (vty, "%ld Static routes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_static)), VTY_NEWLINE); /* Adj-In/Out */ - if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) + if ((count = mem_get_alloc(mst, MTYPE_BGP_ADJ_IN))) vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_adj_in)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) + if ((count = mem_get_alloc(mst, MTYPE_BGP_ADJ_OUT))) vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_adj_out)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) + if ((count = mem_get_alloc(mst, MTYPE_BGP_NEXTHOP_CACHE))) vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_nexthop_cache)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) + if ((count = mem_get_alloc(mst, MTYPE_BGP_DAMP_INFO))) vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct bgp_damp_info)), @@ -6708,7 +6739,7 @@ DEFUN (show_bgp_memory, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof(struct attr)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) + if ((count = mem_get_alloc(mst, MTYPE_ATTR_EXTRA))) vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof(struct attr_extra)), @@ -6724,7 +6755,7 @@ DEFUN (show_bgp_memory, count * sizeof (struct aspath)), VTY_NEWLINE); - count = mtype_stats_alloc (MTYPE_AS_SEG); + count = mem_get_alloc(mst, MTYPE_AS_SEG); vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct assegment)), @@ -6736,43 +6767,43 @@ DEFUN (show_bgp_memory, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct community)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) + if ((count = mem_get_alloc(mst, MTYPE_ECOMMUNITY))) vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct ecommunity)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) + if ((count = mem_get_alloc(mst, MTYPE_CLUSTER))) vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct cluster_list)), VTY_NEWLINE); /* Peer related usage */ - count = mtype_stats_alloc (MTYPE_BGP_PEER); + count = mem_get_alloc(mst, MTYPE_BGP_PEER); vty_out (vty, "%ld peers, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct peer)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) + if ((count = mem_get_alloc(mst, MTYPE_PEER_GROUP))) vty_out (vty, "%ld peer groups, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct peer_group)), VTY_NEWLINE); /* Other */ - if ((count = mtype_stats_alloc (MTYPE_HASH))) + if ((count = mem_get_alloc(mst, MTYPE_HASH))) vty_out (vty, "%ld hash tables, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct hash)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) + if ((count = mem_get_alloc(mst, MTYPE_HASH_BACKET))) vty_out (vty, "%ld hash buckets, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (struct hash_backet)), VTY_NEWLINE); - if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) + if ((count = mem_get_alloc(mst, MTYPE_BGP_REGEXP))) vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, mtype_memstr (memstrbuf, sizeof (memstrbuf), count * sizeof (regex_t)), @@ -9040,37 +9071,50 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, /* BGP node structure. */ static struct cmd_node bgp_node = { - BGP_NODE, - "%s(config-router)# ", - 1, + .node = BGP_NODE, + .prompt = "%s(config-router)# ", + + .config_to_vtysh = true, }; static struct cmd_node bgp_ipv4_unicast_node = { - BGP_IPV4_NODE, - "%s(config-router-af)# ", - 1, + .node = BGP_IPV4_NODE, + .prompt = "%s(config-router-af)# ", + + .parent = BGP_NODE, + + .config_to_vtysh = true, }; static struct cmd_node bgp_ipv4_multicast_node = { - BGP_IPV4M_NODE, - "%s(config-router-af)# ", - 1, + .node = BGP_IPV4M_NODE, + .prompt = "%s(config-router-af)# ", + + .parent = BGP_NODE, + + .config_to_vtysh = true, }; static struct cmd_node bgp_ipv6_unicast_node = { - BGP_IPV6_NODE, - "%s(config-router-af)# ", - 1, + .node = BGP_IPV6_NODE, + .prompt = "%s(config-router-af)# ", + + .parent = BGP_NODE, + + .config_to_vtysh = true, }; static struct cmd_node bgp_ipv6_multicast_node = { - BGP_IPV6M_NODE, - "%s(config-router-af)# ", - 1, + .node = BGP_IPV6M_NODE, + .prompt = "%s(config-router-af)# ", + + .parent = BGP_NODE, + + .config_to_vtysh = true, }; static struct cmd_node bgp_vpnv4_node = @@ -9788,10 +9832,12 @@ bgp_vty_init (void) /* address-family commands. */ install_element (BGP_NODE, &address_family_ipv4_cmd); - install_element (BGP_NODE, &address_family_ipv4_safi_cmd); + install_element (BGP_NODE, &address_family_ipv4_safi_unicast_cmd); + install_element (BGP_NODE, &address_family_ipv4_safi_multicast_cmd); #ifdef HAVE_IPV6 install_element (BGP_NODE, &address_family_ipv6_cmd); - install_element (BGP_NODE, &address_family_ipv6_safi_cmd); + install_element (BGP_NODE, &address_family_ipv6_safi_unicast_cmd); + install_element (BGP_NODE, &address_family_ipv6_safi_multicast_cmd); #endif /* HAVE_IPV6 */ install_element (BGP_NODE, &address_family_vpnv4_cmd); install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); @@ -10564,7 +10610,7 @@ DEFUN (show_ip_community_list, { struct symbol_table* table; vector extract ; - vector_index i ; + vector_index_t i ; struct symbol* sym ; struct community_list *list; @@ -10923,7 +10969,7 @@ DEFUN (show_ip_extcommunity_list, { struct symbol_table* table; vector extract ; - vector_index i ; + vector_index_t i ; struct symbol* sym ; struct community_list *list; @@ -10994,7 +11040,7 @@ community_list_config_write_list(struct vty* vty, int what) struct community_list *list; struct community_entry *entry; vector extract ; - vector_index i ; + vector_index_t i ; struct symbol* sym ; int write = 0; diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index ff601ba1..5a5eab83 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -19,6 +19,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <zebra.h> +#include "misc.h" #include "prefix.h" #include "thread.h" @@ -4864,7 +4865,7 @@ bgp_init (void) * */ void -bgp_terminate (int terminating, int retain_mode) +bgp_terminate (bool terminating, bool retain_mode) { struct bgp *bgp; struct peer *peer; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index dad3360e..f20d8315 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -21,7 +21,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGPD_H #define _QUAGGA_BGPD_H -#include "stdbool.h" +#include "misc.h" #include "bgpd/bgp_common.h" #include "bgpd/bgp_notification.h" @@ -445,15 +445,15 @@ bgp_clock(void) * Clock time calculated now may differ from any logged Wall Clock times !! */ Inline time_t -bgp_wall_clock(time_t bgp_time) +bgp_wall_clock(time_t mono) { - return time(NULL) + (bgp_time - bgp_clock()) ; + return time(NULL) - (bgp_clock() - mono) ; } ; /*------------------------------------------------------------------------------ * Prototypes. */ -extern void bgp_terminate (int, int); +extern void bgp_terminate (bool, bool); extern void bgp_reset (void); extern void bgp_zclient_reset (void); /* See bgp_zebra ! */ |