#include "command.h"
#include "stream.h"
#include "filter.h"
-#include "str.h"
#include "log.h"
#include "routemap.h"
#include "buffer.h"
{
if (peer_sort (new->peer) == BGP_PEER_IBGP
&& peer_sort (exist->peer) == BGP_PEER_IBGP
- && CHECK_FLAG (mpath_cfg->ibgp_flags,
- BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
+ && (mpath_cfg == NULL ||
+ CHECK_FLAG (mpath_cfg->ibgp_flags,
+ BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)))
{
newm = BGP_CLUSTER_LIST_LENGTH(new->attr);
existm = BGP_CLUSTER_LIST_LENGTH(exist->attr);
afi_t afi, safi_t safi)
{
int paths_eq;
- struct bgp_maxpaths_cfg mpath_cfg;
int ret;
- ret = bgp_info_cmp (bgp, new, exist, &paths_eq, &mpath_cfg, 0, __func__);
+ ret = bgp_info_cmp (bgp, new, exist, &paths_eq, NULL, 0, __func__);
if (paths_eq)
ret = 0;
filter = &peer->filter[afi][safi];
/* Apply default weight value. */
- if (peer->weight)
- (bgp_attr_extra_get (attr))->weight = peer->weight;
+ if (peer->weight[afi][safi])
+ (bgp_attr_extra_get (attr))->weight = peer->weight[afi][safi];
if (rmap_name)
{
filter = &peer->filter[afi][safi];
/* Apply default weight value. */
- if (peer->weight)
- (bgp_attr_extra_get (attr))->weight = peer->weight;
+ if (peer->weight[afi][safi])
+ (bgp_attr_extra_get (attr))->weight = peer->weight[afi][safi];
if (rmap_name)
{
#ifdef HAVE_IPV6
#define NEXTHOP_IS_V6 (\
- (safi != SAFI_ENCAP && \
+ (safi != SAFI_ENCAP && safi != SAFI_MPLS_VPN &&\
(p->family == AF_INET6 || peer_cap_enhe(peer))) || \
- (safi == SAFI_ENCAP && attr->extra->mp_nexthop_len == 16))
+ ((safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN) &&\
+ attr->extra->mp_nexthop_len >= IPV6_MAX_BYTELEN))
/* IPv6/MP starts with 1 nexthop. The link-local address is passed only if
* the peer (group) is configured to receive link-local nexthop unchanged
{
bgp_info_path_with_addpath_rx_str (new_select, path_buf);
zlog_debug("%s: %s is the bestpath from AS %d",
- pfx_buf, path_buf, aspath_get_firstas(new_select->attr->aspath));
+ pfx_buf, path_buf, aspath_get_first_as(new_select->attr->aspath));
}
}
}
PEER_STATUS_ORF_WAIT_REFRESH))
return 0;
+ memset(&extra, 0, sizeof(struct attr_extra));
/* It's initialized in bgp_announce_check() */
attr.extra = &extra;
return;
if (bm->process_main_queue == NULL)
- bgp_process_queue_init ();
+ return;
pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
sizeof (struct bgp_process_queue));
struct bgp_process_queue *pqnode;
if (bm->process_main_queue == NULL)
- bgp_process_queue_init ();
+ return;
pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
sizeof (struct bgp_process_queue));
{
if (addpath_id)
sprintf(buf, " with addpath ID %d", addpath_id);
+ else
+ buf[0] = '\0';
}
#ifdef HAVE_IPV6
case BGP_ATTR_NHLEN_IPV6_GLOBAL:
case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL:
+ case BGP_ATTR_NHLEN_VPNV6_GLOBAL:
ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) ||
IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) ||
IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global));
char buf[SU_ADDRSTRLEN];
char buf2[30];
int connected = 0;
+ int do_loop_check = 1;
#if ENABLE_BGP_VNC
int vnc_implicit_withdraw = 0;
#endif
+ memset (&new_attr, 0, sizeof(struct attr));
+ memset (&new_extra, 0, sizeof(struct attr_extra));
+
bgp = peer->bgp;
rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, p, prd);
}
}
+ /* If the peer is configured for "allowas-in origin" and the last ASN in the
+ * as-path is our ASN then we do not need to call aspath_loop_check
+ */
+ if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN_ORIGIN))
+ if (aspath_get_last_as(attr->aspath) == bgp->as)
+ do_loop_check = 0;
+
/* AS path loop check. */
- if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
- || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
- && aspath_loop_check(attr->aspath, bgp->confed_id)
- > peer->allowas_in[afi][safi]))
+ if (do_loop_check)
{
- reason = "as-path contains our own AS;";
- goto filtered;
+ if (aspath_loop_check (attr->aspath, bgp->as) > peer->allowas_in[afi][safi]
+ || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
+ && aspath_loop_check(attr->aspath, bgp->confed_id) > peer->allowas_in[afi][safi]))
+ {
+ reason = "as-path contains our own AS;";
+ goto filtered;
+ }
}
/* Route reflector originator ID check. */
bgp_process (bgp, rn, afi, safi);
bgp_unlock_node (rn);
+#if ENABLE_BGP_VNC
+ if (SAFI_MPLS_VPN == safi)
+ {
+ uint32_t label = decode_label(tag);
+
+ rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+ &label);
+ }
+ if (SAFI_ENCAP == safi)
+ {
+ rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+ NULL);
+ }
+#endif
+
return 0;
} // End of implicit withdraw
/* Process change. */
bgp_process (bgp, rn, afi, safi);
+#if ENABLE_BGP_VNC
+ if (SAFI_MPLS_VPN == safi)
+ {
+ uint32_t label = decode_label(tag);
+
+ rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+ &label);
+ }
+ if (SAFI_ENCAP == safi)
+ {
+ rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+ NULL);
+ }
+#endif
+
return 0;
/* This BGP update is filtered. Log the reason then update BGP
bgp_unlock_node (rn);
+#if ENABLE_BGP_VNC
+ /*
+ * Filtered update is treated as an implicit withdrawal (see bgp_rib_remove()
+ * a few lines above)
+ */
+ if ((SAFI_MPLS_VPN == safi) || (SAFI_ENCAP == safi))
+ {
+ rfapiProcessWithdraw(peer, NULL, p, prd, NULL, afi, safi, type, 0);
+ }
+#endif
+
return 0;
}
struct bgp_node *rn;
struct bgp_info *ri;
+#if ENABLE_BGP_VNC
+ if ((SAFI_MPLS_VPN == safi) || (SAFI_ENCAP == safi))
+ {
+ rfapiProcessWithdraw(peer, NULL, p, prd, NULL, afi, safi, type, 0);
+ }
+#endif
+
bgp = peer->bgp;
/* Lookup node. */
struct bgp_table *table)
{
struct bgp_node *rn;
-
+ int force = bm->process_main_queue ? 0 : 1;
if (! table)
table = peer->bgp->rib[afi][safi];
for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn))
{
- struct bgp_info *ri;
+ struct bgp_info *ri, *next;
struct bgp_adj_in *ain;
struct bgp_adj_in *ain_next;
ain = ain_next;
}
- for (ri = rn->info; ri; ri = ri->next)
- if (ri->peer == peer)
- {
- struct bgp_clear_node_queue *cnq;
-
- /* both unlocked in bgp_clear_node_queue_del */
- bgp_table_lock (bgp_node_table (rn));
- bgp_lock_node (rn);
- cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
- sizeof (struct bgp_clear_node_queue));
- cnq->rn = rn;
- work_queue_add (peer->clear_node_queue, cnq);
- break;
- }
+ for (ri = rn->info; ri; ri = next)
+ {
+ next = ri->next;
+ if (ri->peer != peer)
+ continue;
+
+ if (force)
+ bgp_info_reap (rn, ri);
+ else
+ {
+ struct bgp_clear_node_queue *cnq;
+
+ /* both unlocked in bgp_clear_node_queue_del */
+ bgp_table_lock (bgp_node_table (rn));
+ bgp_lock_node (rn);
+ cnq = XCALLOC (MTYPE_BGP_CLEAR_NODE_QUEUE,
+ sizeof (struct bgp_clear_node_queue));
+ cnq->rn = rn;
+ work_queue_add (peer->clear_node_queue, cnq);
+ break;
+ }
+ }
}
return;
}
vnc_import_bgp_del_route(table->owner->bgp, &rn->p, ri);
#endif
bgp_zebra_withdraw (&rn->p, ri, safi);
+ bgp_info_reap (rn, ri);
}
}
}
/* Delete all kernel routes. */
void
-bgp_cleanup_routes (void)
+bgp_cleanup_routes (struct bgp *bgp)
{
- struct bgp *bgp;
- struct listnode *node, *nnode;
afi_t afi;
- for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
+ for (afi = AFI_IP; afi < AFI_MAX; ++afi)
{
- for (afi = AFI_IP; afi < AFI_MAX; ++afi)
- {
- struct bgp_node *rn;
+ struct bgp_node *rn;
- bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
+ bgp_cleanup_table(bgp->rib[afi][SAFI_UNICAST], SAFI_UNICAST);
- /*
- * VPN and ENCAP tables are two-level (RD is top level)
- */
- for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
- rn = bgp_route_next (rn))
+ /*
+ * VPN and ENCAP tables are two-level (RD is top level)
+ */
+ for (rn = bgp_table_top(bgp->rib[afi][SAFI_MPLS_VPN]); rn;
+ rn = bgp_route_next (rn))
+ {
+ if (rn->info)
{
- if (rn->info)
- {
- bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
- bgp_table_finish ((struct bgp_table **)&(rn->info));
- rn->info = NULL;
- bgp_unlock_node(rn);
- }
+ bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_MPLS_VPN);
+ bgp_table_finish ((struct bgp_table **)&(rn->info));
+ rn->info = NULL;
+ bgp_unlock_node(rn);
}
+ }
- for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
- rn = bgp_route_next (rn))
+ for (rn = bgp_table_top(bgp->rib[afi][SAFI_ENCAP]); rn;
+ rn = bgp_route_next (rn))
+ {
+ if (rn->info)
{
- if (rn->info)
- {
- bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
- bgp_table_finish ((struct bgp_table **)&(rn->info));
- rn->info = NULL;
- bgp_unlock_node(rn);
- }
+ bgp_cleanup_table((struct bgp_table *)(rn->info), SAFI_ENCAP);
+ bgp_table_finish ((struct bgp_table **)&(rn->info));
+ rn->info = NULL;
+ bgp_unlock_node(rn);
}
}
}
/* Parse NLRI stream. Withdraw NLRI is recognized by NULL attr
value. */
int
-bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet)
+bgp_nlri_parse_ip (struct peer *peer, struct attr *attr,
+ struct bgp_nlri *packet)
{
u_char *pnt;
u_char *lim;
addpath_id = 0;
addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi);
+ /* RFC4771 6.3 The NLRI field in the UPDATE message is checked for
+ syntactic validity. If the field is syntactically incorrect,
+ then the Error Subcode is set to Invalid Network Field. */
for (; pnt < lim; pnt += psize)
{
/* Clear prefix structure. */
/* Fetch prefix length. */
p.prefixlen = *pnt++;
+ /* afi/safi validity already verified by caller, bgp_update_receive */
p.family = afi2family (afi);
-
- /* Already checked in nlri_sanity_check(). We do double check
- here. */
- if ((afi == AFI_IP && p.prefixlen > 32)
- || (afi == AFI_IP6 && p.prefixlen > 128))
- return -1;
+
+ /* Prefix length check. */
+ if (p.prefixlen > prefix_blen (&p) * 8)
+ {
+ zlog_err("%s [Error] Update packet error (wrong perfix length %d for afi %u)",
+ peer->host, p.prefixlen, packet->afi);
+ return -1;
+ }
/* Packet size overflow check. */
psize = PSIZE (p.prefixlen);
/* When packet overflow occur return immediately. */
if (pnt + psize > lim)
- return -1;
+ {
+ zlog_err("%s [Error] Update packet error (prefix length %d overflows packet)",
+ peer->host, p.prefixlen);
+ return -1;
+ }
+
+ /* Defensive coding, double-check the psize fits in a struct prefix */
+ if (psize > (ssize_t) sizeof(p.u))
+ {
+ zlog_err("%s [Error] Update packet error (prefix length %d too large for prefix storage %zu)",
+ peer->host, p.prefixlen, sizeof(p.u));
+ return -1;
+ }
/* Fetch prefix from NLRI packet. */
memcpy (&p.u.prefix, pnt, psize);
{
if (IN_CLASSD (ntohl (p.u.prefix4.s_addr)))
{
- /*
- * From draft-ietf-idr-bgp4-22, Section 6.3:
- * If a BGP router receives an UPDATE message with a
- * semantically incorrect NLRI field, in which a prefix is
- * semantically incorrect (eg. an unexpected multicast IP
- * address), it should ignore the prefix.
- */
- zlog_err ("IPv4 unicast NLRI is multicast address %s",
- inet_ntoa (p.u.prefix4));
-
- return -1;
+ /* From RFC4271 Section 6.3:
+ *
+ * If a prefix in the NLRI field is semantically incorrect
+ * (e.g., an unexpected multicast IP address), an error SHOULD
+ * be logged locally, and the prefix SHOULD be ignored.
+ */
+ zlog_err ("%s: IPv4 unicast NLRI is multicast address %s, ignoring",
+ peer->host, inet_ntoa (p.u.prefix4));
+ continue;
}
}
{
char buf[BUFSIZ];
- zlog_warn ("IPv6 link-local NLRI received %s ignore this NLRI",
- inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
+ zlog_err ("%s: IPv6 unicast NLRI is link-local address %s, ignoring",
+ peer->host, inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
+
+ continue;
+ }
+ if (IN6_IS_ADDR_MULTICAST (&p.u.prefix6))
+ {
+ char buf[BUFSIZ];
+
+ zlog_err ("%s: IPv6 unicast NLRI is multicast address %s, ignoring",
+ peer->host, inet_ntop (AF_INET6, &p.u.prefix6, buf, BUFSIZ));
continue;
}
/* Packet length consistency check. */
if (pnt != lim)
- return -1;
-
- return 0;
-}
-
-/* NLRI encode syntax check routine. */
-int
-bgp_nlri_sanity_check (struct peer *peer, int afi, safi_t safi, u_char *pnt,
- bgp_size_t length, int *numpfx)
-{
- u_char *end;
- u_char prefixlen;
- int psize;
- int addpath_encoded;
-
- *numpfx = 0;
- end = pnt + length;
- addpath_encoded = bgp_addpath_encode_rx (peer, afi, safi);
-
- /* RFC1771 6.3 The NLRI field in the UPDATE message is checked for
- syntactic validity. If the field is syntactically incorrect,
- then the Error Subcode is set to Invalid Network Field. */
-
- while (pnt < end)
{
- int badlength;
-
- /* If the NLRI is encoded using addpath then the first 4 bytes are
- * the addpath ID. */
- if (addpath_encoded)
- {
- if (pnt + BGP_ADDPATH_ID_LEN > end)
- {
- zlog_err ("%s [Error] Update packet error"
- " (prefix data addpath overflow)",
- peer->host);
- bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_INVAL_NETWORK);
- return -1;
- }
- pnt += BGP_ADDPATH_ID_LEN;
- }
-
- prefixlen = *pnt++;
-
- /* Prefix length check. */
- badlength = 0;
- if (safi == SAFI_ENCAP) {
- if (prefixlen > 128)
- badlength = 1;
- } else {
- if ((afi == AFI_IP && prefixlen > 32) ||
- (afi == AFI_IP6 && prefixlen > 128)) {
-
- badlength = 1;
- }
- }
- if (badlength)
- {
- zlog_err ("%s [Error] Update packet error (wrong prefix length %d)",
- peer->host, prefixlen);
- bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_INVAL_NETWORK);
- return -1;
- }
-
- /* Packet size overflow check. */
- psize = PSIZE (prefixlen);
-
- if (pnt + psize > end)
- {
- zlog_err ("%s [Error] Update packet error"
- " (prefix data overflow prefix size is %d)",
- peer->host, psize);
- bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_INVAL_NETWORK);
- return -1;
- }
-
- pnt += psize;
- (*numpfx)++;
- }
-
- /* Packet length consistency check. */
- if (pnt != end)
- {
- zlog_err ("%s [Error] Update packet error"
- " (prefix length mismatch with total length)",
- peer->host);
- bgp_notify_send (peer, BGP_NOTIFY_UPDATE_ERR,
- BGP_NOTIFY_UPDATE_INVAL_NETWORK);
+ zlog_err ("%s [Error] Update packet error (prefix length mismatch with total length)",
+ peer->host);
return -1;
}
+
return 0;
}
return 0;
}
-
DEFUN (bgp_table_map,
bgp_table_map_cmd,
"table-map WORD",
if (json_paths)
json_object_int_add(json_path, "med", attr->med);
else
- vty_out (vty, "%10u ", attr->med);
+ vty_out (vty, "%10u", attr->med);
else
if (!json_paths)
vty_out (vty, " ");
if (json_paths)
json_object_int_add(json_path, "localpref", attr->local_pref);
else
- vty_out (vty, "%7u ", attr->local_pref);
+ vty_out (vty, "%7u", attr->local_pref);
else
if (!json_paths)
vty_out (vty, " ");
vty_out (vty, "%s", VTY_NEWLINE);
#if ENABLE_BGP_VNC
/* prints an additional line, indented, with VNC info, if present */
- if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || (safi == SAFI_UNICAST))
+ if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
rfapi_vty_out_vncinfo(vty, p, binfo, safi);
#endif
}
safi == SAFI_ENCAP ||
!BGP_ATTR_NEXTHOP_AFI_IP6(attr)))
{
- if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)
+ if (attr->extra &&
+ (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP))
vty_out (vty, "%-16s",
inet_ntoa (attr->extra->mp_nexthop_global_in));
else
{
int len;
char buf[BUFSIZ];
-
- assert (attr->extra);
-
- len = vty_out (vty, "%s",
- inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
- buf, BUFSIZ));
- len = 16 - len;
+ if (attr->extra)
+ {
+ len = vty_out (vty, "%s",
+ inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global,
+ buf, BUFSIZ));
+ len = 16 - len;
+ }
+ else
+ len = 0;
if (len < 1)
vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " ");
else
}
#endif /* HAVE_IPV6 */
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
- vty_out (vty, "%10u ", attr->med);
+ vty_out (vty, "%10u", attr->med);
else
vty_out (vty, " ");
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
- vty_out (vty, "%7u ", attr->local_pref);
+ vty_out (vty, "%7u", attr->local_pref);
else
vty_out (vty, " ");
struct peer *peer;
int addpath_capable;
int has_adj;
- int first_as;
+ unsigned int first_as;
if (json_paths)
{
// Mark the bestpath(s)
if (CHECK_FLAG (binfo->flags, BGP_INFO_DMED_SELECTED))
{
- first_as = aspath_get_firstas(attr->aspath);
+ first_as = aspath_get_first_as(attr->aspath);
if (json_paths)
{
safi_t safi, enum bgp_show_type type);
static int
-bgp_show_table (struct vty *vty, struct bgp_table *table,
- struct in_addr *router_id, enum bgp_show_type type,
- void *output_arg, u_char use_json, json_object *json)
+bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table,
+ enum bgp_show_type type, void *output_arg, u_char use_json)
{
struct bgp_info *ri;
struct bgp_node *rn;
char buf[BUFSIZ];
char buf2[BUFSIZ];
json_object *json_paths = NULL;
- json_object *json_routes = NULL;
+ int first = 1;
if (use_json)
{
- if (json == NULL)
- json = json_object_new_object();
-
- json_object_int_add(json, "tableVersion", table->version);
- json_object_string_add(json, "routerId", inet_ntoa (*router_id));
- json_routes = json_object_new_object();
+ vty_out (vty, "{ \"vrfId\": %d, \"vrfName\": \"%s\", \"tableVersion\": %" PRId64 ", \"routerId\": \"%s\", \"routes\": { ",
+ bgp->vrf_id == VRF_UNKNOWN ? -1 : bgp->vrf_id,
+ bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? "Default" : bgp->name,
+ table->version, inet_ntoa (bgp->router_id));
+ json_paths = json_object_new_object();
}
/* This is first entry point, so reset total line. */
if (rn->info != NULL)
{
display = 0;
-
+ if (!first && use_json)
+ {
+ vty_out (vty, ",");
+ }
if (use_json)
json_paths = json_object_new_array();
else
if (!use_json && header)
{
- vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (*router_id), VTY_NEWLINE);
+ vty_out (vty, "BGP table version is %" PRIu64 ", local router ID is %s%s", table->version, inet_ntoa (bgp->router_id), VTY_NEWLINE);
vty_out (vty, BGP_SHOW_SCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
vty_out (vty, BGP_SHOW_OCODE_HEADER, VTY_NEWLINE, VTY_NEWLINE);
if (type == bgp_show_type_dampend_paths
{
p = &rn->p;
sprintf(buf2, "%s/%d", inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen);
- json_object_object_add(json_routes, buf2, json_paths);
+ vty_out (vty, "\"%s\": ", buf2);
+ vty_out (vty, "%s", json_object_to_json_string (json_paths));
+ json_object_free (json_paths);
+ first = 0;
+
}
}
}
if (use_json)
{
- /* This can produce a LOT of text so do not use
- * JSON_C_TO_STRING_PRETTY here
- */
- json_object_object_add(json, "routes", json_routes);
- vty_out (vty, "%s%s", json_object_to_json_string(json), VTY_NEWLINE);
- json_object_free(json);
+ json_object_free (json_paths);
+ vty_out (vty, " } }%s", VTY_NEWLINE);
}
else
{
vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
}
else
- vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s",
+ vty_out (vty, "%sDisplayed %ld routes and %ld total paths%s",
VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
}
table = bgp->rib[afi][safi];
- return bgp_show_table (vty, table, &bgp->router_id, type, output_arg,
- use_json, NULL);
+ return bgp_show_table (vty, bgp, table, type, output_arg,
+ use_json);
}
static void
struct listnode *node, *nnode;
struct bgp *bgp;
struct bgp_table *table;
- json_object *json = NULL;
int is_first = 1;
if (use_json)
{
if (use_json)
{
- if (!(json = json_object_new_object()))
- {
- zlog_err("Unable to allocate memory for JSON object");
- vty_out (vty,
- "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
- VTY_NEWLINE);
- return;
- }
- json_object_int_add(json, "vrfId",
- (bgp->vrf_id == VRF_UNKNOWN)
- ? -1 : bgp->vrf_id);
- json_object_string_add(json, "vrfName",
- (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
- ? "Default" : bgp->name);
if (! is_first)
vty_out (vty, ",%s", VTY_NEWLINE);
else
VTY_NEWLINE);
}
table = bgp->rib[afi][safi];
- bgp_show_table (vty, table, &bgp->router_id,
- bgp_show_type_normal, NULL, use_json, json);
+ bgp_show_table (vty, bgp, table,
+ bgp_show_type_normal, NULL, use_json);
}
return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, use_json(argc, argv));
}
+ALIAS (show_ip_bgp,
+ show_bgp_ipv4_cmd,
+ "show bgp ipv4 {json}",
+ SHOW_STR
+ IP_STR
+ BGP_STR
+ "Address family\n"
+ "JavaScript Object Notation\n")
+
DEFUN (show_ip_bgp_ipv4,
show_ip_bgp_ipv4_cmd,
"show ip bgp ipv4 (unicast|multicast) {json}",
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
-
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal,
- NULL, uj);
- return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj);
+ return bgp_show (vty, NULL, AFI_IP,
+ bgp_vty_safi_from_arg(argv[0]),
+ bgp_show_type_normal, NULL, uj);
}
ALIAS (show_ip_bgp_ipv4,
DEFUN (show_bgp_ipv4_safi_route_pathtype,
show_bgp_ipv4_safi_route_pathtype_cmd,
- "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}",
+ "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D (bestpath|multipath) {json}",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Display only the bestpath\n"
"Display only multipaths\n"
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj);
+ if (strncmp (argv[2], "b", 1) == 0)
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 0, BGP_PATH_BESTPATH, uj);
else
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 0, BGP_PATH_MULTIPATH, uj);
}
DEFUN (show_bgp_ipv4_prefix,
DEFUN (show_ip_bgp_ipv4_route,
show_ip_bgp_ipv4_route_cmd,
- "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
+ "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D {json}",
SHOW_STR
IP_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"Network in the BGP routing table to display\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj);
-
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 0, BGP_PATH_ALL, uj);
}
ALIAS (show_ip_bgp_ipv4_route,
show_bgp_ipv4_safi_route_cmd,
- "show bgp ipv4 (unicast|multicast) A.B.C.D {json}",
- SHOW_STR
- BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Network in the BGP routing table to display\n"
- "JavaScript Object Notation\n")
-
-DEFUN (show_ip_bgp_vpnv4_all_route,
- show_ip_bgp_vpnv4_all_route_cmd,
- "show ip bgp vpnv4 all A.B.C.D {json}",
+ "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D {json}",
SHOW_STR
- IP_STR
BGP_STR
- "Display VPNv4 NLRI specific information\n"
- "Display information about all VPNv4 NLRIs\n"
+ BGP_AFI_SAFI_HELP_STR
"Network in the BGP routing table to display\n"
"JavaScript Object Notation\n")
-{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv));
-}
-DEFUN (show_bgp_ipv4_vpn_route,
- show_bgp_ipv4_vpn_route_cmd,
- "show bgp ipv4 vpn A.B.C.D {json}",
+DEFUN (show_bgp_ipv4_safi_rd_route,
+ show_bgp_ipv4_safi_rd_route_cmd,
+ "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
SHOW_STR
BGP_STR
"Address Family\n"
- "Display VPN NLRI specific information\n"
- "Network in the BGP routing table to display\n"
- JSON_STR)
+ "Address Family Modifier\n"
+ "Address Family Modifier\n"
+ "Display information for a route distinguisher\n"
+ "ENCAP Route Distinguisher\n"
+ "Network in the BGP routing table to display\n")
{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv));
-}
+ int ret;
+ struct prefix_rd prd;
+ safi_t safi;
-DEFUN (show_bgp_ipv6_vpn_route,
- show_bgp_ipv6_vpn_route_cmd,
- "show bgp ipv6 vpn X:X::X:X {json}",
- SHOW_STR
- BGP_STR
- "Address Family\n"
- "Display VPN NLRI specific information\n"
- "Network in the BGP routing table to display\n"
- JSON_STR)
-{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv));
+ if (bgp_parse_safi(argv[0], &safi)) {
+ vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ ret = str2prefix_rd (argv[1], &prd);
+ if (! ret)
+ {
+ vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL, use_json (argc, argv));
}
-DEFUN (show_bgp_ipv4_vpn_rd_route,
- show_bgp_ipv4_vpn_rd_route_cmd,
- "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
+DEFUN (show_bgp_ipv6_safi_rd_route,
+ show_bgp_ipv6_safi_rd_route_cmd,
+ "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
SHOW_STR
BGP_STR
- IP_STR
- "Display VPN NLRI specific information\n"
+ "Address Family\n"
+ "Address Family Modifier\n"
+ "Address Family Modifier\n"
"Display information for a route distinguisher\n"
- "VPN Route Distinguisher\n"
- "Network in the BGP routing table to display\n"
- JSON_STR)
+ "ENCAP Route Distinguisher\n"
+ "Network in the BGP routing table to display\n")
{
int ret;
struct prefix_rd prd;
+ safi_t safi;
- ret = str2prefix_rd (argv[0], &prd);
+ if (bgp_parse_safi(argv[0], &safi)) {
+ vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ ret = str2prefix_rd (argv[1], &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv));
+ return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL, use_json (argc, argv));
}
-DEFUN (show_bgp_ipv6_vpn_rd_route,
- show_bgp_ipv6_vpn_rd_route_cmd,
- "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}",
+
+DEFUN (show_bgp_ipv4_safi_rd_prefix,
+ show_bgp_ipv4_safi_rd_prefix_cmd,
+ "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
SHOW_STR
BGP_STR
"Address Family\n"
- "Display VPN NLRI specific information\n"
+ "Address Family Modifier\n"
+ "Address Family Modifier\n"
"Display information for a route distinguisher\n"
- "VPN Route Distinguisher\n"
- "Network in the BGP routing table to display\n"
- JSON_STR)
+ "ENCAP Route Distinguisher\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
{
int ret;
struct prefix_rd prd;
+ safi_t safi;
- ret = str2prefix_rd (argv[0], &prd);
+ if (bgp_parse_safi(argv[0], &safi)) {
+ vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ ret = str2prefix_rd (argv[1], &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv));
+ return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv));
}
-DEFUN (show_ip_bgp_vpnv4_rd_route,
- show_ip_bgp_vpnv4_rd_route_cmd,
- "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}",
+DEFUN (show_bgp_ipv6_safi_rd_prefix,
+ show_bgp_ipv6_safi_rd_prefix_cmd,
+ "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}",
SHOW_STR
- IP_STR
BGP_STR
- "Display VPNv4 NLRI specific information\n"
+ "Address Family\n"
+ "Address Family Modifier\n"
+ "Address Family Modifier\n"
"Display information for a route distinguisher\n"
- "VPN Route Distinguisher\n"
- "Network in the BGP routing table to display\n"
- "JavaScript Object Notation\n")
+ "ENCAP Route Distinguisher\n"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n")
{
int ret;
struct prefix_rd prd;
- u_char uj= use_json(argc, argv);
+ safi_t safi;
- ret = str2prefix_rd (argv[0], &prd);
+ if (bgp_parse_safi(argv[0], &safi)) {
+ vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ ret = str2prefix_rd (argv[1], &prd);
if (! ret)
{
vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj);
+ return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv));
}
DEFUN (show_ip_bgp_prefix,
DEFUN (show_ip_bgp_ipv4_prefix,
show_ip_bgp_ipv4_prefix_cmd,
- "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
+ "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M {json}",
SHOW_STR
IP_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj);
-
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 1, BGP_PATH_ALL, uj);
}
ALIAS (show_ip_bgp_ipv4_prefix,
show_bgp_ipv4_safi_prefix_cmd,
- "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}",
+ "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M {json}",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"JavaScript Object Notation\n")
DEFUN (show_ip_bgp_ipv4_prefix_pathtype,
show_ip_bgp_ipv4_prefix_pathtype_cmd,
- "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
+ "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M (bestpath|multipath) {json}",
SHOW_STR
IP_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Display only the bestpath\n"
"Display only multipaths\n"
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj);
+ if (strncmp (argv[2], "b", 1) == 0)
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 1, BGP_PATH_BESTPATH, uj);
else
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 1, BGP_PATH_MULTIPATH, uj);
}
ALIAS (show_ip_bgp_ipv4_prefix_pathtype,
show_bgp_ipv4_safi_prefix_pathtype_cmd,
- "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}",
+ "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M (bestpath|multipath) {json}",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Display only the bestpath\n"
"Display only multipaths\n"
"JavaScript Object Notation\n")
-DEFUN (show_ip_bgp_vpnv4_all_prefix,
- show_ip_bgp_vpnv4_all_prefix_cmd,
- "show ip bgp vpnv4 all A.B.C.D/M {json}",
- SHOW_STR
- IP_STR
- BGP_STR
- "Display VPNv4 NLRI specific information\n"
- "Display information about all VPNv4 NLRIs\n"
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
- "JavaScript Object Notation\n")
-{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv));
-}
-
-DEFUN (show_ip_bgp_vpnv4_rd_prefix,
- show_ip_bgp_vpnv4_rd_prefix_cmd,
- "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}",
- SHOW_STR
- IP_STR
- BGP_STR
- "Display VPNv4 NLRI specific information\n"
- "Display information for a route distinguisher\n"
- "VPN Route Distinguisher\n"
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
- "JavaScript Object Notation\n")
-{
- int ret;
- struct prefix_rd prd;
-
- ret = str2prefix_rd (argv[0], &prd);
- if (! ret)
- {
- vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv));
-}
DEFUN (show_ip_bgp_view,
show_ip_bgp_instance_cmd,
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal,
- NULL, uj);
- return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj);
+ return bgp_show (vty, NULL, AFI_IP6,
+ bgp_vty_safi_from_arg(argv[0]),
+ bgp_show_type_normal, NULL, uj);
}
static void
DEFUN (show_bgp_ipv6_safi_route,
show_bgp_ipv6_safi_route_cmd,
- "show bgp ipv6 (unicast|multicast) X:X::X:X {json}",
+ "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X {json}",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"Network in the BGP routing table to display\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj);
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP6,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 0, BGP_PATH_ALL, uj);
}
DEFUN (show_bgp_route_pathtype,
DEFUN (show_bgp_ipv6_safi_route_pathtype,
show_bgp_ipv6_safi_route_pathtype_cmd,
- "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}",
+ "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X (bestpath|multipath) {json}",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"Network in the BGP routing table to display\n"
"Display only the bestpath\n"
"Display only multipaths\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj);
+ if (strncmp (argv[2], "b", 1) == 0)
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP6,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 0, BGP_PATH_BESTPATH, uj);
else
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP6,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 0, BGP_PATH_MULTIPATH, uj);
}
/* old command */
DEFUN (show_bgp_ipv6_safi_prefix,
show_bgp_ipv6_safi_prefix_cmd,
- "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}",
+ "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X/M {json}",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj);
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP6,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 1, BGP_PATH_ALL, uj);
}
DEFUN (show_bgp_prefix_pathtype,
DEFUN (show_bgp_ipv6_safi_prefix_pathtype,
show_bgp_ipv6_safi_prefix_pathtype_cmd,
- "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}",
+ "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X/M (bestpath|multipath) {json}",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"IPv6 prefix <network>/<length>, e.g., 3ffe::/16\n"
"Display only the bestpath\n"
"Display only multipaths\n"
"JavaScript Object Notation\n")
{
u_char uj = use_json(argc, argv);
- if (strncmp (argv[0], "m", 1) == 0)
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj);
+ if (strncmp (argv[2], "b", 1) == 0)
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP6,
+ bgp_vty_safi_from_arg(argv[0]),
+ NULL, 1, BGP_PATH_BESTPATH, uj);
else
- if (strncmp (argv[2], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj);
+ return bgp_show_route (vty, NULL, argv[1], AFI_IP6,
+ bgp_vty_safi_from_arg(argv[0]), NULL, 1, BGP_PATH_MULTIPATH, uj);
}
/* old command */
"Display routes matching the AS path regular expression\n"
"A regular-expression to match the BGP AS paths\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST,
- bgp_show_type_regexp);
-
- return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST,
- bgp_show_type_regexp);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_regexp (vty, argc, argv, AFI_IP, safi,
+ bgp_show_type_regexp);
}
#ifdef HAVE_IPV6
"Display routes conforming to the prefix-list\n"
"IP prefix-list name\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST,
- bgp_show_type_prefix_list);
-
- return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST,
- bgp_show_type_prefix_list);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, safi,
+ bgp_show_type_prefix_list);
}
#ifdef HAVE_IPV6
"Display routes conforming to the filter-list\n"
"Regular expression access list name\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST,
- bgp_show_type_filter_list);
-
- return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST,
- bgp_show_type_filter_list);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, safi,
+ bgp_show_type_filter_list);
}
#ifdef HAVE_IPV6
"Display detailed information about dampening\n"
"Display detail of configured dampening parameters\n")
{
- if (strncmp(argv[0], "m", 1) == 0)
- return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST);
-
- return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_dampening_parameters (vty, AFI_IP, safi);
}
"Display detailed information about dampening\n"
"Display flap statistics of routes\n")
{
- if (strncmp(argv[0], "m", 1) == 0)
- return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show (vty, NULL, AFI_IP, safi,
bgp_show_type_flap_statistics, NULL, 0);
-
- return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
- bgp_show_type_flap_statistics, NULL, 0);
}
DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths,
"Display detailed information about dampening\n"
"Display paths suppressed due to dampening\n")
{
- if (strncmp(argv[0], "m", 1) == 0)
- return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show (vty, NULL, AFI_IP, safi,
bgp_show_type_dampend_paths, NULL, 0);
-
- return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
- bgp_show_type_dampend_paths, NULL, 0);
}
static int
"Display routes matching the route-map\n"
"A route-map to match on\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST,
- bgp_show_type_route_map);
-
- return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST,
- bgp_show_type_route_map);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, safi,
+ bgp_show_type_route_map);
}
DEFUN (show_bgp_route_map,
"Address Family modifier\n"
"Display only routes with non-natural netmasks\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
- bgp_show_type_cidr_only, NULL, 0);
-
- return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
- bgp_show_type_cidr_only, NULL, 0);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show (vty, NULL, AFI_IP, safi,
+ bgp_show_type_cidr_only, NULL, 0);
}
DEFUN (show_ip_bgp_community_all,
"Address Family modifier\n"
"Display routes matching the communities\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST,
- bgp_show_type_community_all, NULL, 0);
-
- return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST,
- bgp_show_type_community_all, NULL, 0);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show (vty, NULL, AFI_IP, safi,
+ bgp_show_type_community_all, NULL, 0);
}
#ifdef HAVE_IPV6
"Do not advertise to any peer (well-known community)\n"
"Do not export to next AS (well-known community)\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST);
-
- return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, safi);
}
ALIAS (show_ip_bgp_ipv4_community,
return CMD_WARNING;
}
- afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
- safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
+ afi = bgp_vty_safi_from_arg(argv[2]);
+ safi = bgp_vty_safi_from_arg(argv[3]);
return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0);
}
int afi;
int safi;
- afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
- safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
+ afi = bgp_vty_safi_from_arg(argv[2]);
+ safi = bgp_vty_safi_from_arg(argv[3]);
return bgp_show_community (vty, argv[1], argc-4, &argv[4], 0, afi, safi);
}
"Do not export to next AS (well-known community)\n"
"Exact match of the communities")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST);
-
- return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, safi);
}
ALIAS (show_ip_bgp_ipv4_community_exact,
"community-list number\n"
"community-list name\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_MULTICAST);
-
- return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_UNICAST);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, safi);
}
DEFUN (show_ip_bgp_community_list_exact,
"community-list name\n"
"Exact match of the communities\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_MULTICAST);
-
- return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_UNICAST);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, safi);
}
#ifdef HAVE_IPV6
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Display route and more specific routes\n")
{
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST,
- bgp_show_type_prefix_longer);
-
- return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST,
- bgp_show_type_prefix_longer);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, safi,
+ bgp_show_type_prefix_longer);
}
DEFUN (show_ip_bgp_flap_address,
vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
return CMD_WARNING;
}
- if (strncmp (afi_str, "ipv", 3) == 0)
- {
- if (strncmp (afi_str, "ipv4", 4) == 0)
- afi = AFI_IP;
- else if (strncmp (afi_str, "ipv6", 4) == 0)
- afi = AFI_IP6;
- else
- {
- vty_out (vty, "%% Invalid address family %s%s",
- afi_str, VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (strncmp (safi_str, "m", 1) == 0)
- safi = SAFI_MULTICAST;
- else if (strncmp (safi_str, "u", 1) == 0)
- safi = SAFI_UNICAST;
- else if (strncmp (safi_str, "e", 1) == 0)
- safi = SAFI_ENCAP;
- else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0)
- safi = SAFI_MPLS_VPN;
- else
- {
- vty_out (vty, "%% Invalid subsequent address family %s%s",
- safi_str, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- else
+ afi = bgp_vty_afi_from_arg(afi_str);
+ if (afi == AFI_MAX)
{
vty_out (vty, "%% Invalid address family \"%s\"%s",
afi_str, VTY_NEWLINE);
return CMD_WARNING;
}
+ safi = bgp_vty_safi_from_arg(safi_str);
+ if (safi == SAFI_MAX)
+ {
+ vty_out (vty, "%% Invalid subsequent address family %s%s",
+ safi_str, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
return bgp_table_stats (vty, bgp, afi, safi);
}
DEFUN (show_bgp_statistics,
show_bgp_statistics_cmd,
- "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics",
+ "show bgp "BGP_AFI_SAFI_CMD_STR" statistics",
SHOW_STR
BGP_STR
- "Address family\n"
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"BGP RIB advertisement statistics\n")
{
return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]);
DEFUN (show_bgp_statistics_view,
show_bgp_statistics_view_cmd,
- "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics",
+ "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" statistics",
SHOW_STR
BGP_STR
BGP_INSTANCE_HELP_STR
- "Address family\n"
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
+ BGP_AFI_SAFI_HELP_STR
"BGP RIB advertisement statistics\n")
{
return bgp_table_stats_vty (vty, NULL, argv[1], argv[2]);
if (! peer)
return CMD_WARNING;
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj);
-
- return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj);
-}
-
-DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts,
- show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd,
- "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}",
- SHOW_STR
- IP_STR
- BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Detailed information on TCP and BGP neighbor connections\n"
- "Neighbor to display information about\n"
- "Neighbor to display information about\n"
- "Neighbor on bgp configured interface\n"
- "Display detailed prefix count information\n"
- "JavaScript Object Notation\n")
-{
- struct peer *peer;
- u_char uj = use_json(argc, argv);
-
- peer = peer_lookup_in_view (vty, NULL, argv[0], uj);
- if (! peer)
- return CMD_WARNING;
-
- return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_peer_counts (vty, peer, AFI_IP, safi, uj);
}
static void
{
struct peer *peer;
const char *rmap_name = NULL;
+ safi_t safi;
+
u_char uj = use_json(argc, argv);
peer = peer_lookup_in_view (vty, NULL, argv[1], uj);
if ((argc == 4) || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0))
rmap_name = argv[2];
- if (strncmp (argv[0], "m", 1) == 0)
- return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj);
- else
- return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj);
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return peer_adj_routes (vty, peer, AFI_IP, safi, 0, rmap_name, uj);
}
ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route,
{
struct peer *peer;
const char *rmap_name = NULL;
+ safi_t safi;
u_char uj = use_json(argc, argv);
peer = peer_lookup_in_view (vty, NULL, argv[1], uj);
if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0))
rmap_name = argv[2];
- if (strncmp (argv[0], "m", 1) == 0)
- return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj);
- else
- return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj);
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return peer_adj_routes (vty, peer, AFI_IP, safi, 1, rmap_name, uj);
}
ALIAS (show_ip_bgp_ipv4_neighbor_received_routes,
if (! peer)
return CMD_WARNING;
- afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP;
- safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST;
+ afi = bgp_vty_safi_from_arg(argv[2]);
+ safi = bgp_vty_safi_from_arg(argv[3]);
in = (strncmp (argv[5], "r", 1) == 0) ? 1 : 0;
return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj);
}
}
- if (strncmp (argv[0], "m", 1) == 0)
- {
- sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST);
- count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj);
- if (count)
- {
- if (!uj)
- vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE);
- prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj);
- }
- else
- {
- if (uj)
- {
- json_object *json_no = NULL;
- json_no = json_object_new_object();
- json_object_boolean_true_add(json_no, "noFuntionalOutput");
- vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
- json_object_free(json_no);
- }
- else
- vty_out (vty, "No functional output%s", VTY_NEWLINE);
- }
- }
- else
{
- sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST);
+ safi_t safi;
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi);
count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj);
if (count)
{
if (!uj)
- vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE);
+ vty_out (vty, "Address family: %s%s",
+ afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj);
}
else
"JavaScript Object Notation\n")
{
struct peer *peer;
+ safi_t safi;
u_char uj = use_json(argc, argv);
peer = peer_lookup_in_view (vty, NULL, argv[1], uj);
if (! peer)
return CMD_WARNING;
- if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST,
- bgp_show_type_neighbor, uj);
-
- return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST,
- bgp_show_type_neighbor, uj);
+ safi = bgp_vty_safi_from_arg(argv[0]);
+ return bgp_show_neighbor_route (vty, peer, AFI_IP, safi,
+ bgp_show_type_neighbor, uj);
}
#ifdef HAVE_IPV6
#endif /* HAVE_IPV6 */
-struct bgp_table *bgp_distance_table;
+struct bgp_table *bgp_distance_table[AFI_MAX][SAFI_MAX];
struct bgp_distance
{
const char *ip_str, const char *access_list_str)
{
int ret;
- struct prefix_ipv4 p;
+ afi_t afi;
+ safi_t safi;
+ struct prefix p;
u_char distance;
struct bgp_node *rn;
struct bgp_distance *bdistance;
- ret = str2prefix_ipv4 (ip_str, &p);
+ afi = bgp_node_afi (vty);
+ safi = bgp_node_safi (vty);
+
+ ret = str2prefix (ip_str, &p);
if (ret == 0)
{
vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
distance = atoi (distance_str);
/* Get BGP distance node. */
- rn = bgp_node_get (bgp_distance_table, (struct prefix *) &p);
+ rn = bgp_node_get (bgp_distance_table[afi][safi], (struct prefix *) &p);
if (rn->info)
{
bdistance = rn->info;
const char *ip_str, const char *access_list_str)
{
int ret;
+ afi_t afi;
+ safi_t safi;
+ struct prefix p;
int distance;
- struct prefix_ipv4 p;
struct bgp_node *rn;
struct bgp_distance *bdistance;
- ret = str2prefix_ipv4 (ip_str, &p);
+ afi = bgp_node_afi (vty);
+ safi = bgp_node_safi (vty);
+
+ ret = str2prefix (ip_str, &p);
if (ret == 0)
{
vty_out (vty, "Malformed prefix%s", VTY_NEWLINE);
return CMD_WARNING;
}
- rn = bgp_node_lookup (bgp_distance_table, (struct prefix *)&p);
+ rn = bgp_node_lookup (bgp_distance_table[afi][safi], (struct prefix *)&p);
if (! rn)
{
vty_out (vty, "Can't find specified prefix%s", VTY_NEWLINE);
/* Apply BGP information to distance method. */
u_char
-bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, struct bgp *bgp)
+bgp_distance_apply (struct prefix *p, struct bgp_info *rinfo, afi_t afi,
+ safi_t safi, struct bgp *bgp)
{
struct bgp_node *rn;
- struct prefix_ipv4 q;
+ struct prefix q;
struct peer *peer;
struct bgp_distance *bdistance;
struct access_list *alist;
if (! bgp)
return 0;
- if (p->family != AF_INET)
- return 0;
-
peer = rinfo->peer;
- if (peer->su.sa.sa_family != AF_INET)
- return 0;
-
- memset (&q, 0, sizeof (struct prefix_ipv4));
- q.family = AF_INET;
- q.prefix = peer->su.sin.sin_addr;
- q.prefixlen = IPV4_MAX_BITLEN;
-
/* Check source address. */
- rn = bgp_node_match (bgp_distance_table, (struct prefix *) &q);
+ sockunion2hostprefix (&peer->su, &q);
+ rn = bgp_node_match (bgp_distance_table[afi][safi], &q);
if (rn)
{
bdistance = rn->info;
if (bdistance->access_list)
{
- alist = access_list_lookup (AFI_IP, bdistance->access_list);
+ alist = access_list_lookup (afi, bdistance->access_list);
if (alist && access_list_apply (alist, p) == FILTER_PERMIT)
return bdistance->distance;
}
}
/* Backdoor check. */
- rn = bgp_node_lookup (bgp->route[AFI_IP][SAFI_UNICAST], p);
+ rn = bgp_node_lookup (bgp->route[afi][safi], p);
if (rn)
{
bgp_static = rn->info;
if (bgp_static->backdoor)
{
- if (bgp->distance_local)
- return bgp->distance_local;
+ if (bgp->distance_local[afi][safi])
+ return bgp->distance_local[afi][safi];
else
return ZEBRA_IBGP_DISTANCE_DEFAULT;
}
if (peer->sort == BGP_PEER_EBGP)
{
- if (bgp->distance_ebgp)
- return bgp->distance_ebgp;
+ if (bgp->distance_ebgp[afi][safi])
+ return bgp->distance_ebgp[afi][safi];
return ZEBRA_EBGP_DISTANCE_DEFAULT;
}
else
{
- if (bgp->distance_ibgp)
- return bgp->distance_ibgp;
+ if (bgp->distance_ibgp[afi][safi])
+ return bgp->distance_ibgp[afi][safi];
return ZEBRA_IBGP_DISTANCE_DEFAULT;
}
}
"Distance for local routes\n")
{
struct bgp *bgp;
+ afi_t afi;
+ safi_t safi;
bgp = vty->index;
+ afi = bgp_node_afi (vty);
+ safi = bgp_node_safi (vty);
- bgp->distance_ebgp = atoi (argv[0]);
- bgp->distance_ibgp = atoi (argv[1]);
- bgp->distance_local = atoi (argv[2]);
+ bgp->distance_ebgp[afi][safi] = atoi (argv[0]);
+ bgp->distance_ibgp[afi][safi] = atoi (argv[1]);
+ bgp->distance_local[afi][safi] = atoi (argv[2]);
return CMD_SUCCESS;
}
"Distance for local routes\n")
{
struct bgp *bgp;
+ afi_t afi;
+ safi_t safi;
bgp = vty->index;
+ afi = bgp_node_afi (vty);
+ safi = bgp_node_safi (vty);
- bgp->distance_ebgp= 0;
- bgp->distance_ibgp = 0;
- bgp->distance_local = 0;
+ bgp->distance_ebgp[afi][safi] = 0;
+ bgp->distance_ibgp[afi][safi] = 0;
+ bgp->distance_local[afi][safi] = 0;
return CMD_SUCCESS;
}
return CMD_SUCCESS;
}
+DEFUN (ipv6_bgp_distance_source,
+ ipv6_bgp_distance_source_cmd,
+ "distance <1-255> X:X::X:X/M",
+ "Define an administrative distance\n"
+ "Administrative distance\n"
+ "IP source prefix\n")
+{
+ bgp_distance_set (vty, argv[0], argv[1], NULL);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ipv6_bgp_distance_source,
+ no_ipv6_bgp_distance_source_cmd,
+ "no distance <1-255> X:X::X:X/M",
+ NO_STR
+ "Define an administrative distance\n"
+ "Administrative distance\n"
+ "IP source prefix\n")
+{
+ bgp_distance_unset (vty, argv[0], argv[1], NULL);
+ return CMD_SUCCESS;
+}
+
+DEFUN (ipv6_bgp_distance_source_access_list,
+ ipv6_bgp_distance_source_access_list_cmd,
+ "distance <1-255> X:X::X:X/M WORD",
+ "Define an administrative distance\n"
+ "Administrative distance\n"
+ "IP source prefix\n"
+ "Access list name\n")
+{
+ bgp_distance_set (vty, argv[0], argv[1], argv[2]);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_ipv6_bgp_distance_source_access_list,
+ no_ipv6_bgp_distance_source_access_list_cmd,
+ "no distance <1-255> X:X::X:X/M WORD",
+ NO_STR
+ "Define an administrative distance\n"
+ "Administrative distance\n"
+ "IP source prefix\n"
+ "Access list name\n")
+{
+ bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
+ return CMD_SUCCESS;
+}
+
DEFUN (bgp_damp_set,
bgp_damp_set_cmd,
"bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
}
int
-bgp_config_write_distance (struct vty *vty, struct bgp *bgp)
+bgp_config_write_distance (struct vty *vty, struct bgp *bgp, afi_t afi,
+ safi_t safi, int *write)
{
struct bgp_node *rn;
struct bgp_distance *bdistance;
/* Distance configuration. */
- if (bgp->distance_ebgp
- && bgp->distance_ibgp
- && bgp->distance_local
- && (bgp->distance_ebgp != ZEBRA_EBGP_DISTANCE_DEFAULT
- || bgp->distance_ibgp != ZEBRA_IBGP_DISTANCE_DEFAULT
- || bgp->distance_local != ZEBRA_IBGP_DISTANCE_DEFAULT))
- vty_out (vty, " distance bgp %d %d %d%s",
- bgp->distance_ebgp, bgp->distance_ibgp, bgp->distance_local,
- VTY_NEWLINE);
-
- for (rn = bgp_table_top (bgp_distance_table); rn; rn = bgp_route_next (rn))
+ if (bgp->distance_ebgp[afi][safi]
+ && bgp->distance_ibgp[afi][safi]
+ && bgp->distance_local[afi][safi]
+ && (bgp->distance_ebgp[afi][safi] != ZEBRA_EBGP_DISTANCE_DEFAULT
+ || bgp->distance_ibgp[afi][safi] != ZEBRA_IBGP_DISTANCE_DEFAULT
+ || bgp->distance_local[afi][safi] != ZEBRA_IBGP_DISTANCE_DEFAULT))
+ {
+ bgp_config_write_family_header (vty, afi, safi, write);
+ vty_out (vty, " distance bgp %d %d %d%s",
+ bgp->distance_ebgp[afi][safi], bgp->distance_ibgp[afi][safi],
+ bgp->distance_local[afi][safi], VTY_NEWLINE);
+ }
+
+ for (rn = bgp_table_top (bgp_distance_table[afi][safi]); rn;
+ rn = bgp_route_next (rn))
if ((bdistance = rn->info) != NULL)
{
- vty_out (vty, " distance %d %s/%d %s%s", bdistance->distance,
- inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
+ char buf[PREFIX_STRLEN];
+
+ bgp_config_write_family_header (vty, afi, safi, write);
+ vty_out (vty, " distance %d %s %s%s", bdistance->distance,
+ prefix2str (&rn->p, buf, sizeof (buf)),
bdistance->access_list ? bdistance->access_list : "",
VTY_NEWLINE);
}
- return 0;
+ return *write;
}
/* Allocate routing table structure and install commands. */
void
bgp_route_init (void)
{
+ afi_t afi;
+ safi_t safi;
+
/* Init BGP distance table. */
- bgp_distance_table = bgp_table_init (AFI_IP, SAFI_UNICAST);
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
+ bgp_distance_table[afi][safi] = bgp_table_init (afi, safi);
/* IPv4 BGP commands. */
install_element (BGP_NODE, &bgp_table_map_cmd);
install_element (BGP_IPV4M_NODE, &no_aggregate_address_mask_summary_as_set_cmd);
install_element (VIEW_NODE, &show_ip_bgp_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv4_cmd);
install_element (VIEW_NODE, &show_ip_bgp_instance_cmd);
install_element (VIEW_NODE, &show_ip_bgp_instance_all_cmd);
install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd);
- install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
- install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd);
install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd);
install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd);
install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd);
install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd);
- install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
- install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd);
install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd);
install_element (VIEW_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
install_element (VIEW_NODE, &show_ip_bgp_neighbor_flap_cmd);
install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd);
-
- /* Restricted node: VIEW_NODE - (set of dangerous commands) */
- install_element (RESTRICTED_NODE, &show_ip_bgp_route_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_route_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_route_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv4_safi_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_prefix_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_instance_route_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_instance_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community2_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community3_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community4_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_all_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community2_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community3_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_afi_safi_community4_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community_exact_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community2_exact_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community3_exact_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_community4_exact_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
- install_element (RESTRICTED_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
-
- install_element (ENABLE_NODE, &show_ip_bgp_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_all_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_safi_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_safi_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_prefix_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_safi_prefix_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd);
-
- install_element (ENABLE_NODE, &show_ip_bgp_regexp_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_regexp_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_filter_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_filter_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_filter_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_route_map_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_route_map_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_route_map_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_cidr_only_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_cidr_only_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community_all_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_all_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community2_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community3_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community4_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_all_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community2_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community3_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_community4_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community2_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community3_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community4_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community2_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community3_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community4_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_community_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_community_list_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_community_list_exact_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_advertised_route_rmap_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_advertised_route_rmap_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_routes_rmap_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_received_routes_rmap_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_dampening_params_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_dampened_paths_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_dampd_paths_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_ipv4_dampening_flap_stats_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_dampened_paths_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_statistics_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_statistics_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_address_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_address_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_cidr_only_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_cidr_only_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_regexp_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_regexp_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_filter_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_filter_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_flap_route_map_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_damp_flap_route_map_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_flap_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_neighbor_damp_cmd);
install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_prefix_cmd);
- install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_rd_route_cmd);
- install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv4_vpn_route_cmd);
-
- install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_rd_route_cmd);
- install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_vpn_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd);
/* BGP dampening clear commands */
install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd);
install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd);
- install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd);
#ifdef HAVE_IPV6
install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd);
install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd);
install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd);
install_element (VIEW_NODE, &show_bgp_instance_neighbor_damp_cmd);
install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd);
-
- /* Restricted:
- * VIEW_NODE - (set of dangerous commands) - (commands dependent on prev)
- */
- install_element (RESTRICTED_NODE, &show_bgp_route_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_prefix_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community2_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community3_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community4_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community2_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community2_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community3_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community3_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_community4_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_ipv6_community4_exact_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_route_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_prefix_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd);
- install_element (RESTRICTED_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd);
-
- install_element (ENABLE_NODE, &show_bgp_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_safi_cmd);
- install_element (ENABLE_NODE, &show_bgp_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_safi_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_prefix_cmd);
- install_element (ENABLE_NODE, &show_bgp_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_safi_prefix_cmd);
- install_element (ENABLE_NODE, &show_bgp_regexp_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_regexp_cmd);
- install_element (ENABLE_NODE, &show_bgp_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_filter_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_filter_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_route_map_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_route_map_cmd);
- install_element (ENABLE_NODE, &show_bgp_community_all_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community_all_cmd);
- install_element (ENABLE_NODE, &show_bgp_community_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community_cmd);
- install_element (ENABLE_NODE, &show_bgp_community2_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community2_cmd);
- install_element (ENABLE_NODE, &show_bgp_community3_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community3_cmd);
- install_element (ENABLE_NODE, &show_bgp_community4_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community4_cmd);
- install_element (ENABLE_NODE, &show_bgp_community_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_community2_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community2_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_community3_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community3_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_community4_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community4_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_community_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_community_list_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_community_list_exact_cmd);
- install_element (ENABLE_NODE, &show_bgp_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_bgp_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
- install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
- install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
- install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_all_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_prefix_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_pathtype_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_filter_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_filter_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_route_map_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_route_map_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_community_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_community_list_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_neighbor_received_prefix_filter_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_received_prefix_filter_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_neighbor_flap_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_flap_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_neighbor_damp_cmd);
- install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_damp_cmd);
/* Statistics */
install_element (ENABLE_NODE, &show_bgp_statistics_cmd);
install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
- /* old command */
- install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_regexp_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_filter_list_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community_all_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community2_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community3_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community4_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community2_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community3_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community4_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_community_list_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_bgp_prefix_longer_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_route_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_regexp_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_list_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_filter_list_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community_all_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community2_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community3_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community4_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
- install_element (ENABLE_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
-
/* old command */
install_element (VIEW_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &ipv6_bgp_neighbor_advertised_route_cmd);
install_element (VIEW_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
- install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_advertised_route_cmd);
/* old command */
install_element (VIEW_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &ipv6_bgp_neighbor_received_routes_cmd);
install_element (VIEW_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
- install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_received_routes_cmd);
/* old command */
install_element (VIEW_NODE, &ipv6_bgp_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &ipv6_bgp_neighbor_routes_cmd);
install_element (VIEW_NODE, &ipv6_mbgp_neighbor_routes_cmd);
- install_element (ENABLE_NODE, &ipv6_mbgp_neighbor_routes_cmd);
#endif /* HAVE_IPV6 */
install_element (BGP_NODE, &bgp_distance_cmd);
install_element (BGP_NODE, &no_bgp_distance_source_cmd);
install_element (BGP_NODE, &bgp_distance_source_access_list_cmd);
install_element (BGP_NODE, &no_bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV4_NODE, &bgp_distance_cmd);
+ install_element (BGP_IPV4_NODE, &no_bgp_distance_cmd);
+ install_element (BGP_IPV4_NODE, &no_bgp_distance2_cmd);
+ install_element (BGP_IPV4_NODE, &bgp_distance_source_cmd);
+ install_element (BGP_IPV4_NODE, &no_bgp_distance_source_cmd);
+ install_element (BGP_IPV4_NODE, &bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV4_NODE, &no_bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV4M_NODE, &bgp_distance_cmd);
+ install_element (BGP_IPV4M_NODE, &no_bgp_distance_cmd);
+ install_element (BGP_IPV4M_NODE, &no_bgp_distance2_cmd);
+ install_element (BGP_IPV4M_NODE, &bgp_distance_source_cmd);
+ install_element (BGP_IPV4M_NODE, &no_bgp_distance_source_cmd);
+ install_element (BGP_IPV4M_NODE, &bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV4M_NODE, &no_bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV6_NODE, &bgp_distance_cmd);
+ install_element (BGP_IPV6_NODE, &no_bgp_distance_cmd);
+ install_element (BGP_IPV6_NODE, &no_bgp_distance2_cmd);
+ install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_cmd);
+ install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_cmd);
+ install_element (BGP_IPV6_NODE, &ipv6_bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV6_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV6M_NODE, &bgp_distance_cmd);
+ install_element (BGP_IPV6M_NODE, &no_bgp_distance_cmd);
+ install_element (BGP_IPV6M_NODE, &no_bgp_distance2_cmd);
+ install_element (BGP_IPV6M_NODE, &ipv6_bgp_distance_source_cmd);
+ install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_distance_source_cmd);
+ install_element (BGP_IPV6M_NODE, &ipv6_bgp_distance_source_access_list_cmd);
+ install_element (BGP_IPV6M_NODE, &no_ipv6_bgp_distance_source_access_list_cmd);
install_element (BGP_NODE, &bgp_damp_set_cmd);
install_element (BGP_NODE, &bgp_damp_set2_cmd);
void
bgp_route_finish (void)
{
- bgp_table_unlock (bgp_distance_table);
- bgp_distance_table = NULL;
+ afi_t afi;
+ safi_t safi;
+
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
+ {
+ bgp_table_unlock (bgp_distance_table[afi][safi]);
+ bgp_distance_table[afi][safi] = NULL;
+ }
}