diff options
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp.h | 2 | ||||
-rw-r--r-- | bgpd/bgp_advertise.h | 4 | ||||
-rw-r--r-- | bgpd/bgp_aspath.h | 5 | ||||
-rw-r--r-- | bgpd/bgp_clist.c | 8 | ||||
-rw-r--r-- | bgpd/bgp_common.h | 7 | ||||
-rw-r--r-- | bgpd/bgp_connection.h | 6 | ||||
-rw-r--r-- | bgpd/bgp_engine.h | 6 | ||||
-rw-r--r-- | bgpd/bgp_msg_write.h | 3 | ||||
-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_index.c | 22 | ||||
-rw-r--r-- | bgpd/bgp_route_refresh.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_route_refresh.h | 12 | ||||
-rw-r--r-- | bgpd/bgp_session.h | 6 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 23 |
17 files changed, 67 insertions, 87 deletions
@@ -30,7 +30,7 @@ #define _GMCH_BGP_H "19-Dec-2009" -#include <stdint.h> +#include "misc.h" #include "confirm.h" /*############################################################################## 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 895379aa..c02a84aa 100644 --- a/bgpd/bgp_aspath.h +++ b/bgpd/bgp_aspath.h @@ -21,10 +21,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #ifndef _QUAGGA_BGP_ASPATH_H #define _QUAGGA_BGP_ASPATH_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_clist.c b/bgpd/bgp_clist.c index 1d847ee4..0df34bb0 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.h b/bgpd/bgp_common.h index 0d2395ed..fb695125 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.h b/bgpd/bgp_connection.h index 79270bd8..8c5e00d4 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_engine.h b/bgpd/bgp_engine.h index ceec1b2f..7e3cceec 100644 --- a/bgpd/bgp_engine.h +++ b/bgpd/bgp_engine.h @@ -22,16 +22,14 @@ #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 -#endif - enum { qdebug = #ifdef QDEBUG 1 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.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 62d76c60..9a5aaf30 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -776,7 +776,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; @@ -1837,7 +1837,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; @@ -1852,11 +1852,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_index.c b/bgpd/bgp_peer_index.c index 518a22bc..10d53f62 100644 --- a/bgpd/bgp_peer_index.c +++ b/bgpd/bgp_peer_index.c @@ -59,7 +59,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 +112,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 +149,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 +204,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 +213,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 +241,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 +288,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 +340,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 +375,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 +424,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_refresh.c b/bgpd/bgp_route_refresh.c index 5c2b6e5c..7a8d5df5 100644 --- a/bgpd/bgp_route_refresh.c +++ b/bgpd/bgp_route_refresh.c @@ -60,7 +60,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 +74,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 +130,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_session.h b/bgpd/bgp_session.h index ccc7a28e..e1a4c51b 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. * diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 222e4485..b8af6140 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10365,8 +10365,9 @@ 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; table = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); if (table == NULL) @@ -10375,7 +10376,11 @@ DEFUN (show_ip_community_list, extract = symbol_table_extract(table, NULL, NULL, 0, symbol_mixed_name_cmp) ; for (VECTOR_ITEMS(extract, sym, i)) - community_list_show (vty, symbol_get_value(sym)); + { + list = symbol_get_value(sym) ; + if (list != NULL) + community_list_show (vty, list) ; + } vector_free(extract) ; /* discard temporary vector */ @@ -10719,7 +10724,7 @@ DEFUN (show_ip_extcommunity_list, { struct symbol_table* table; vector extract ; - vector_index i ; + vector_index_t i ; struct symbol* sym ; table = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); @@ -10729,7 +10734,11 @@ DEFUN (show_ip_extcommunity_list, extract = symbol_table_extract(table, NULL, NULL, 0, symbol_mixed_name_cmp) ; for (VECTOR_ITEMS(extract, sym, i)) - extcommunity_list_show (vty, symbol_get_value(sym)); + { + list = symbol_get_value(sym) ; + if (list != NULL) + extcommunity_list_show (vty, list) ; + } vector_free(extract) ; /* discard temporary vector */ @@ -10785,7 +10794,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; @@ -10796,6 +10805,10 @@ community_list_config_write_list(struct vty* vty, int what) for (VECTOR_ITEMS(extract, sym, i)) { list = symbol_get_value(sym) ; + + if (list == NULL) + continue ; + for (entry = list->head; entry; entry = entry->next) { const char* list_type = "" ; |