summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_vty.c')
-rw-r--r--bgpd/bgp_vty.c923
1 files changed, 520 insertions, 403 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index e7e7dba1..48d8ecbe 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -32,6 +32,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "hash.h"
#include "bgpd/bgpd.h"
+#include "bgpd/bgp_peer.h"
#include "bgpd/bgp_advertise.h"
#include "bgpd/bgp_attr.h"
#include "bgpd/bgp_aspath.h"
@@ -48,6 +49,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_zebra.h"
#include "bgpd/bgp_table.h"
#include "bgpd/bgp_vty.h"
+#include "bgpd/bgp_session.h"
extern struct in_addr router_id_zebra;
@@ -55,7 +57,9 @@ extern struct in_addr router_id_zebra;
afi_t
bgp_node_afi (struct vty *vty)
{
- if (vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE)
+ enum node_type node = vty_get_node(vty) ;
+
+ if (node == BGP_IPV6_NODE || node == BGP_IPV6M_NODE)
return AFI_IP6;
return AFI_IP;
}
@@ -65,9 +69,11 @@ bgp_node_afi (struct vty *vty)
safi_t
bgp_node_safi (struct vty *vty)
{
- if (vty->node == BGP_VPNV4_NODE)
+ enum node_type node = vty_get_node(vty) ;
+
+ if (node == BGP_VPNV4_NODE)
return SAFI_MPLS_VPN;
- if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
+ if (node == BGP_IPV4M_NODE || node == BGP_IPV6M_NODE)
return SAFI_MULTICAST;
return SAFI_UNICAST;
}
@@ -213,7 +219,9 @@ bgp_vty_return (struct vty *vty, int ret)
case BGP_ERR_TCPSIG_FAILED:
str = "Error while applying TCP-Sig to session(s)";
break;
- case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
+ case BGP_ERR_PEER_EXISTS:
+ str = "Cannot have the same neighbor in different bgp views";
+ case BGP_ERR_NO_EBGP_MULTIHOP_WITH_GTSM:
str = "ebgp-multihop and ttl-security cannot be configured together";
break;
case BGP_ERR_NO_IBGP_WITH_TTLHACK:
@@ -313,10 +321,10 @@ DEFUN_DEPRECATED (neighbor_version,
{
return CMD_SUCCESS;
}
-
+
/* "router bgp" commands. */
-DEFUN (router_bgp,
- router_bgp_cmd,
+DEFUN (router_bgp,
+ router_bgp_cmd,
"router bgp " CMD_AS_RANGE,
ROUTER_STR
BGP_STR
@@ -336,7 +344,7 @@ DEFUN (router_bgp,
switch (ret)
{
case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
- vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
+ vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
VTY_NEWLINE);
return CMD_WARNING;
case BGP_ERR_AS_MISMATCH:
@@ -349,7 +357,7 @@ DEFUN (router_bgp,
return CMD_WARNING;
}
- vty->node = BGP_NODE;
+ vty_set_node(vty, BGP_NODE) ;
vty->index = bgp;
return CMD_SUCCESS;
@@ -363,7 +371,7 @@ ALIAS (router_bgp,
AS_STR
"BGP view\n"
"view name\n")
-
+
/* "no router bgp" commands. */
DEFUN (no_router_bgp,
no_router_bgp_cmd,
@@ -404,7 +412,7 @@ ALIAS (no_router_bgp,
AS_STR
"BGP view\n"
"view name\n")
-
+
/* BGP router-id. */
DEFUN (bgp_router_id,
@@ -475,7 +483,7 @@ ALIAS (no_bgp_router_id,
BGP_STR
"Override configured router identifier\n"
"Manually configured router identifier\n")
-
+
/* BGP Cluster ID. */
DEFUN (bgp_cluster_id,
@@ -545,7 +553,7 @@ ALIAS (no_bgp_cluster_id,
BGP_STR
"Configure Route-Reflector Cluster-id\n"
"Route-Reflector Cluster-id in IP address format\n")
-
+
DEFUN (bgp_confederation_identifier,
bgp_confederation_identifier_cmd,
"bgp confederation identifier " CMD_AS_RANGE,
@@ -595,7 +603,7 @@ ALIAS (no_bgp_confederation_identifier,
"AS confederation parameters\n"
"AS number\n"
"Set routing domain confederation AS\n")
-
+
DEFUN (bgp_confederation_peers,
bgp_confederation_peers_cmd,
"bgp confederation peers ." CMD_AS_RANGE,
@@ -649,7 +657,7 @@ DEFUN (no_bgp_confederation_peers,
}
return CMD_SUCCESS;
}
-
+
/* BGP timers. */
DEFUN (bgp_timers,
@@ -705,7 +713,7 @@ ALIAS (no_bgp_timers,
"BGP timers\n"
"Keepalive interval\n"
"Holdtime\n")
-
+
DEFUN (bgp_client_to_client_reflection,
bgp_client_to_client_reflection_cmd,
"bgp client-to-client reflection",
@@ -762,7 +770,7 @@ DEFUN (no_bgp_always_compare_med,
bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
return CMD_SUCCESS;
}
-
+
/* "bgp deterministic-med" configuration. */
DEFUN (bgp_deterministic_med,
bgp_deterministic_med_cmd,
@@ -893,7 +901,7 @@ DEFUN (no_bgp_fast_external_failover,
bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
return CMD_SUCCESS;
}
-
+
/* "bgp enforce-first-as" configuration. */
DEFUN (bgp_enforce_first_as,
bgp_enforce_first_as_cmd,
@@ -921,7 +929,7 @@ DEFUN (no_bgp_enforce_first_as,
bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
return CMD_SUCCESS;
}
-
+
/* "bgp bestpath compare-routerid" configuration. */
DEFUN (bgp_bestpath_compare_router_id,
bgp_bestpath_compare_router_id_cmd,
@@ -951,7 +959,7 @@ DEFUN (no_bgp_bestpath_compare_router_id,
bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
return CMD_SUCCESS;
}
-
+
/* "bgp bestpath as-path ignore" configuration. */
DEFUN (bgp_bestpath_aspath_ignore,
bgp_bestpath_aspath_ignore_cmd,
@@ -983,7 +991,7 @@ DEFUN (no_bgp_bestpath_aspath_ignore,
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
return CMD_SUCCESS;
}
-
+
/* "bgp bestpath as-path confed" configuration. */
DEFUN (bgp_bestpath_aspath_confed,
bgp_bestpath_aspath_confed_cmd,
@@ -1015,7 +1023,7 @@ DEFUN (no_bgp_bestpath_aspath_confed,
bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
return CMD_SUCCESS;
}
-
+
/* "bgp log-neighbor-changes" configuration. */
DEFUN (bgp_log_neighbor_changes,
bgp_log_neighbor_changes_cmd,
@@ -1043,7 +1051,7 @@ DEFUN (no_bgp_log_neighbor_changes,
bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
return CMD_SUCCESS;
}
-
+
/* "bgp bestpath med" configuration. */
DEFUN (bgp_bestpath_med,
bgp_bestpath_med_cmd,
@@ -1055,7 +1063,7 @@ DEFUN (bgp_bestpath_med,
"Treat missing MED as the least preferred one\n")
{
struct bgp *bgp;
-
+
bgp = vty->index;
if (strncmp (argv[0], "confed", 1) == 0)
@@ -1076,7 +1084,7 @@ DEFUN (bgp_bestpath_med2,
"Treat missing MED as the least preferred one\n")
{
struct bgp *bgp;
-
+
bgp = vty->index;
bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
@@ -1105,7 +1113,7 @@ DEFUN (no_bgp_bestpath_med,
struct bgp *bgp;
bgp = vty->index;
-
+
if (strncmp (argv[0], "confed", 1) == 0)
bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
else
@@ -1125,7 +1133,7 @@ DEFUN (no_bgp_bestpath_med2,
"Treat missing MED as the least preferred one\n")
{
struct bgp *bgp;
-
+
bgp = vty->index;
bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
@@ -1141,7 +1149,7 @@ ALIAS (no_bgp_bestpath_med2,
"MED attribute\n"
"Treat missing MED as the least preferred one\n"
"Compare MED among confederation paths\n")
-
+
/* "no bgp default ipv4-unicast". */
DEFUN (no_bgp_default_ipv4_unicast,
no_bgp_default_ipv4_unicast_cmd,
@@ -1171,7 +1179,7 @@ DEFUN (bgp_default_ipv4_unicast,
bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
return CMD_SUCCESS;
}
-
+
/* "bgp import-check" configuration. */
DEFUN (bgp_network_import_check,
bgp_network_import_check_cmd,
@@ -1201,7 +1209,7 @@ DEFUN (no_bgp_network_import_check,
bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
return CMD_SUCCESS;
}
-
+
DEFUN (bgp_default_local_preference,
bgp_default_local_preference_cmd,
"bgp default local-preference <0-4294967295>",
@@ -1245,9 +1253,9 @@ ALIAS (no_bgp_default_local_preference,
"Configure BGP defaults\n"
"local preference (higher=more preferred)\n"
"Configure default local preference value\n")
-
+
static int
-peer_remote_as_vty (struct vty *vty, const char *peer_str,
+peer_remote_as_vty (struct vty *vty, const char *peer_str,
const char *as_str, afi_t afi, safi_t safi)
{
int ret;
@@ -1305,7 +1313,7 @@ DEFUN (neighbor_remote_as,
{
return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST);
}
-
+
DEFUN (neighbor_peer_group,
neighbor_peer_group_cmd,
"neighbor WORD peer-group",
@@ -1353,7 +1361,7 @@ DEFUN (no_neighbor,
{
peer = peer_lookup (vty->index, &su);
if (peer)
- peer_delete (peer);
+ bgp_peer_delete (peer);
}
return CMD_SUCCESS;
@@ -1410,7 +1418,7 @@ DEFUN (no_neighbor_peer_group_remote_as,
}
return CMD_SUCCESS;
}
-
+
DEFUN (neighbor_local_as,
neighbor_local_as_cmd,
NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
@@ -1487,7 +1495,7 @@ ALIAS (no_neighbor_local_as,
"Specify a local-as number\n"
"AS number used as local AS\n"
"Do not prepend local-as to updates from ebgp peers\n")
-
+
DEFUN (neighbor_password,
neighbor_password_cmd,
NEIGHBOR_CMD2 "password LINE",
@@ -1525,7 +1533,7 @@ DEFUN (no_neighbor_password,
ret = peer_password_unset (peer);
return bgp_vty_return (vty, ret);
}
-
+
DEFUN (neighbor_activate,
neighbor_activate_cmd,
NEIGHBOR_CMD2 "activate",
@@ -1564,7 +1572,7 @@ DEFUN (no_neighbor_activate,
return bgp_vty_return (vty, ret);
}
-
+
DEFUN (neighbor_set_peer_group,
neighbor_set_peer_group_cmd,
NEIGHBOR_CMD "peer-group WORD",
@@ -1602,7 +1610,7 @@ DEFUN (neighbor_set_peer_group,
return CMD_WARNING;
}
- ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
+ ret = peer_group_bind (bgp, &su, group, bgp_node_afi (vty),
bgp_node_safi (vty), &as);
if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
@@ -1646,9 +1654,9 @@ DEFUN (no_neighbor_set_peer_group,
return bgp_vty_return (vty, ret);
}
-
+
static int
-peer_flag_modify_vty (struct vty *vty, const char *ip_str,
+peer_flag_modify_vty (struct vty *vty, const char *ip_str,
u_int16_t flag, int set)
{
int ret;
@@ -1699,7 +1707,7 @@ DEFUN (no_neighbor_passive,
{
return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_PASSIVE);
}
-
+
/* neighbor shutdown. */
DEFUN (neighbor_shutdown,
neighbor_shutdown_cmd,
@@ -1721,7 +1729,7 @@ DEFUN (no_neighbor_shutdown,
{
return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN);
}
-
+
/* Deprecated neighbor capability route-refresh. */
DEFUN_DEPRECATED (neighbor_capability_route_refresh,
neighbor_capability_route_refresh_cmd,
@@ -1745,7 +1753,7 @@ DEFUN_DEPRECATED (no_neighbor_capability_route_refresh,
{
return CMD_SUCCESS;
}
-
+
/* neighbor capability dynamic. */
DEFUN (neighbor_capability_dynamic,
neighbor_capability_dynamic_cmd,
@@ -1769,7 +1777,7 @@ DEFUN (no_neighbor_capability_dynamic,
{
return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DYNAMIC_CAPABILITY);
}
-
+
/* neighbor dont-capability-negotiate */
DEFUN (neighbor_dont_capability_negotiate,
neighbor_dont_capability_negotiate_cmd,
@@ -1791,10 +1799,10 @@ DEFUN (no_neighbor_dont_capability_negotiate,
{
return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_DONT_CAPABILITY);
}
-
+
static int
peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
- safi_t safi, u_int32_t flag, int set)
+ safi_t safi, u_int32_t flag, bool set)
{
int ret;
struct peer *peer;
@@ -1803,10 +1811,7 @@ peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
if (! peer)
return CMD_WARNING;
- if (set)
- ret = peer_af_flag_set (peer, afi, safi, flag);
- else
- ret = peer_af_flag_unset (peer, afi, safi, flag);
+ ret = peer_af_flag_modify(peer, afi, safi, flag, set);
return bgp_vty_return (vty, ret);
}
@@ -1815,16 +1820,16 @@ static int
peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
safi_t safi, u_int32_t flag)
{
- return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
+ return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, true);
}
static int
peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
safi_t safi, u_int32_t flag)
{
- return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
+ return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, false);
}
-
+
/* neighbor capability orf prefix-list. */
DEFUN (neighbor_capability_orf_prefix,
neighbor_capability_orf_prefix_cmd,
@@ -1880,7 +1885,7 @@ DEFUN (no_neighbor_capability_orf_prefix,
return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty), flag);
}
-
+
/* neighbor next-hop-self. */
DEFUN (neighbor_nexthop_self,
neighbor_nexthop_self_cmd,
@@ -1904,7 +1909,7 @@ DEFUN (no_neighbor_nexthop_self,
return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
}
-
+
/* neighbor remove-private-AS. */
DEFUN (neighbor_remove_private_as,
neighbor_remove_private_as_cmd,
@@ -1930,7 +1935,7 @@ DEFUN (no_neighbor_remove_private_as,
bgp_node_safi (vty),
PEER_FLAG_REMOVE_PRIVATE_AS);
}
-
+
/* neighbor send-community. */
DEFUN (neighbor_send_community,
neighbor_send_community_cmd,
@@ -1956,7 +1961,7 @@ DEFUN (no_neighbor_send_community,
bgp_node_safi (vty),
PEER_FLAG_SEND_COMMUNITY);
}
-
+
/* neighbor send-community extended. */
DEFUN (neighbor_send_community_type,
neighbor_send_community_type_cmd,
@@ -2008,7 +2013,7 @@ DEFUN (no_neighbor_send_community_type,
(PEER_FLAG_SEND_COMMUNITY |
PEER_FLAG_SEND_EXT_COMMUNITY));
}
-
+
/* neighbor soft-reconfig. */
DEFUN (neighbor_soft_reconfiguration,
neighbor_soft_reconfiguration_cmd,
@@ -2036,7 +2041,7 @@ DEFUN (no_neighbor_soft_reconfiguration,
bgp_node_afi (vty), bgp_node_safi (vty),
PEER_FLAG_SOFT_RECONFIG);
}
-
+
DEFUN (neighbor_route_reflector_client,
neighbor_route_reflector_client_cmd,
NEIGHBOR_CMD2 "route-reflector-client",
@@ -2068,9 +2073,9 @@ DEFUN (no_neighbor_route_reflector_client,
bgp_node_safi (vty),
PEER_FLAG_REFLECTOR_CLIENT);
}
-
+
static int
-peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
+peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
int afi, int safi)
{
int ret;
@@ -2080,7 +2085,7 @@ peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
struct listnode *node, *nnode;
struct bgp_filter *pfilter;
struct bgp_filter *gfilter;
- int locked_and_added = 0;
+ bool was_active ;
bgp = vty->index;
@@ -2092,29 +2097,22 @@ peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
if ( CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
return CMD_SUCCESS;
- if ( ! peer_rsclient_active (peer) )
- {
- peer = peer_lock (peer); /* rsclient peer list reference */
- listnode_add_sort (bgp->rsclient, peer);
- locked_and_added = 1;
- }
+ was_active = peer_rsclient_active(peer) ;
ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
if (ret < 0)
- {
- if (locked_and_added)
- {
- listnode_delete (bgp->rsclient, peer);
- peer_unlock (peer); /* rsclient peer list reference */
- }
+ return bgp_vty_return (vty, ret);
- return bgp_vty_return (vty, ret);
- }
+ if (!was_active)
+ {
+ bgp_peer_lock (peer); /* rsclient peer list reference */
+ listnode_add_sort (bgp->rsclient, peer);
+ } ;
peer->rib[afi][safi] = bgp_table_init (afi, safi);
peer->rib[afi][safi]->type = BGP_TABLE_RSCLIENT;
/* RIB peer reference. Released when table is free'd in bgp_table_free. */
- peer->rib[afi][safi]->owner = peer_lock (peer);
+ peer->rib[afi][safi]->owner = bgp_peer_lock (peer);
/* Check for existing 'network' and 'redistribute' routes. */
bgp_check_local_routes_rsclient (peer, afi, safi);
@@ -2131,7 +2129,7 @@ peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
{
pfilter = &peer->filter[afi][safi];
- /* Members of a non-RS-Client group should not be RS-Clients, as that
+ /* Members of a non-RS-Client group should not be RS-Clients, as that
is checked when the become part of the peer-group */
ret = peer_af_flag_set (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
if (ret < 0)
@@ -2166,7 +2164,7 @@ peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
}
static int
-peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
+peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
int afi, int safi)
{
int ret;
@@ -2181,10 +2179,19 @@ peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
if ( ! peer )
return CMD_WARNING;
+ assert(bgp == peer->bgp) ;
+
/* If it is not a RS-Client, don't do anything. */
if ( ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT) )
return CMD_SUCCESS;
+ /* If this is a Peer Group, then need to undo the relevant rsclient state
+ * for all the group members.
+ *
+ * That means clearing the state flag and the pointer to the shared RIB.
+ *
+ * TODO: peer_af_flag_unset PEER_FLAG_RSERVER_CLIENT fails for group members ?
+ */
if (CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
@@ -2201,22 +2208,65 @@ peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
peer = group->conf;
}
+ /* Unset the rsclient flag and remove from rsclient list if no longer a
+ * distinct rsclient.
+ *
+ * NB: this takes care of downing the peer, if required.
+ */
ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
if (ret < 0)
return bgp_vty_return (vty, ret);
- if ( ! peer_rsclient_active (peer) )
+ /* Now tidy up the data structures. */
+ peer_rsclient_unset(peer, afi, safi, false) ;
+
+ return CMD_SUCCESS;
+}
+
+/* Have unset rsclient state for a peer that was a distinct rsclient.
+ *
+ * Tidy up the data structures.
+ *
+ * NB: does not down the peer or deal with other consequences.
+ */
+void
+peer_rsclient_unset(struct peer* peer, int afi, int safi, bool keep_export)
+{
+ assert(peer->rib[afi][safi] != NULL) ;
+
+ /* If the peer is no longer a distinct rsclient, remove from list of same. */
+ if (! peer_rsclient_active (peer))
{
- bgp_clear_route (peer, afi, safi, BGP_CLEAR_ROUTE_MY_RSCLIENT);
- listnode_delete (bgp->rsclient, peer);
- peer_unlock (peer); /* peer bgp rsclient reference */
+ struct listnode *pn;
+ pn = listnode_lookup (peer->bgp->rsclient, peer) ;
+
+ assert(pn != NULL) ;
+
+ bgp_peer_unlock (peer); /* peer rsclient reference */
+ list_delete_node (peer->bgp->rsclient, pn);
}
- bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
+ /* Discard the rsclient rib */
+ bgp_clear_rsclient_rib (peer, afi, safi);
+ bgp_table_finish (&peer->rib[afi][safi]);
- return CMD_SUCCESS;
+ /* Discard import policy unconditionally */
+ if (peer->filter[afi][safi].map[RMAP_IMPORT].name)
+ {
+ free (peer->filter[afi][safi].map[RMAP_IMPORT].name);
+ peer->filter[afi][safi].map[RMAP_IMPORT].name = NULL;
+ peer->filter[afi][safi].map[RMAP_IMPORT].map = NULL;
+ }
+
+ /* Discard export policy unless should be kept. */
+ if (peer->filter[afi][safi].map[RMAP_EXPORT].name && !keep_export)
+ {
+ free (peer->filter[afi][safi].map[RMAP_EXPORT].name);
+ peer->filter[afi][safi].map[RMAP_EXPORT].name = NULL;
+ peer->filter[afi][safi].map[RMAP_EXPORT].map = NULL;
+ }
}
-
+
/* neighbor route-server-client. */
DEFUN (neighbor_route_server_client,
neighbor_route_server_client_cmd,
@@ -2240,7 +2290,7 @@ DEFUN (no_neighbor_route_server_client,
return peer_rsclient_unset_vty (vty, argv[0], bgp_node_afi(vty),
bgp_node_safi(vty));
}
-
+
DEFUN (neighbor_nexthop_local_unchanged,
neighbor_nexthop_local_unchanged_cmd,
NEIGHBOR_CMD2 "nexthop-local unchanged",
@@ -2253,7 +2303,7 @@ DEFUN (neighbor_nexthop_local_unchanged,
bgp_node_safi (vty),
PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
}
-
+
DEFUN (no_neighbor_nexthop_local_unchanged,
no_neighbor_nexthop_local_unchanged_cmd,
NO_NEIGHBOR_CMD2 "nexthop-local unchanged",
@@ -2267,7 +2317,7 @@ DEFUN (no_neighbor_nexthop_local_unchanged,
bgp_node_safi (vty),
PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
}
-
+
DEFUN (neighbor_attr_unchanged,
neighbor_attr_unchanged_cmd,
NEIGHBOR_CMD2 "attribute-unchanged",
@@ -2432,7 +2482,7 @@ ALIAS (neighbor_attr_unchanged,
DEFUN (no_neighbor_attr_unchanged,
no_neighbor_attr_unchanged_cmd,
NO_NEIGHBOR_CMD2 "attribute-unchanged",
- NO_STR
+ NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"BGP attribute is propagated unchanged to this neighbor\n")
@@ -2624,10 +2674,10 @@ DEFUN_DEPRECATED (neighbor_transparent_nexthop,
bgp_node_safi (vty),
PEER_FLAG_NEXTHOP_UNCHANGED);
}
-
+
/* EBGP multihop configuration. */
static int
-peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
+peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
const char *ttl_str)
{
struct peer *peer;
@@ -2638,15 +2688,15 @@ peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
return CMD_WARNING;
if (! ttl_str)
- ttl = TTL_MAX;
+ ttl = MAXTTL;
else
- VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, 255);
+ VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL);
return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
}
static int
-peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
+peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
{
struct peer *peer;
@@ -2698,7 +2748,7 @@ ALIAS (no_neighbor_ebgp_multihop,
NEIGHBOR_ADDR_STR2
"Allow EBGP neighbors not on directly connected networks\n"
"maximum hop count\n")
-
+
/* disable-connected-check */
DEFUN (neighbor_disable_connected_check,
neighbor_disable_connected_check_cmd,
@@ -2737,7 +2787,7 @@ ALIAS (no_neighbor_disable_connected_check,
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Enforce EBGP neighbors perform multihop\n")
-
+
DEFUN (neighbor_description,
neighbor_description_cmd,
NEIGHBOR_CMD2 "description .LINE",
@@ -2792,10 +2842,10 @@ ALIAS (no_neighbor_description,
NEIGHBOR_ADDR_STR2
"Neighbor specific description\n"
"Up to 80 characters describing this neighbor\n")
-
+
/* Neighbor update-source. */
static int
-peer_update_source_vty (struct vty *vty, const char *peer_str,
+peer_update_source_vty (struct vty *vty, const char *peer_str,
const char *source_str)
{
struct peer *peer;
@@ -2849,10 +2899,10 @@ DEFUN (no_neighbor_update_source,
{
return peer_update_source_vty (vty, argv[0], NULL);
}
-
+
static int
-peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
- afi_t afi, safi_t safi,
+peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
+ afi_t afi, safi_t safi,
const char *rmap, int set)
{
int ret;
@@ -2916,10 +2966,10 @@ ALIAS (no_neighbor_default_originate,
"Originate default route to this neighbor\n"
"Route-map to specify criteria to originate default\n"
"route-map name\n")
-
+
/* Set neighbor's BGP port. */
static int
-peer_port_vty (struct vty *vty, const char *ip_str, int afi,
+peer_port_vty (struct vty *vty, const char *ip_str, int afi,
const char *port_str)
{
struct peer *peer;
@@ -2931,7 +2981,7 @@ peer_port_vty (struct vty *vty, const char *ip_str, int afi,
return CMD_WARNING;
if (! port_str)
- {
+ {
sp = getservbyname ("bgp", "tcp");
port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
}
@@ -2976,10 +3026,10 @@ ALIAS (no_neighbor_port,
NEIGHBOR_ADDR_STR
"Neighbor's BGP port\n"
"TCP port number\n")
-
+
/* neighbor weight. */
static int
-peer_weight_set_vty (struct vty *vty, const char *ip_str,
+peer_weight_set_vty (struct vty *vty, const char *ip_str,
const char *weight_str)
{
int ret;
@@ -3041,7 +3091,7 @@ ALIAS (no_neighbor_weight,
NEIGHBOR_ADDR_STR2
"Set default weight for routes from this neighbor\n"
"default weight\n")
-
+
/* Override capability negotiation. */
DEFUN (neighbor_override_capability,
neighbor_override_capability_cmd,
@@ -3063,7 +3113,7 @@ DEFUN (no_neighbor_override_capability,
{
return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_OVERRIDE_CAPABILITY);
}
-
+
DEFUN (neighbor_strict_capability,
neighbor_strict_capability_cmd,
NEIGHBOR_CMD "strict-capability-match",
@@ -3084,9 +3134,9 @@ DEFUN (no_neighbor_strict_capability,
{
return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_STRICT_CAP_MATCH);
}
-
+
static int
-peer_timers_set_vty (struct vty *vty, const char *ip_str,
+peer_timers_set_vty (struct vty *vty, const char *ip_str,
const char *keep_str, const char *hold_str)
{
int ret;
@@ -3105,7 +3155,7 @@ peer_timers_set_vty (struct vty *vty, const char *ip_str,
return bgp_vty_return (vty, ret);
}
-
+
static int
peer_timers_unset_vty (struct vty *vty, const char *ip_str)
{
@@ -3143,9 +3193,9 @@ DEFUN (no_neighbor_timers,
{
return peer_timers_unset_vty (vty, argv[0]);
}
-
+
static int
-peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
+peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
const char *time_str)
{
int ret;
@@ -3211,10 +3261,10 @@ ALIAS (no_neighbor_timers_connect,
"BGP per neighbor timers\n"
"BGP connect timer\n"
"Connect timer\n")
-
+
static int
-peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
- const char *time_str, int set)
+peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
+ const char *time_str, int set)
{
int ret;
struct peer *peer;
@@ -3265,7 +3315,7 @@ ALIAS (no_neighbor_advertise_interval,
NEIGHBOR_ADDR_STR
"Minimum interval between sending BGP routing updates\n"
"time in seconds\n")
-
+
/* neighbor interface */
static int
peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
@@ -3307,10 +3357,10 @@ DEFUN (no_neighbor_interface,
{
return peer_interface_vty (vty, argv[0], NULL);
}
-
+
/* Set distribute list to the peer. */
static int
-peer_distribute_set_vty (struct vty *vty, const char *ip_str,
+peer_distribute_set_vty (struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi,
const char *name_str, const char *direct_str)
{
@@ -3388,11 +3438,11 @@ DEFUN (no_neighbor_distribute_list,
return peer_distribute_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty), argv[2]);
}
-
+
/* Set prefix list to the peer. */
static int
peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
- safi_t safi, const char *name_str,
+ safi_t safi, const char *name_str,
const char *direct_str)
{
int ret;
@@ -3425,7 +3475,7 @@ peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
peer = peer_and_group_lookup_vty (vty, ip_str);
if (! peer)
return CMD_WARNING;
-
+
/* Check filter direction. */
if (strncmp (direct_str, "i", 1) == 0)
direct = FILTER_IN;
@@ -3465,9 +3515,9 @@ DEFUN (no_neighbor_prefix_list,
return peer_prefix_list_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty), argv[2]);
}
-
+
static int
-peer_aslist_set_vty (struct vty *vty, const char *ip_str,
+peer_aslist_set_vty (struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi,
const char *name_str, const char *direct_str)
{
@@ -3491,7 +3541,7 @@ peer_aslist_set_vty (struct vty *vty, const char *ip_str,
}
static int
-peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
+peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi,
const char *direct_str)
{
@@ -3542,10 +3592,10 @@ DEFUN (no_neighbor_filter_list,
return peer_aslist_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty), argv[2]);
}
-
+
/* Set route-map to the peer. */
static int
-peer_route_map_set_vty (struct vty *vty, const char *ip_str,
+peer_route_map_set_vty (struct vty *vty, const char *ip_str,
afi_t afi, safi_t safi,
const char *name_str, const char *direct_str)
{
@@ -3566,6 +3616,8 @@ peer_route_map_set_vty (struct vty *vty, const char *ip_str,
direct = RMAP_IMPORT;
else if (strncmp (direct_str, "e", 1) == 0)
direct = RMAP_EXPORT;
+ else if (strncmp (direct_str, "r", 1) == 0)
+ direct = RMAP_RS_IN;
ret = peer_route_map_set (peer, afi, safi, direct, name_str);
@@ -3593,6 +3645,8 @@ peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
direct = RMAP_IMPORT;
else if (strncmp (direct_str, "e", 1) == 0)
direct = RMAP_EXPORT;
+ else if (strncmp (direct_str, "r", 1) == 0)
+ direct = RMAP_RS_IN;
ret = peer_route_map_unset (peer, afi, safi, direct);
@@ -3601,12 +3655,13 @@ peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
DEFUN (neighbor_route_map,
neighbor_route_map_cmd,
- NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
+ NEIGHBOR_CMD2 "route-map WORD (in|rs-in|out|import|export)",
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Apply route map to neighbor\n"
"Name of route map\n"
"Apply map to incoming routes\n"
+ "Apply map to incoming Route-Server routes\n"
"Apply map to outbound routes\n"
"Apply map to routes going into a Route-Server client's table\n"
"Apply map to routes coming from a Route-Server client")
@@ -3617,13 +3672,14 @@ DEFUN (neighbor_route_map,
DEFUN (no_neighbor_route_map,
no_neighbor_route_map_cmd,
- NO_NEIGHBOR_CMD2 "route-map WORD (in|out|import|export)",
+ NO_NEIGHBOR_CMD2 "route-map WORD (in|rs-in|out|import|export)",
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Apply route map to neighbor\n"
"Name of route map\n"
"Apply map to incoming routes\n"
+ "Apply map to incoming Route-Server routes\n"
"Apply map to outbound routes\n"
"Apply map to routes going into a Route-Server client's table\n"
"Apply map to routes coming from a Route-Server client")
@@ -3631,7 +3687,7 @@ DEFUN (no_neighbor_route_map,
return peer_route_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty), argv[2]);
}
-
+
/* Set unsuppress-map to the peer. */
static int
peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
@@ -3690,10 +3746,10 @@ DEFUN (no_neighbor_unsuppress_map,
return peer_unsuppress_map_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty));
}
-
+
static int
peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
- safi_t safi, const char *num_str,
+ safi_t safi, const char *num_str,
const char *threshold_str, int warning,
const char *restart_str)
{
@@ -3837,7 +3893,7 @@ DEFUN (no_neighbor_maximum_prefix,
return peer_maximum_prefix_unset_vty (vty, argv[0], bgp_node_afi (vty),
bgp_node_safi (vty));
}
-
+
ALIAS (no_neighbor_maximum_prefix,
no_neighbor_maximum_prefix_val_cmd,
NO_NEIGHBOR_CMD2 "maximum-prefix <1-4294967295>",
@@ -3900,7 +3956,7 @@ ALIAS (no_neighbor_maximum_prefix,
"Threshold value (%) at which to generate a warning msg\n"
"Restart bgp connection after limit is exceeded\n"
"Restart interval in minutes")
-
+
/* "neighbor allowas-in" */
DEFUN (neighbor_allowas_in,
neighbor_allowas_in_cmd,
@@ -3955,7 +4011,8 @@ DEFUN (no_neighbor_allowas_in,
return bgp_vty_return (vty, ret);
}
-
+
+
DEFUN (neighbor_ttl_security,
neighbor_ttl_security_cmd,
NEIGHBOR_CMD2 "ttl-security hops <1-254>",
@@ -3969,7 +4026,7 @@ DEFUN (neighbor_ttl_security,
peer = peer_and_group_lookup_vty (vty, argv[0]);
if (! peer)
return CMD_WARNING;
-
+
VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[1], 1, 254);
return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
@@ -3991,7 +4048,7 @@ DEFUN (no_neighbor_ttl_security,
return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
}
-
+
/* Address family configuration. */
DEFUN (address_family_ipv4,
address_family_ipv4_cmd,
@@ -3999,7 +4056,7 @@ DEFUN (address_family_ipv4,
"Enter Address Family command mode\n"
"Address family\n")
{
- vty->node = BGP_IPV4_NODE;
+ vty_set_node(vty, BGP_IPV4_NODE) ;
return CMD_SUCCESS;
}
@@ -4012,9 +4069,9 @@ DEFUN (address_family_ipv4_safi,
"Address Family modifier\n")
{
if (strncmp (argv[0], "m", 1) == 0)
- vty->node = BGP_IPV4M_NODE;
+ vty_set_node(vty, BGP_IPV4M_NODE) ;
else
- vty->node = BGP_IPV4_NODE;
+ vty_set_node(vty, BGP_IPV4_NODE) ;
return CMD_SUCCESS;
}
@@ -4025,7 +4082,7 @@ DEFUN (address_family_ipv6,
"Enter Address Family command mode\n"
"Address family\n")
{
- vty->node = BGP_IPV6_NODE;
+ vty_set_node(vty, BGP_IPV6_NODE) ;
return CMD_SUCCESS;
}
@@ -4038,9 +4095,9 @@ DEFUN (address_family_ipv6_safi,
"Address Family modifier\n")
{
if (strncmp (argv[0], "m", 1) == 0)
- vty->node = BGP_IPV6M_NODE;
+ vty_set_node(vty, BGP_IPV6M_NODE) ;
else
- vty->node = BGP_IPV6_NODE;
+ vty_set_node(vty, BGP_IPV6_NODE) ;
return CMD_SUCCESS;
}
@@ -4051,7 +4108,7 @@ DEFUN (address_family_vpnv4,
"Enter Address Family command mode\n"
"Address family\n")
{
- vty->node = BGP_VPNV4_NODE;
+ vty_set_node(vty, BGP_VPNV4_NODE) ;
return CMD_SUCCESS;
}
@@ -4067,24 +4124,26 @@ DEFUN (exit_address_family,
"exit-address-family",
"Exit from Address Family configuration mode\n")
{
- if (vty->node == BGP_IPV4_NODE
- || vty->node == BGP_IPV4M_NODE
- || vty->node == BGP_VPNV4_NODE
- || vty->node == BGP_IPV6_NODE
- || vty->node == BGP_IPV6M_NODE)
- vty->node = BGP_NODE;
+ enum node_type node = vty_get_node(vty) ;
+
+ 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;
}
-
+
/* BGP clear sort. */
-enum clear_sort
+typedef enum
{
clear_all,
clear_peer,
clear_group,
clear_external,
clear_as
-};
+} clear_sort_t ;
static void
bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
@@ -4110,7 +4169,7 @@ bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
/* `clear ip bgp' functions. */
static int
bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
- enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
+ clear_sort_t sort, bgp_clear_type_t stype, const char *arg)
{
int ret;
struct peer *peer;
@@ -4172,7 +4231,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
if (! group)
{
vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
- return CMD_WARNING;
+ return CMD_WARNING;
}
for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
@@ -4198,7 +4257,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
{
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
- if (peer_sort (peer) == BGP_PEER_IBGP)
+ if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
if (stype == BGP_CLEAR_SOFT_NONE)
@@ -4219,17 +4278,17 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
int find = 0;
VTY_GET_LONG ("AS", as_ul, arg);
-
+
if (!as_ul)
{
- vty_out (vty, "Invalid AS number%s", VTY_NEWLINE);
+ vty_out (vty, "Invalid AS number%s", VTY_NEWLINE);
return CMD_WARNING;
}
as = (as_t) as_ul;
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
- if (peer->as != as)
+ if (peer->as != as)
continue;
find = 1;
@@ -4252,8 +4311,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
static int
bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
- enum clear_sort sort, enum bgp_clear_type stype,
- const char *arg)
+ clear_sort_t sort, bgp_clear_type_t stype, const char *arg)
{
struct bgp *bgp;
@@ -4279,7 +4337,7 @@ bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
}
-
+
DEFUN (clear_ip_bgp_all,
clear_ip_bgp_all_cmd,
"clear ip bgp *",
@@ -4289,7 +4347,7 @@ DEFUN (clear_ip_bgp_all,
"Clear all peers\n")
{
if (argc == 1)
- return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
+ return bgp_clear_vty (vty, argv[0], 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
return bgp_clear_vty (vty, NULL, 0, 0, clear_all, BGP_CLEAR_SOFT_NONE, NULL);
}
@@ -4329,7 +4387,7 @@ ALIAS (clear_ip_bgp_all,
"Clear all peers\n")
DEFUN (clear_ip_bgp_peer,
- clear_ip_bgp_peer_cmd,
+ clear_ip_bgp_peer_cmd,
"clear ip bgp (A.B.C.D|X:X::X:X)",
CLEAR_STR
IP_STR
@@ -4341,7 +4399,7 @@ DEFUN (clear_ip_bgp_peer,
}
ALIAS (clear_ip_bgp_peer,
- clear_bgp_peer_cmd,
+ clear_bgp_peer_cmd,
"clear bgp (A.B.C.D|X:X::X:X)",
CLEAR_STR
BGP_STR
@@ -4349,7 +4407,7 @@ ALIAS (clear_ip_bgp_peer,
"BGP IPv6 neighbor to clear\n")
ALIAS (clear_ip_bgp_peer,
- clear_bgp_ipv6_peer_cmd,
+ clear_bgp_ipv6_peer_cmd,
"clear bgp ipv6 (A.B.C.D|X:X::X:X)",
CLEAR_STR
BGP_STR
@@ -4358,7 +4416,7 @@ ALIAS (clear_ip_bgp_peer,
"BGP IPv6 neighbor to clear\n")
DEFUN (clear_ip_bgp_peer_group,
- clear_ip_bgp_peer_group_cmd,
+ clear_ip_bgp_peer_group_cmd,
"clear ip bgp peer-group WORD",
CLEAR_STR
IP_STR
@@ -4370,7 +4428,7 @@ DEFUN (clear_ip_bgp_peer_group,
}
ALIAS (clear_ip_bgp_peer_group,
- clear_bgp_peer_group_cmd,
+ clear_bgp_peer_group_cmd,
"clear bgp peer-group WORD",
CLEAR_STR
BGP_STR
@@ -4378,7 +4436,7 @@ ALIAS (clear_ip_bgp_peer_group,
"BGP peer-group name\n")
ALIAS (clear_ip_bgp_peer_group,
- clear_bgp_ipv6_peer_group_cmd,
+ clear_bgp_ipv6_peer_group_cmd,
"clear bgp ipv6 peer-group WORD",
CLEAR_STR
BGP_STR
@@ -4398,14 +4456,14 @@ DEFUN (clear_ip_bgp_external,
}
ALIAS (clear_ip_bgp_external,
- clear_bgp_external_cmd,
+ clear_bgp_external_cmd,
"clear bgp external",
CLEAR_STR
BGP_STR
"Clear all external peers\n")
ALIAS (clear_ip_bgp_external,
- clear_bgp_ipv6_external_cmd,
+ clear_bgp_ipv6_external_cmd,
"clear bgp ipv6 external",
CLEAR_STR
BGP_STR
@@ -4421,7 +4479,7 @@ DEFUN (clear_ip_bgp_as,
"Clear peers with the AS number\n")
{
return bgp_clear_vty (vty, NULL, 0, 0, clear_as, BGP_CLEAR_SOFT_NONE, argv[0]);
-}
+}
ALIAS (clear_ip_bgp_as,
clear_bgp_as_cmd,
@@ -4437,7 +4495,7 @@ ALIAS (clear_ip_bgp_as,
BGP_STR
"Address family\n"
"Clear peers with the AS number\n")
-
+
/* Outbound soft-reconfiguration */
DEFUN (clear_ip_bgp_all_soft_out,
clear_ip_bgp_all_soft_out_cmd,
@@ -4743,7 +4801,7 @@ ALIAS (clear_bgp_peer_soft_out,
"Soft reconfig outbound update\n")
DEFUN (clear_ip_bgp_peer_group_soft_out,
- clear_ip_bgp_peer_group_soft_out_cmd,
+ clear_ip_bgp_peer_group_soft_out_cmd,
"clear ip bgp peer-group WORD soft out",
CLEAR_STR
IP_STR
@@ -4758,7 +4816,7 @@ DEFUN (clear_ip_bgp_peer_group_soft_out,
}
ALIAS (clear_ip_bgp_peer_group_soft_out,
- clear_ip_bgp_peer_group_out_cmd,
+ clear_ip_bgp_peer_group_out_cmd,
"clear ip bgp peer-group WORD out",
CLEAR_STR
IP_STR
@@ -4847,7 +4905,7 @@ ALIAS (clear_bgp_peer_group_soft_out,
"Soft reconfig outbound update\n")
DEFUN (clear_ip_bgp_external_soft_out,
- clear_ip_bgp_external_soft_out_cmd,
+ clear_ip_bgp_external_soft_out_cmd,
"clear ip bgp external soft out",
CLEAR_STR
IP_STR
@@ -4861,7 +4919,7 @@ DEFUN (clear_ip_bgp_external_soft_out,
}
ALIAS (clear_ip_bgp_external_soft_out,
- clear_ip_bgp_external_out_cmd,
+ clear_ip_bgp_external_out_cmd,
"clear ip bgp external out",
CLEAR_STR
IP_STR
@@ -5064,7 +5122,7 @@ ALIAS (clear_bgp_as_soft_out,
"Address family\n"
"Clear peers with the AS number\n"
"Soft reconfig outbound update\n")
-
+
/* Inbound soft-reconfiguration */
DEFUN (clear_ip_bgp_all_soft_in,
clear_ip_bgp_all_soft_in_cmd,
@@ -5361,7 +5419,7 @@ ALIAS (clear_ip_bgp_peer_soft_in,
BGP_STR
"BGP neighbor address to clear\n"
"Soft reconfig inbound update\n")
-
+
DEFUN (clear_ip_bgp_peer_in_prefix_filter,
clear_ip_bgp_peer_in_prefix_filter_cmd,
"clear ip bgp A.B.C.D in prefix-filter",
@@ -6026,7 +6084,7 @@ ALIAS (clear_bgp_as_in_prefix_filter,
"Clear peers with the AS number\n"
"Soft reconfig inbound update\n"
"Push out prefix-list ORF and do inbound soft reconfig\n")
-
+
/* Both soft-reconfiguration */
DEFUN (clear_ip_bgp_all_soft,
clear_ip_bgp_all_soft_cmd,
@@ -6125,7 +6183,7 @@ DEFUN (clear_bgp_all_soft,
if (argc == 1)
return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
BGP_CLEAR_SOFT_BOTH, argv[0]);
-
+
return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
BGP_CLEAR_SOFT_BOTH, argv[0]);
}
@@ -6400,7 +6458,7 @@ ALIAS (clear_bgp_as_soft,
"Address family\n"
"Clear peers with the AS number\n"
"Soft reconfig\n")
-
+
/* RS-client soft reconfiguration. */
#ifdef HAVE_IPV6
DEFUN (clear_bgp_all_rsclient,
@@ -6576,17 +6634,17 @@ DEFUN (show_bgp_views,
vty_out (vty, "Multiple BGP views are not defined%s", VTY_NEWLINE);
return CMD_WARNING;
}
-
+
vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
- vty_out (vty, "\t%s (AS%u)%s",
+ vty_out (vty, "\t%s (AS%u)%s",
bgp->name ? bgp->name : "(null)",
bgp->as, VTY_NEWLINE);
-
+
return CMD_SUCCESS;
}
-DEFUN (show_bgp_memory,
+DEFUN (show_bgp_memory,
show_bgp_memory_cmd,
"show bgp memory",
SHOW_STR
@@ -6595,14 +6653,14 @@ DEFUN (show_bgp_memory,
{
char memstrbuf[MTYPE_MEMSTR_LEN];
unsigned long count;
-
+
/* RIB related usage stats */
count = mtype_stats_alloc (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);
vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
@@ -6613,13 +6671,13 @@ DEFUN (show_bgp_memory,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof (struct bgp_info_extra)),
VTY_NEWLINE);
-
+
if ((count = mtype_stats_alloc (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)))
vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
@@ -6631,7 +6689,7 @@ DEFUN (show_bgp_memory,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof (struct bgp_adj_out)),
VTY_NEWLINE);
-
+
if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
@@ -6646,32 +6704,32 @@ DEFUN (show_bgp_memory,
/* Attributes */
count = attr_count();
- vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
- mtype_memstr (memstrbuf, sizeof (memstrbuf),
- count * sizeof(struct attr)),
+ vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
+ mtype_memstr (memstrbuf, sizeof (memstrbuf),
+ count * sizeof(struct attr)),
VTY_NEWLINE);
if ((count = mtype_stats_alloc (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)),
+ vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
+ mtype_memstr (memstrbuf, sizeof (memstrbuf),
+ count * sizeof(struct attr_extra)),
VTY_NEWLINE);
-
+
if ((count = attr_unknown_count()))
vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
-
+
/* AS_PATH attributes */
count = aspath_count ();
vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof (struct aspath)),
VTY_NEWLINE);
-
+
count = mtype_stats_alloc (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)),
VTY_NEWLINE);
-
+
/* Other attributes */
if ((count = community_count ()))
vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
@@ -6683,26 +6741,26 @@ DEFUN (show_bgp_memory,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof (struct ecommunity)),
VTY_NEWLINE);
-
+
if ((count = mtype_stats_alloc (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);
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)))
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)))
vty_out (vty, "%ld hash tables, using %s of memory%s", count,
@@ -6731,30 +6789,33 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
unsigned int count = 0;
char timebuf[BGP_UPTIME_LEN];
int len;
+ struct bgp_session_stats stats;
/* Header string for each address family. */
static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
-
+
for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
+ bgp_session_get_stats(peer->session, &stats);
+
if (peer->afc[afi][safi])
{
if (!count)
{
unsigned long ents;
char memstrbuf[MTYPE_MEMSTR_LEN];
-
+
/* Usage summary and header */
vty_out (vty,
"BGP router identifier %s, local AS number %u%s",
- inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
+ safe_inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
ents = bgp_table_count (bgp->rib[afi][safi]);
vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
ents * sizeof (struct bgp_node)),
VTY_NEWLINE);
-
+
/* Peer related usage */
ents = listcount (bgp->peer);
vty_out (vty, "Peers %ld, using %s of memory%s",
@@ -6762,14 +6823,14 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
mtype_memstr (memstrbuf, sizeof (memstrbuf),
ents * sizeof (struct peer)),
VTY_NEWLINE);
-
+
if ((ents = listcount (bgp->rsclient)))
vty_out (vty, "RS-Client peers %ld, using %s of memory%s",
ents,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
ents * sizeof (struct peer)),
VTY_NEWLINE);
-
+
if ((ents = listcount (bgp->group)))
vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
mtype_memstr (memstrbuf, sizeof (memstrbuf),
@@ -6781,11 +6842,11 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
vty_out (vty, "%s", VTY_NEWLINE);
vty_out (vty, "%s%s", header, VTY_NEWLINE);
}
-
+
count++;
- len = vty_out (vty, "%s", peer->host);
- len = 16 - len;
+ vty_out (vty, "%s", peer->host);
+ len = 16 - strlen(peer->host);
if (len < 1)
vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
else
@@ -6795,17 +6856,17 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
peer->as,
- peer->open_in + peer->update_in + peer->keepalive_in
- + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
- peer->open_out + peer->update_out + peer->keepalive_out
- + peer->notify_out + peer->refresh_out
- + peer->dynamic_cap_out,
+ stats.open_in + stats.update_in + stats.keepalive_in
+ + stats.notify_in + stats.refresh_in + stats.dynamic_cap_in,
+ stats.open_out + stats.update_out + stats.keepalive_out
+ + stats.notify_out + stats.refresh_out
+ + stats.dynamic_cap_out,
0, 0, (unsigned long) peer->obuf->count);
- vty_out (vty, "%8s",
+ vty_out (vty, "%8s",
peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN));
- if (peer->status == Established)
+ if (peer->state == bgp_peer_pEstablished)
{
vty_out (vty, " %8ld", peer->pcount[afi][safi]);
}
@@ -6816,7 +6877,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
vty_out (vty, " Idle (PfxCt)");
else
- vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status));
+ vty_out (vty, " %-11s", LOOKUP(bgp_peer_status_msg, peer->state));
}
vty_out (vty, "%s", VTY_NEWLINE);
@@ -6832,8 +6893,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
return CMD_SUCCESS;
}
-static int
-bgp_show_summary_vty (struct vty *vty, const char *name,
+static int
+bgp_show_summary_vty (struct vty *vty, const char *name,
afi_t afi, safi_t safi)
{
struct bgp *bgp;
@@ -6841,27 +6902,27 @@ bgp_show_summary_vty (struct vty *vty, const char *name,
if (name)
{
bgp = bgp_lookup_by_name (name);
-
+
if (! bgp)
{
- vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
+ vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
bgp_show_summary (vty, bgp, afi, safi);
return CMD_SUCCESS;
}
-
+
bgp = bgp_get_default ();
if (bgp)
- bgp_show_summary (vty, bgp, afi, safi);
-
+ bgp_show_summary (vty, bgp, afi, safi);
+
return CMD_SUCCESS;
}
/* `show ip bgp summary' commands. */
-DEFUN (show_ip_bgp_summary,
+DEFUN (show_ip_bgp_summary,
show_ip_bgp_summary_cmd,
"show ip bgp summary",
SHOW_STR
@@ -6882,10 +6943,10 @@ DEFUN (show_ip_bgp_instance_summary,
"View name\n"
"Summary of BGP neighbor status\n")
{
- return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
+ return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST);
}
-DEFUN (show_ip_bgp_ipv4_summary,
+DEFUN (show_ip_bgp_ipv4_summary,
show_ip_bgp_ipv4_summary_cmd,
"show ip bgp ipv4 (unicast|multicast) summary",
SHOW_STR
@@ -6981,7 +7042,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_summary,
}
#ifdef HAVE_IPV6
-DEFUN (show_bgp_summary,
+DEFUN (show_bgp_summary,
show_bgp_summary_cmd,
"show bgp summary",
SHOW_STR
@@ -7003,7 +7064,7 @@ DEFUN (show_bgp_instance_summary,
return bgp_show_summary_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST);
}
-ALIAS (show_bgp_summary,
+ALIAS (show_bgp_summary,
show_bgp_ipv6_summary_cmd,
"show bgp ipv6 summary",
SHOW_STR
@@ -7056,7 +7117,7 @@ DEFUN (show_bgp_instance_ipv6_safi_summary,
}
/* old command */
-DEFUN (show_ipv6_bgp_summary,
+DEFUN (show_ipv6_bgp_summary,
show_ipv6_bgp_summary_cmd,
"show ipv6 bgp summary",
SHOW_STR
@@ -7068,7 +7129,7 @@ DEFUN (show_ipv6_bgp_summary,
}
/* old command */
-DEFUN (show_ipv6_mbgp_summary,
+DEFUN (show_ipv6_mbgp_summary,
show_ipv6_mbgp_summary_cmd,
"show ipv6 mbgp summary",
SHOW_STR
@@ -7079,7 +7140,7 @@ DEFUN (show_ipv6_mbgp_summary,
return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST);
}
#endif /* HAVE_IPV6 */
-
+
const char *
afi_safi_print (afi_t afi, safi_t safi)
{
@@ -7230,7 +7291,7 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
vty_out (vty, "(both)%s", VTY_NEWLINE);
else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
vty_out (vty, "(extended)%s", VTY_NEWLINE);
- else
+ else
vty_out (vty, "(standard)%s", VTY_NEWLINE);
}
if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
@@ -7247,12 +7308,14 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
vty_out (vty, " default not sent%s", VTY_NEWLINE);
}
- if (filter->plist[FILTER_IN].name
+ if (filter->plist[FILTER_IN].ref
|| filter->dlist[FILTER_IN].name
|| filter->aslist[FILTER_IN].name
|| filter->map[RMAP_IN].name)
vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
- if (filter->plist[FILTER_OUT].name
+ if (filter->map[RMAP_RS_IN].name)
+ vty_out (vty, " RS-Inbound path policy configured%s", VTY_NEWLINE);
+ if (filter->plist[FILTER_OUT].ref
|| filter->dlist[FILTER_OUT].name
|| filter->aslist[FILTER_OUT].name
|| filter->map[RMAP_OUT].name
@@ -7264,15 +7327,15 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
vty_out (vty, " Export policy for this RS-client configured%s", VTY_NEWLINE);
/* prefix-list */
- if (filter->plist[FILTER_IN].name)
+ if (filter->plist[FILTER_IN].ref)
vty_out (vty, " Incoming update prefix filter list is %s%s%s",
- filter->plist[FILTER_IN].plist ? "*" : "",
- filter->plist[FILTER_IN].name,
+ prefix_list_ref_plist(filter->plist[FILTER_IN].ref) ? "*" : "",
+ prefix_list_ref_name(filter->plist[FILTER_IN].ref),
VTY_NEWLINE);
- if (filter->plist[FILTER_OUT].name)
+ if (filter->plist[FILTER_OUT].ref)
vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
- filter->plist[FILTER_OUT].plist ? "*" : "",
- filter->plist[FILTER_OUT].name,
+ prefix_list_ref_plist(filter->plist[FILTER_OUT].ref) ? "*" : "",
+ prefix_list_ref_name(filter->plist[FILTER_OUT].ref),
VTY_NEWLINE);
/* distribute-list */
@@ -7305,6 +7368,11 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
filter->map[RMAP_IN].map ? "*" : "",
filter->map[RMAP_IN].name,
VTY_NEWLINE);
+ if (filter->map[RMAP_RS_IN].name)
+ vty_out (vty, " Route map for RS incoming advertisements is %s%s%s",
+ filter->map[RMAP_RS_IN].map ? "*" : "",
+ filter->map[RMAP_RS_IN].name,
+ VTY_NEWLINE);
if (filter->map[RMAP_OUT].name)
vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
filter->map[RMAP_OUT].map ? "*" : "",
@@ -7350,10 +7418,13 @@ static void
bgp_show_peer (struct vty *vty, struct peer *p)
{
struct bgp *bgp;
- char buf1[BUFSIZ];
+ char buf[SU_ADDRSTRLEN];
char timebuf[BGP_UPTIME_LEN];
afi_t afi;
safi_t safi;
+ struct bgp_session_stats stats;
+
+ bgp_session_get_stats(p->session, &stats);
bgp = p->bgp;
@@ -7371,7 +7442,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
/* Description. */
if (p->desc)
vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
-
+
/* Peer-group */
if (p->group)
vty_out (vty, " Member of peer-group %s for session parameters%s",
@@ -7383,30 +7454,33 @@ bgp_show_peer (struct vty *vty, struct peer *p)
/* BGP Version. */
vty_out (vty, " BGP version 4");
- vty_out (vty, ", remote router ID %s%s",
- inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ),
+ vty_out (vty, ", remote router ID %s%s",
+ inet_ntop (AF_INET, &p->remote_id, buf, sizeof(buf)),
VTY_NEWLINE);
/* Confederation */
if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
&& bgp_confederation_peers_check (bgp, p->as))
vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
-
+
/* Status. */
- vty_out (vty, " BGP state = %s",
- LOOKUP (bgp_status_msg, p->status));
- if (p->status == Established)
- vty_out (vty, ", up for %8s",
+ vty_out (vty, " BGP state = %s",
+ LOOKUP (bgp_peer_status_msg, p->state));
+ if (p->state == bgp_peer_pEstablished)
+ vty_out (vty, ", up for %8s",
peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN));
+ /* TODO: what is state "Active" now? sEnabled? */
+#if 0
else if (p->status == Active)
{
if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
- vty_out (vty, " (passive)");
+ vty_out (vty, " (passive)");
else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
- vty_out (vty, " (NSF passive)");
+ vty_out (vty, " (NSF passive)");
}
+#endif
vty_out (vty, "%s", VTY_NEWLINE);
-
+
/* read timer */
vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN));
@@ -7421,7 +7495,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
}
/* Capability. */
- if (p->status == Established)
+ if (p->state == bgp_peer_pEstablished)
{
if (p->cap
|| p->afc_adv[AFI_IP][SAFI_UNICAST]
@@ -7489,12 +7563,12 @@ bgp_show_peer (struct vty *vty, struct peer *p)
if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
{
vty_out (vty, " Address family %s:", afi_safi_print (afi, safi));
- if (p->afc_adv[afi][safi])
+ if (p->afc_adv[afi][safi])
vty_out (vty, " advertised");
if (p->afc_recv[afi][safi])
vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
vty_out (vty, "%s", VTY_NEWLINE);
- }
+ }
/* Gracefull Restart */
if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
@@ -7513,7 +7587,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
int restart_af_count = 0;
vty_out (vty, " Remote Restart timer is %d seconds%s",
- p->v_gr_restart, VTY_NEWLINE);
+ p->v_gr_restart, VTY_NEWLINE);
vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
@@ -7543,7 +7617,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
int eor_receive_af_count = 0;
vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
- if (p->status == Established)
+ if (p->state == bgp_peer_pEstablished)
{
vty_out (vty, " End-of-RIB send: ");
for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
@@ -7571,7 +7645,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
if (p->t_gr_restart)
vty_out (vty, " The remaining time of restart timer is %ld%s",
thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
-
+
if (p->t_gr_stale)
vty_out (vty, " The remaining time of stalepath timer is %ld%s",
thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
@@ -7582,16 +7656,16 @@ bgp_show_peer (struct vty *vty, struct peer *p)
vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
- vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
- vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
- vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
- vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
- vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
- vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
- vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
- p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
- p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
- p->dynamic_cap_in, VTY_NEWLINE);
+ vty_out (vty, " Opens: %10d %10d%s", stats.open_out, stats.open_in, VTY_NEWLINE);
+ vty_out (vty, " Notifications: %10d %10d%s", stats.notify_out, stats.notify_in, VTY_NEWLINE);
+ vty_out (vty, " Updates: %10d %10d%s", stats.update_out, stats.update_in, VTY_NEWLINE);
+ vty_out (vty, " Keepalives: %10d %10d%s", stats.keepalive_out, stats.keepalive_in, VTY_NEWLINE);
+ vty_out (vty, " Route Refresh: %10d %10d%s", stats.refresh_out, stats.refresh_in, VTY_NEWLINE);
+ vty_out (vty, " Capability: %10d %10d%s", stats.dynamic_cap_out, stats.dynamic_cap_in, VTY_NEWLINE);
+ vty_out (vty, " Total: %10d %10d%s", stats.open_out + stats.notify_out +
+ stats.update_out + stats.keepalive_out + stats.refresh_out + stats.dynamic_cap_out,
+ stats.open_in + stats.notify_in + stats.update_in + stats.keepalive_in + stats.refresh_in +
+ stats.dynamic_cap_in, VTY_NEWLINE);
/* advertisement-interval */
vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
@@ -7604,8 +7678,7 @@ bgp_show_peer (struct vty *vty, struct peer *p)
if (p->update_if)
vty_out (vty, "%s", p->update_if);
else if (p->update_source)
- vty_out (vty, "%s",
- sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
+ vty_out (vty, "%s", sutoa(p->update_source).str);
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -7649,9 +7722,10 @@ bgp_show_peer (struct vty *vty, struct peer *p)
/* EBGP Multihop and GTSM */
if (peer_sort (p) != BGP_PEER_IBGP)
{
- if (p->gtsm_hops > 0)
- vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
- p->gtsm_hops, VTY_NEWLINE);
+ if (p->gtsm)
+ vty_out (vty, " External BGP neighbor may be up to %d hops away"
+ " -- using GTSM.%s",
+ p->ttl, VTY_NEWLINE);
else if (p->ttl > 1)
vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
p->ttl, VTY_NEWLINE);
@@ -7661,16 +7735,16 @@ bgp_show_peer (struct vty *vty, struct peer *p)
if (p->su_local)
{
vty_out (vty, "Local host: %s, Local port: %d%s",
- sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
+ sutoa(p->su_local).str,
ntohs (p->su_local->sin.sin_port),
VTY_NEWLINE);
}
-
+
/* Remote address. */
if (p->su_remote)
{
vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
- sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
+ sutoa(p->su_remote).str,
ntohs (p->su_remote->sin.sin_port),
VTY_NEWLINE);
}
@@ -7678,15 +7752,15 @@ bgp_show_peer (struct vty *vty, struct peer *p)
/* Nexthop display. */
if (p->su_local)
{
- vty_out (vty, "Nexthop: %s%s",
- inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ),
+ vty_out (vty, "Nexthop: %s%s",
+ inet_ntop (AF_INET, &p->nexthop.v4, buf, sizeof(buf)),
VTY_NEWLINE);
#ifdef HAVE_IPV6
- vty_out (vty, "Nexthop global: %s%s",
- inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ),
+ vty_out (vty, "Nexthop global: %s%s",
+ inet_ntop (AF_INET6, &p->nexthop.v6_global, buf, sizeof(buf)),
VTY_NEWLINE);
vty_out (vty, "Nexthop local: %s%s",
- inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ),
+ inet_ntop (AF_INET6, &p->nexthop.v6_local, buf, sizeof(buf)),
VTY_NEWLINE);
vty_out (vty, "BGP connection: %s%s",
p->shared_network ? "shared network" : "non shared network",
@@ -7694,23 +7768,28 @@ bgp_show_peer (struct vty *vty, struct peer *p)
#endif /* HAVE_IPV6 */
}
- /* Timer information. */
+ /* TODO: Timer information. */
+#if 0
if (p->t_start)
vty_out (vty, "Next start timer due in %ld seconds%s",
thread_timer_remain_second (p->t_start), VTY_NEWLINE);
if (p->t_connect)
vty_out (vty, "Next connect timer due in %ld seconds%s",
thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
-
- vty_out (vty, "Read thread: %s Write thread: %s%s",
+#endif
+
+#if 0
+ vty_out (vty, "Read thread: %s Write thread: %s%s",
p->t_read ? "on" : "off",
p->t_write ? "on" : "off",
VTY_NEWLINE);
+#endif
- if (p->notify.code == BGP_NOTIFY_OPEN_ERR
- && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
+ if (p->session != NULL && p->session->notification != NULL
+ && p->session->notification->code == BGP_NOTIFY_OPEN_ERR
+ && p->session->notification->subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
bgp_capability_vty_out (vty, p);
-
+
vty_out (vty, "%s", VTY_NEWLINE);
}
@@ -7741,12 +7820,12 @@ bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
if (type == show_peer && ! find)
vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
-
+
return CMD_SUCCESS;
}
-static int
-bgp_show_neighbor_vty (struct vty *vty, const char *name,
+static int
+bgp_show_neighbor_vty (struct vty *vty, const char *name,
enum show_type type, const char *ip_str)
{
int ret;
@@ -7766,10 +7845,10 @@ bgp_show_neighbor_vty (struct vty *vty, const char *name,
if (name)
{
bgp = bgp_lookup_by_name (name);
-
+
if (! bgp)
{
- vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
+ vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
return CMD_WARNING;
}
@@ -7981,11 +8060,11 @@ ALIAS (show_ip_bgp_instance_neighbors_peer,
"Detailed information on TCP and BGP neighbor connections\n"
"Neighbor to display information about\n"
"Neighbor to display information about\n")
-
+
/* Show BGP's AS paths internal data. There are both `show ip bgp
paths' and `show ip mbgp paths'. Those functions results are the
same.*/
-DEFUN (show_ip_bgp_paths,
+DEFUN (show_ip_bgp_paths,
show_ip_bgp_paths_cmd,
"show ip bgp paths",
SHOW_STR
@@ -7998,7 +8077,7 @@ DEFUN (show_ip_bgp_paths,
return CMD_SUCCESS;
}
-DEFUN (show_ip_bgp_ipv4_paths,
+DEFUN (show_ip_bgp_ipv4_paths,
show_ip_bgp_ipv4_paths_cmd,
"show ip bgp ipv4 (unicast|multicast) paths",
SHOW_STR
@@ -8014,7 +8093,7 @@ DEFUN (show_ip_bgp_ipv4_paths,
return CMD_SUCCESS;
}
-
+
#include "hash.h"
static void
@@ -8028,7 +8107,7 @@ community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
}
/* Show BGP's community internal data. */
-DEFUN (show_ip_bgp_community_info,
+DEFUN (show_ip_bgp_community_info,
show_ip_bgp_community_info_cmd,
"show ip bgp community-info",
SHOW_STR
@@ -8038,7 +8117,7 @@ DEFUN (show_ip_bgp_community_info,
{
vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
- hash_iterate (community_hash (),
+ hash_iterate (community_hash (),
(void (*) (struct hash_backet *, void *))
community_show_all_iterator,
vty);
@@ -8046,7 +8125,7 @@ DEFUN (show_ip_bgp_community_info,
return CMD_SUCCESS;
}
-DEFUN (show_ip_bgp_attr_info,
+DEFUN (show_ip_bgp_attr_info,
show_ip_bgp_attr_info_cmd,
"show ip bgp attribute-info",
SHOW_STR
@@ -8057,7 +8136,7 @@ DEFUN (show_ip_bgp_attr_info,
attr_show_all (vty);
return CMD_SUCCESS;
}
-
+
static int
bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
afi_t afi, safi_t safi)
@@ -8080,8 +8159,8 @@ bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
return count;
}
- len = vty_out (vty, "%s", rsclient->host);
- len = 16 - len;
+ vty_out (vty, "%s", rsclient->host);
+ len = 16 - strlen(rsclient->host) ;
if (len < 1)
vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " ");
@@ -8119,7 +8198,7 @@ bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
else if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_PREFIX_OVERFLOW))
vty_out (vty, " Idle (PfxCt)");
else
- vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, rsclient->status));
+ vty_out (vty, " %-11s", LOOKUP(bgp_peer_status_msg, rsclient->state));
vty_out (vty, "%s", VTY_NEWLINE);
@@ -8127,7 +8206,7 @@ bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
}
static int
-bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
+bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
afi_t afi, safi_t safi)
{
struct peer *peer;
@@ -8146,7 +8225,7 @@ bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
{
vty_out (vty,
"Route Server's BGP router identifier %s%s",
- inet_ntoa (bgp->router_id), VTY_NEWLINE);
+ safe_inet_ntoa (bgp->router_id), VTY_NEWLINE);
vty_out (vty,
"Route Server's local AS number %u%s", bgp->as,
VTY_NEWLINE);
@@ -8170,7 +8249,7 @@ bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
}
static int
-bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
+bgp_show_rsclient_summary_vty (struct vty *vty, const char *name,
afi_t afi, safi_t safi)
{
struct bgp *bgp;
@@ -8378,7 +8457,7 @@ ALIAS (show_bgp_instance_ipv6_safi_rsclient_summary,
"Summary of all Route Server Clients\n")
#endif /* HAVE IPV6 */
-
+
/* Redistribute VTY commands. */
/* Utility function to convert user input route type string to route
@@ -8669,7 +8748,7 @@ ALIAS (no_bgp_redistribute_ipv4_rmap_metric,
"Default metric\n"
"Route map reference\n"
"Pointer to route-map entries\n")
-
+
#ifdef HAVE_IPV6
DEFUN (bgp_redistribute_ipv6,
bgp_redistribute_ipv6_cmd,
@@ -8924,7 +9003,7 @@ ALIAS (no_bgp_redistribute_ipv6_rmap_metric,
"Route map reference\n"
"Pointer to route-map entries\n")
#endif /* HAVE_IPV6 */
-
+
int
bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi, int *write)
@@ -8957,7 +9036,7 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
}
return *write;
}
-
+
/* BGP node structure. */
static struct cmd_node bgp_node =
{
@@ -9000,7 +9079,7 @@ static struct cmd_node bgp_vpnv4_node =
"%s(config-router-af)# ",
1
};
-
+
static void community_list_vty (void);
void
@@ -9021,7 +9100,7 @@ bgp_vty_init (void)
install_default (BGP_IPV6_NODE);
install_default (BGP_IPV6M_NODE);
install_default (BGP_VPNV4_NODE);
-
+
/* "bgp multiple-instance" commands. */
install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
@@ -9074,7 +9153,7 @@ bgp_vty_init (void)
/* "bgp always-compare-med" commands */
install_element (BGP_NODE, &bgp_always_compare_med_cmd);
install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
-
+
/* "bgp deterministic-med" commands */
install_element (BGP_NODE, &bgp_deterministic_med_cmd);
install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
@@ -9085,7 +9164,7 @@ bgp_vty_init (void)
install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_val_cmd);
-
+
/* "bgp fast-external-failover" commands */
install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
@@ -9121,7 +9200,7 @@ bgp_vty_init (void)
/* "no bgp default ipv4-unicast" commands. */
install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
-
+
/* "bgp network import-check" commands. */
install_element (BGP_NODE, &bgp_network_import_check_cmd);
install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
@@ -9175,7 +9254,7 @@ bgp_vty_init (void)
install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd);
install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd);
install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd);
-
+
/* "no neighbor peer-group unset" commands. */
install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd);
@@ -9183,7 +9262,7 @@ bgp_vty_init (void)
install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd);
install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd);
install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd);
-
+
/* "neighbor softreconfiguration inbound" commands.*/
install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd);
install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd);
@@ -9605,7 +9684,7 @@ bgp_vty_init (void)
install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
- install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
+ install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
/* "neighbor maximum-prefix" commands. */
install_element (BGP_NODE, &neighbor_maximum_prefix_cmd);
@@ -10112,16 +10191,16 @@ bgp_vty_init (void)
install_element (VIEW_NODE, &show_bgp_memory_cmd);
install_element (RESTRICTED_NODE, &show_bgp_memory_cmd);
install_element (ENABLE_NODE, &show_bgp_memory_cmd);
-
+
/* "show bgp views" commands. */
install_element (VIEW_NODE, &show_bgp_views_cmd);
install_element (RESTRICTED_NODE, &show_bgp_views_cmd);
install_element (ENABLE_NODE, &show_bgp_views_cmd);
-
+
/* Community-list. */
community_list_vty ();
}
-
+
#include "memory.h"
#include "bgp_regex.h"
#include "bgp_clist.h"
@@ -10167,7 +10246,7 @@ community_list_perror (struct vty *vty, int ret)
/* VTY interface for community_set() function. */
static int
-community_list_set_vty (struct vty *vty, int argc, const char **argv,
+community_list_set_vty (struct vty *vty, int argc, argv_t argv,
int style, int reject_all_digit_name)
{
int ret;
@@ -10220,7 +10299,7 @@ community_list_set_vty (struct vty *vty, int argc, const char **argv,
/* Communiyt-list entry delete. */
static int
-community_list_unset_vty (struct vty *vty, int argc, const char **argv,
+community_list_unset_vty (struct vty *vty, int argc, argv_t argv,
int style)
{
int ret;
@@ -10448,20 +10527,21 @@ community_list_show (struct vty *vty, struct community_list *list)
{
struct community_entry *entry;
+ const char* list_name = symbol_get_name(list->sym) ;
for (entry = list->head; entry; entry = entry->next)
{
if (entry == list->head)
{
- if (all_digit (list->name))
+ if (all_digit (list_name))
vty_out (vty, "Community %s list %s%s",
entry->style == COMMUNITY_LIST_STANDARD ?
"standard" : "(expanded) access",
- list->name, VTY_NEWLINE);
+ list_name, VTY_NEWLINE);
else
vty_out (vty, "Named Community %s list %s%s",
entry->style == COMMUNITY_LIST_STANDARD ?
"standard" : "expanded",
- list->name, VTY_NEWLINE);
+ list_name, VTY_NEWLINE);
}
if (entry->any)
vty_out (vty, " %s%s",
@@ -10482,18 +10562,26 @@ DEFUN (show_ip_community_list,
IP_STR
"List community-list\n")
{
+ struct symbol_table* table;
+ vector extract ;
+ vector_index i ;
+ struct symbol* sym ;
struct community_list *list;
- struct community_list_master *cm;
- cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
- if (! cm)
+ table = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
+ if (table == NULL)
return CMD_SUCCESS;
- for (list = cm->num.head; list; list = list->next)
- community_list_show (vty, list);
+ extract = symbol_table_extract(table, NULL, NULL, 0, symbol_mixed_name_cmp) ;
+
+ for (VECTOR_ITEMS(extract, sym, i))
+ {
+ list = symbol_get_value(sym) ;
+ if (list != NULL)
+ community_list_show (vty, list);
+ } ;
- for (list = cm->str.head; list; list = list->next)
- community_list_show (vty, list);
+ vector_free(extract) ; /* discard temporary vector */
return CMD_SUCCESS;
}
@@ -10520,9 +10608,9 @@ DEFUN (show_ip_community_list_arg,
return CMD_SUCCESS;
}
-
+
static int
-extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
+extcommunity_list_set_vty (struct vty *vty, int argc, argv_t argv,
int style, int reject_all_digit_name)
{
int ret;
@@ -10570,8 +10658,7 @@ extcommunity_list_set_vty (struct vty *vty, int argc, const char **argv,
}
static int
-extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
- int style)
+extcommunity_list_unset_vty (struct vty *vty, int argc, argv_t argv, int style)
{
int ret;
int direct = 0;
@@ -10798,20 +10885,22 @@ extcommunity_list_show (struct vty *vty, struct community_list *list)
{
struct community_entry *entry;
+ const char* list_name = symbol_get_name(list->sym) ;
+
for (entry = list->head; entry; entry = entry->next)
{
if (entry == list->head)
{
- if (all_digit (list->name))
+ if (all_digit (list_name))
vty_out (vty, "Extended community %s list %s%s",
entry->style == EXTCOMMUNITY_LIST_STANDARD ?
"standard" : "(expanded) access",
- list->name, VTY_NEWLINE);
+ list_name, VTY_NEWLINE);
else
vty_out (vty, "Named extended community %s list %s%s",
entry->style == EXTCOMMUNITY_LIST_STANDARD ?
"standard" : "expanded",
- list->name, VTY_NEWLINE);
+ list_name, VTY_NEWLINE);
}
if (entry->any)
vty_out (vty, " %s%s",
@@ -10832,18 +10921,26 @@ DEFUN (show_ip_extcommunity_list,
IP_STR
"List extended-community list\n")
{
+ struct symbol_table* table;
+ vector extract ;
+ vector_index i ;
+ struct symbol* sym ;
struct community_list *list;
- struct community_list_master *cm;
- cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
- if (! cm)
+ table = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
+ if (table == NULL)
return CMD_SUCCESS;
- for (list = cm->num.head; list; list = list->next)
- extcommunity_list_show (vty, list);
+ extract = symbol_table_extract(table, NULL, NULL, 0, symbol_mixed_name_cmp) ;
+
+ for (VECTOR_ITEMS(extract, sym, i))
+ {
+ list = symbol_get_value(sym) ;
+ if (list != NULL)
+ extcommunity_list_show (vty, list);
+ } ;
- for (list = cm->str.head; list; list = list->next)
- extcommunity_list_show (vty, list);
+ vector_free(extract) ; /* discard temporary vector */
return CMD_SUCCESS;
}
@@ -10870,7 +10967,7 @@ DEFUN (show_ip_extcommunity_list_arg,
return CMD_SUCCESS;
}
-
+
/* Return configuration string of community-list entry. */
static const char *
community_list_config_str (struct community_entry *entry)
@@ -10889,60 +10986,80 @@ community_list_config_str (struct community_entry *entry)
return str;
}
-/* Display community-list and extcommunity-list configuration. */
+/* Put entire community-list or extcommunity-list. */
static int
-community_list_config_write (struct vty *vty)
+community_list_config_write_list(struct vty* vty, int what)
{
+ struct symbol_table* table;
struct community_list *list;
struct community_entry *entry;
- struct community_list_master *cm;
+ vector extract ;
+ vector_index i ;
+ struct symbol* sym ;
+
int write = 0;
- /* Community-list. */
- cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
-
- for (list = cm->num.head; list; list = list->next)
- for (entry = list->head; entry; entry = entry->next)
- {
- vty_out (vty, "ip community-list %s %s %s%s",
- list->name, community_direct_str (entry->direct),
- community_list_config_str (entry),
- VTY_NEWLINE);
- write++;
- }
- for (list = cm->str.head; list; list = list->next)
- for (entry = list->head; entry; entry = entry->next)
- {
- vty_out (vty, "ip community-list %s %s %s %s%s",
- entry->style == COMMUNITY_LIST_STANDARD
- ? "standard" : "expanded",
- list->name, community_direct_str (entry->direct),
- community_list_config_str (entry),
- VTY_NEWLINE);
- write++;
- }
+ table = community_list_master_lookup (bgp_clist, what);
+
+ extract = symbol_table_extract(table, NULL, NULL, 0, symbol_mixed_name_cmp) ;
+ 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 = "" ;
+ const char* list_style = "" ;
+ const char* list_name = symbol_get_name(list->sym) ;
+
+ switch (entry->style)
+ {
+ case COMMUNITY_LIST_STANDARD:
+ list_type = "community-list" ;
+ list_style = "standard " ;
+ break ;
+ case COMMUNITY_LIST_EXPANDED:
+ list_type = "community-list" ;
+ list_style = "expanded " ;
+ break ;
+ case EXTCOMMUNITY_LIST_STANDARD:
+ list_type = "extcommunity-list" ;
+ list_style = "standard " ;
+ break ;
+ case EXTCOMMUNITY_LIST_EXPANDED:
+ list_type = "extcommunity-list" ;
+ list_style = "expanded " ;
+ break ;
+ } ;
+ if (all_digit(list_name))
+ list_style = "" ; /* squash style for all digit names */
+
+ vty_out (vty, "ip %s %s%s %s %s%s",
+ list_type, list_style, list_name,
+ community_direct_str (entry->direct),
+ community_list_config_str (entry),
+ VTY_NEWLINE);
+ write++;
+ }
+ }
+
+ vector_free(extract) ; /* discard temporary vector */
+
+ return write;
+}
+
+/* Display community-list and extcommunity-list configuration. */
+static int
+community_list_config_write (struct vty *vty)
+{
+ int write = 0;
+
+ write += community_list_config_write_list(vty, COMMUNITY_LIST_MASTER) ;
+ write += community_list_config_write_list(vty, EXTCOMMUNITY_LIST_MASTER);
- /* Extcommunity-list. */
- cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
-
- for (list = cm->num.head; list; list = list->next)
- for (entry = list->head; entry; entry = entry->next)
- {
- vty_out (vty, "ip extcommunity-list %s %s %s%s",
- list->name, community_direct_str (entry->direct),
- community_list_config_str (entry), VTY_NEWLINE);
- write++;
- }
- for (list = cm->str.head; list; list = list->next)
- for (entry = list->head; entry; entry = entry->next)
- {
- vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
- entry->style == EXTCOMMUNITY_LIST_STANDARD
- ? "standard" : "expanded",
- list->name, community_direct_str (entry->direct),
- community_list_config_str (entry), VTY_NEWLINE);
- write++;
- }
return write;
}