diff options
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_msg_read.c | 12 | ||||
-rw-r--r-- | bgpd/bgp_network.c | 45 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 4 |
3 files changed, 43 insertions, 18 deletions
diff --git a/bgpd/bgp_msg_read.c b/bgpd/bgp_msg_read.c index e8a2897e..7e55bf70 100644 --- a/bgpd/bgp_msg_read.c +++ b/bgpd/bgp_msg_read.c @@ -617,7 +617,12 @@ bgp_msg_open_option_parse (bgp_connection connection, bgp_notify notification, opt_type = suck_b(sr); opt_length = suck_b(sr); left -= opt_length ; - } ; + } + else + { + opt_type = 0 ; /* ensure initialised */ + opt_length = 0 ; + } /* Must not have exceeded available bytes */ if (left < 0) @@ -1569,6 +1574,11 @@ bgp_msg_orf_recv(bgp_connection connection, bgp_route_refresh rr, { orf_type = suck_b(sr) ; orf_len = suck_w(sr) ; + } + else + { + orf_type = 0 ; /* ensure initialised */ + orf_len = 0 ; } ; /* The length may not be zero and may not exceed what there is left */ diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 710dc51e..77c89ff3 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -83,17 +83,9 @@ bgp_md5_set_listeners(union sockunion* su, const char* password) ; typedef struct bgp_listener* bgp_listener ; -static bgp_listener bgp_listeners[] = - { - [AF_INET] = NULL, -#if HAVE_IPV6 - [AF_INET6] = NULL -#endif - } ; - -CONFIRM(AF_INET < 20) ; /* The bgp_listeners array is not a silly size */ -#if HAVE_IPV6 -CONFIRM(AF_INET6 < 20) ; /* The bgp_listeners array is not a silly size */ +static bgp_listener bgp_listeners_inet = NULL ; +#ifdef HAVE_IPV6 +static bgp_listener bgp_listeners_inet6 = NULL ; #endif #if defined(HAVE_IPV6) && !defined(NRL) @@ -110,6 +102,25 @@ struct bgp_listener union sockunion su ; } ; +/* Get pointer to list base for listeners in the given address family. */ +static inline +bgp_listener* bgp_listeners(sa_family_t family) +{ + switch (family) + { + case AF_INET: + return &bgp_listeners_inet ; + +#ifdef HAVE_IPV6 + case AF_INET6: + return &bgp_listeners_inet6 ; + +#endif + default: + zabort("invalid address family") ; + } ; +} + /* Forward reference */ static int bgp_open_listeners_addrinfo(const char* address, unsigned short port) ; @@ -412,8 +423,8 @@ bgp_open_listener(sockunion su, unsigned short port, sockunion_copy(&listener->su, su) ; - listener->next = bgp_listeners[sockunion_family(su)] ; - bgp_listeners[sockunion_family(su)] = listener ; + listener->next = *bgp_listeners(sockunion_family(su)) ; + *bgp_listeners(sockunion_family(su)) = listener ; return 0 ; } ; @@ -429,8 +440,10 @@ static void bgp_reset_listeners(bgp_listener* p_listener) ; extern void bgp_close_listeners(void) { - bgp_reset_listeners(&bgp_listeners[AF_INET]) ; - bgp_reset_listeners(&bgp_listeners[AF_INET6]) ; + bgp_reset_listeners(bgp_listeners(AF_INET)) ; +#ifdef HAVE_IPV6 + bgp_reset_listeners(bgp_listeners(AF_INET6)) ; +#endif } ; static void @@ -1089,7 +1102,7 @@ bgp_md5_set_listeners(union sockunion* su, const char* password) assert(su->sa.sa_family == AF_INET) ; #endif - listener = bgp_listeners[su->sa.sa_family] ; + listener = *bgp_listeners(su->sa.sa_family) ; while (listener != NULL) { diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 875ff648..6553b3ff 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1570,7 +1570,7 @@ bgp_process_main (struct work_queue *wq, work_queue_item item) struct bgp_node *rn ; afi_t afi ; safi_t safi ; - struct prefix *p = &rn->p; + struct prefix *p ; struct bgp_info *new_select; struct bgp_info *old_select; struct bgp_info_pair old_and_new; @@ -1591,6 +1591,8 @@ bgp_process_main (struct work_queue *wq, work_queue_item item) afi = rn->table->afi; safi = rn->table->safi; + p = &rn->p ; + /* Best path selection. */ bgp_best_selection (bgp, rn, &old_and_new); old_select = old_and_new.old; |