From f9956b9524ddafdb9d0cec042213eaa8229aad8c Mon Sep 17 00:00:00 2001 From: Chris Hall Date: Tue, 29 Mar 2011 01:49:16 +0100 Subject: Bring "ex" version up to date with 0.99.18 Release: 0.99.18ex15p -- Pipework Branch Also fixes issue with unknown attributes -- does not release them prematurely. Contains the "bgpd: New show commands for improved view and address family support", which is post 0.99.18. (But not RFC 5082 GTSM.) --- lib/command.c | 7 +- lib/command.h | 3 + lib/command_parse.h | 1 - lib/command_queue.c | 2 - lib/distribute.c | 13 +- lib/elstring.c | 2 +- lib/errno_names.c | 2 +- lib/getopt.c | 4 - lib/getopt1.c | 4 - lib/hash.c | 11 + lib/hash.h | 2 + lib/if.c | 18 + lib/if.h | 1 + lib/if_rmap.c | 9 +- lib/keystroke.c | 12 +- lib/list_util.c | 2 +- lib/log.c | 11 +- lib/log.h | 1 - lib/memory.c | 25 +- lib/memory.h | 2 +- lib/misc.h | 22 +- lib/mqueue.c | 4 +- lib/network.c | 2 - lib/prefix.c | 13 +- lib/prefix.h | 4 +- lib/privs.c | 1 - lib/pthread_safe.c | 81 ++- lib/pthread_safe.h | 12 +- lib/qfstring.c | 311 ++++++---- lib/qfstring.h | 112 +++- lib/qiovec.c | 3 +- lib/qlib_init.c | 2 +- lib/qpath.c | 2 +- lib/qpthreads.h | 2 - lib/qrand.c | 2 +- lib/qstring.c | 2 +- lib/qtime.c | 104 ++-- lib/qtime.h | 28 + lib/qtimers.c | 5 +- lib/regex.c | 51 +- lib/sockopt.c | 9 +- lib/sockunion.c | 1 + lib/stream.c | 2 +- lib/table.c | 14 +- lib/thread.c | 153 ++++- lib/thread.h | 3 +- lib/vector.c | 2 +- lib/vio_fifo.c | 1683 ++++++++++++++++++++------------------------------- lib/vio_fifo.h | 172 +++--- lib/vio_lines.c | 1 - lib/vty.c | 1 - lib/vty_cli.c | 12 +- lib/vty_command.c | 8 +- lib/vty_io.c | 17 +- lib/vty_io_basic.c | 2 +- lib/vty_io_file.c | 8 +- lib/vty_io_term.c | 12 +- lib/vty_log.c | 2 +- lib/workqueue.c | 31 +- lib/workqueue.h | 2 +- lib/zassert.h | 2 +- lib/zclient.c | 6 +- lib/zclient.h | 9 +- lib/zconfig.h | 12 +- lib/zebra.h | 2 +- 65 files changed, 1568 insertions(+), 1493 deletions(-) (limited to 'lib') diff --git a/lib/command.c b/lib/command.c index 61f554bb..1fc85344 100644 --- a/lib/command.c +++ b/lib/command.c @@ -21,10 +21,8 @@ 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 "zconfig.h" -#include "version.h" - #include "misc.h" +#include "version.h" #include #include @@ -58,7 +56,7 @@ vector node_vector = NULL ; /*============================================================================== * Default motd string. */ -const char* default_motd = +static const char* default_motd = "\n" "Hello, this is " QUAGGA_PROGNAME " (version " QUAGGA_VERSION ")\n" QUAGGA_COPYRIGHT "\n" @@ -2287,6 +2285,7 @@ cmd_init (bool terminal) install_element (RESTRICTED_NODE, &show_thread_cpu_cmd); install_element (VIEW_NODE, &show_thread_cpu_cmd); install_element (ENABLE_NODE, &show_thread_cpu_cmd); + install_element (ENABLE_NODE, &clear_thread_cpu_cmd); install_element (VIEW_NODE, &show_work_queues_cmd); install_element (ENABLE_NODE, &show_work_queues_cmd); } ; diff --git a/lib/command.h b/lib/command.h index 2b835cc8..3ad758d5 100644 --- a/lib/command.h +++ b/lib/command.h @@ -59,6 +59,9 @@ .r_doc = NULL, \ } ; +/* Legacy name for cmd_command */ +#define cmd_element cmd_command + #define DEFUN_CMD_FUNC_DECL(funcname) \ static cmd_function funcname; diff --git a/lib/command_parse.h b/lib/command_parse.h index a1e801ce..5f17d083 100644 --- a/lib/command_parse.h +++ b/lib/command_parse.h @@ -24,7 +24,6 @@ #ifndef _ZEBRA_COMMAND_PARSE_H #define _ZEBRA_COMMAND_PARSE_H -#include "zconfig.h" /* HAVE_IPV6 */ #include "misc.h" #include "command_common.h" diff --git a/lib/command_queue.c b/lib/command_queue.c index f83e3291..7946d0e8 100644 --- a/lib/command_queue.c +++ b/lib/command_queue.c @@ -18,8 +18,6 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - -#include "zconfig.h" /* for CONSUMED_TIME_CHECK */ #include "misc.h" #include "qpnexus.h" diff --git a/lib/distribute.c b/lib/distribute.c index 0e1c9458..8c0f057e 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -115,16 +115,11 @@ distribute_get (const char *ifname) } static unsigned int -distribute_hash_make (struct distribute *dist) +distribute_hash_make (void *arg) { - unsigned int i, key; + const struct distribute *dist = arg; - key = 0; - if (dist->ifname) - for (i = 0; i < strlen (dist->ifname); i++) - key += dist->ifname[i]; - - return key; + return dist->ifname ? string_hash_make (dist->ifname) : 0; } /* If two distribute-list have same value then return 1 else return @@ -764,7 +759,7 @@ distribute_list_reset () void distribute_list_init (int node) { - disthash = hash_create ((unsigned int (*) (void *)) distribute_hash_make, + disthash = hash_create (distribute_hash_make, (int (*) (const void *, const void *)) distribute_cmp); if(node==RIP_NODE) { diff --git a/lib/elstring.c b/lib/elstring.c index 41fc88ed..64756a64 100644 --- a/lib/elstring.c +++ b/lib/elstring.c @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - +#include "misc.h" #include #include "elstring.h" diff --git a/lib/errno_names.c b/lib/errno_names.c index 7238f1a7..3c1ff23c 100644 --- a/lib/errno_names.c +++ b/lib/errno_names.c @@ -18,8 +18,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include "misc.h" -#include #include #include diff --git a/lib/getopt.c b/lib/getopt.c index ec98feac..75cf7c8b 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -30,10 +30,6 @@ # define _NO_PROTO #endif -#ifdef HAVE_CONFIG_H -# include -#endif - #include "zebra.h" #include diff --git a/lib/getopt1.c b/lib/getopt1.c index dc36fd0e..d5514c33 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c @@ -20,10 +20,6 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include "zebra.h" #include "getopt.h" diff --git a/lib/hash.c b/lib/hash.c index 672327ec..6db79ea7 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -101,6 +101,17 @@ hash_lookup (struct hash *hash, void *data) return hash_get (hash, data, NULL); } +/* Simple Bernstein hash which is simple and fast for common case */ +unsigned int string_hash_make (const char *str) +{ + unsigned int hash = 0; + + while (*str) + hash = (hash * 33) ^ (unsigned int) *str++; + + return hash; +} + /* This function release registered value from specified hash. When release is successfully finished, return the data pointer in the hash backet. */ diff --git a/lib/hash.h b/lib/hash.h index f4b1c23e..4cb772e5 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -70,4 +70,6 @@ extern void hash_iterate (struct hash *, extern void hash_clean (struct hash *, void (*) (void *)); extern void hash_free (struct hash *); +extern unsigned int string_hash_make (const char *); + #endif /* _ZEBRA_HASH_H */ diff --git a/lib/if.c b/lib/if.c index 21427e71..23d35054 100644 --- a/lib/if.c +++ b/lib/if.c @@ -879,3 +879,21 @@ if_init (void) memset (&if_master, 0, sizeof if_master); } + +void +if_terminate (void) +{ + for (;;) + { + struct interface *ifp; + + ifp = listnode_head (iflist); + if (ifp == NULL) + break; + + if_delete (ifp); + } + + list_delete (iflist); + iflist = NULL; +} diff --git a/lib/if.h b/lib/if.h index b4b83cd5..f89f488b 100644 --- a/lib/if.h +++ b/lib/if.h @@ -266,6 +266,7 @@ extern int if_is_pointopoint (struct interface *); extern int if_is_multicast (struct interface *); extern void if_add_hook (int, int (*)(struct interface *)); extern void if_init (void); +extern void if_terminate (void); extern void if_dump_all (void); extern const char *if_flag_dump(unsigned long); diff --git a/lib/if_rmap.c b/lib/if_rmap.c index 9ef5ed94..e51f1fe5 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -110,14 +110,9 @@ if_rmap_get (const char *ifname) static unsigned int if_rmap_hash_make (void *data) { - struct if_rmap *if_rmap = data; - unsigned int i, key; + const struct if_rmap *if_rmap = data; - key = 0; - for (i = 0; i < strlen (if_rmap->ifname); i++) - key += if_rmap->ifname[i]; - - return key; + return string_hash_make (if_rmap->ifname); } static int diff --git a/lib/keystroke.c b/lib/keystroke.c index 8325b8f8..2b5d8128 100644 --- a/lib/keystroke.c +++ b/lib/keystroke.c @@ -19,8 +19,7 @@ * Boston, MA 02111-1307, USA. */ -#include -#include +#include "misc.h" #include "keystroke.h" @@ -28,7 +27,6 @@ #include "memory.h" #include "mqueue.h" -#include "zassert.h" /*============================================================================== */ @@ -274,7 +272,7 @@ typedef struct keystroke_state keystroke_state_t ; struct keystroke_stream { - vio_fifo_t fifo ; /* the keystrokes -- embedded */ + vio_fifo fifo ; /* the keystrokes */ keystroke_callback* iac_callback ; void* iac_callback_context ; @@ -373,7 +371,7 @@ keystroke_stream_new(uint8_t csi_char, keystroke_callback* iac_callback, stream->iac_callback = iac_callback ; stream->iac_callback_context = iac_callback_context ; - vio_fifo_init_new(stream->fifo, keystroke_buffer_len) ; + stream->fifo = vio_fifo_new(keystroke_buffer_len) ; stream->CSI = (csi_char != '\0') ? csi_char : 0x1B ; @@ -390,7 +388,7 @@ keystroke_stream_free(keystroke_stream stream) { if (stream != NULL) { - vio_fifo_reset(stream->fifo, keep_it) ; + stream->fifo = vio_fifo_free(stream->fifo) ; XFREE(MTYPE_KEY_STREAM, stream) ; } ; @@ -446,7 +444,7 @@ keystroke_stream_eof(keystroke_stream stream) extern void keystroke_stream_set_eof(keystroke_stream stream, bool timed_out) { - vio_fifo_reset(stream->fifo, keep_it) ; + vio_fifo_clear(stream->fifo, true) ; /* and clear marks */ stream->eof_met = true ; /* essential information */ stream->timed_out = timed_out ; /* variant of eof */ diff --git a/lib/list_util.c b/lib/list_util.c index f73244a4..0f7e8a02 100644 --- a/lib/list_util.c +++ b/lib/list_util.c @@ -18,7 +18,7 @@ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ - +#include "misc.h" #include "list_util.h" /*============================================================================== diff --git a/lib/log.c b/lib/log.c index e3296d3a..d78c795e 100644 --- a/lib/log.c +++ b/lib/log.c @@ -306,6 +306,8 @@ zlog (struct zlog *zl, int priority, const char *format, ...) /*------------------------------------------------------------------------------ * Preparation of line to send to logging: file, stdout or "monitor" terminals. + * + * Line ends in '\n', but no terminating '\0'. */ static void uvzlog_line(logline ll, struct zlog *zl, int priority, @@ -314,7 +316,7 @@ uvzlog_line(logline ll, struct zlog *zl, int priority, const char* q ; qf_str_t qfs ; - qfs_init(qfs, ll->line, sizeof(ll->line) - 1) ; /* leave space for '\n' */ + qfs_init(qfs, ll->line, sizeof(ll->line)) ; /* "