diff options
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_connection.c | 3 | ||||
-rw-r--r-- | bgpd/bgp_debug.c | 38 | ||||
-rw-r--r-- | bgpd/bgp_engine.h | 30 | ||||
-rw-r--r-- | bgpd/bgp_main.c | 27 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 5 | ||||
-rw-r--r-- | bgpd/bgp_peer.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 18 | ||||
-rw-r--r-- | bgpd/bgp_session.c | 4 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 77 | ||||
-rw-r--r-- | bgpd/bgpd.c | 3 | ||||
-rw-r--r-- | bgpd/bgpd.h | 4 |
12 files changed, 121 insertions, 92 deletions
diff --git a/bgpd/bgp_connection.c b/bgpd/bgp_connection.c index 0bdd4f3d..151d3309 100644 --- a/bgpd/bgp_connection.c +++ b/bgpd/bgp_connection.c @@ -22,6 +22,7 @@ #include "bgpd/bgp_connection.h" #include <zebra.h> +#include "misc.h" #include "bgpd/bgpd.h" #include "bgpd/bgp_fsm.h" @@ -685,7 +686,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_debug.c b/bgpd/bgp_debug.c index c4cf9cf6..f7494f19 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_STR "BGP AS4 aspath segment handling\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_ON (as4, AS4_SEGMENT); else { @@ -428,7 +428,7 @@ DEFUN (no_debug_bgp_as4_segment, BGP_STR "BGP AS4 aspath segment handling\n") { - if (vty_get_node(vty) == CONFIG_NODE) + if (vty->node == CONFIG_NODE) DEBUG_OFF (as4, AS4_SEGMENT); else { @@ -453,7 +453,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 { @@ -471,7 +471,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_engine.h b/bgpd/bgp_engine.h index 7e3cceec..bedfc18e 100644 --- a/bgpd/bgp_engine.h +++ b/bgpd/bgp_engine.h @@ -30,13 +30,25 @@ #include "lib/qpnexus.h" #include "lib/log.h" -enum { qdebug = -#ifdef QDEBUG - 1 +/*============================================================================== + * DEBUG setting + */ + +#ifdef BGP_ENGINE_DEBUG /* Can be forced from outside */ +# if BGP_ENGINE_DEBUG +# define BGP_ENGINE_DEBUG 1 /* Force 1 or 0 */ #else - 0 +# define BGP_ENGINE_DEBUG 0 +# endif +#else +# ifdef QDEBUG +# define BGP_ENGINE_DEBUG 1 /* Follow QDEBUG */ +#else +# define BGP_ENGINE_DEBUG 0 +# endif #endif -}; + +enum { bgp_engine_debug = BGP_ENGINE_DEBUG } ; /*============================================================================== * @@ -117,10 +129,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) ; } ; @@ -131,10 +143,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..6bbc8197 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -240,14 +240,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(); } @@ -301,6 +304,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; @@ -366,10 +370,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"); @@ -744,16 +748,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 +812,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_packet.c b/bgpd/bgp_packet.c index 9a5aaf30..54a47b06 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -173,9 +173,10 @@ bgp_update_packet (struct peer *peer, afi_t afi, safi_t safi) if (rn->prn) prd = (struct prefix_rd *) &rn->prn->p; - if (binfo && binfo->extra) + if (binfo) { - tag = binfo->extra->tag; + if (binfo->extra) + tag = binfo->extra->tag; from = binfo->peer; } diff --git a/bgpd/bgp_peer.c b/bgpd/bgp_peer.c index 3a1eb71f..59c9a8da 100644 --- a/bgpd/bgp_peer.c +++ b/bgpd/bgp_peer.c @@ -466,7 +466,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_route.c b/bgpd/bgp_route.c index 4d69badb..c9281ca9 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -5033,7 +5033,7 @@ DEFUN (bgp_network_mask_natural_backdoor, ALIAS (bgp_network_mask_natural_backdoor, bgp_network_mask_natural_backdoor_ttl_cmd, - "network A.B.C.D backdoor pathlimit (1-255>", + "network A.B.C.D backdoor pathlimit <1-255>", "Specify a network to announce via BGP\n" "Network number\n" "Specify a BGP backdoor route\n" diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index f40d057d..ebc37e0d 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -3065,7 +3065,7 @@ DEFUN (set_metric, ALIAS (set_metric, set_metric_addsub_cmd, - "set metric <+/-metric>", + "set metric <+/-32b>", SET_STR "Metric value for destination routing protocol\n" "Add or subtract metric\n") @@ -3155,11 +3155,11 @@ ALIAS (no_set_weight, DEFUN (set_aspath_prepend, set_aspath_prepend_cmd, - "set as-path prepend ." CMD_AS_RANGE, + "set as-path prepend .ASs", SET_STR "Transform BGP AS_PATH attribute\n" "Prepend to the as-path\n" - "AS number\n") + "AS number(s)\n") { int ret; char *str; @@ -3193,20 +3193,20 @@ 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 .ASs", NO_STR SET_STR "Transform BGP AS_PATH attribute\n" "Prepend to the as-path\n" - "AS number\n") + "AS number(s)\n") DEFUN (set_aspath_exclude, set_aspath_exclude_cmd, - "set as-path exclude ." CMD_AS_RANGE, + "set as-path exclude .ASs", SET_STR "Transform BGP AS-path attribute\n" "Exclude from the as-path\n" - "AS number\n") + "AS number(s)\n") { int ret; char *str; @@ -3239,12 +3239,12 @@ 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 .ASs", NO_STR SET_STR "Transform BGP AS_PATH attribute\n" "Exclude from the as-path\n" - "AS number\n") + "AS number(s)\n") DEFUN (set_community, set_community_cmd, diff --git a/bgpd/bgp_session.c b/bgpd/bgp_session.c index a734ba99..681075da 100644 --- a/bgpd/bgp_session.c +++ b/bgpd/bgp_session.c @@ -461,7 +461,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; @@ -517,7 +517,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_vty.c b/bgpd/bgp_vty.c index 23d39b85..9195b9f3 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; } @@ -352,7 +348,7 @@ DEFUN (router_bgp, return CMD_WARNING; } - vty_set_node(vty, BGP_NODE) ; + vty->node = BGP_NODE ; vty->index = bgp; return CMD_SUCCESS; @@ -601,7 +597,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" @@ -631,7 +627,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" @@ -4018,7 +4014,7 @@ DEFUN (address_family_ipv4, "Enter Address Family command mode\n" "Address family\n") { - vty_set_node(vty, BGP_IPV4_NODE) ; + vty->node = BGP_IPV4_NODE ; return CMD_SUCCESS; } @@ -4031,9 +4027,9 @@ DEFUN (address_family_ipv4_safi, "Address Family modifier\n") { if (strncmp (argv[0], "m", 1) == 0) - vty_set_node(vty, BGP_IPV4M_NODE) ; + vty->node = BGP_IPV4M_NODE ; else - vty_set_node(vty, BGP_IPV4_NODE) ; + vty->node = BGP_IPV4_NODE ; return CMD_SUCCESS; } @@ -4044,7 +4040,7 @@ DEFUN (address_family_ipv6, "Enter Address Family command mode\n" "Address family\n") { - vty_set_node(vty, BGP_IPV6_NODE) ; + vty->node = BGP_IPV6_NODE ; return CMD_SUCCESS; } @@ -4057,9 +4053,9 @@ DEFUN (address_family_ipv6_safi, "Address Family modifier\n") { if (strncmp (argv[0], "m", 1) == 0) - vty_set_node(vty, BGP_IPV6M_NODE) ; + vty->node = BGP_IPV6M_NODE ; else - vty_set_node(vty, BGP_IPV6_NODE) ; + vty->node = BGP_IPV6_NODE ; return CMD_SUCCESS; } @@ -4070,7 +4066,7 @@ DEFUN (address_family_vpnv4, "Enter Address Family command mode\n" "Address family\n") { - vty_set_node(vty, BGP_VPNV4_NODE) ; + vty->node = BGP_VPNV4_NODE ; return CMD_SUCCESS; } @@ -4086,14 +4082,14 @@ DEFUN (exit_address_family, "exit-address-family", "Exit from Address Family configuration mode\n") { - enum node_type node = vty_get_node(vty) ; + node_type_t node = vty->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); + vty->node = BGP_NODE ; return CMD_SUCCESS; } @@ -8869,37 +8865,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 = diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 79aad2cb..c2d69bd2 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" @@ -4691,7 +4692,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 ee8efa1b..12a01450 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" @@ -410,7 +410,7 @@ extern qpn_nexus bgp_nexus; extern qpn_nexus routing_nexus; /* 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 ! */ |