Merge pull request #426 from donaldsharp/afi_safi2

Afi safi2
This commit is contained in:
Renato Westphal 2017-05-02 12:09:18 -03:00 committed by GitHub
commit 5a9a82b8ec
6 changed files with 95 additions and 59 deletions

View File

@ -773,25 +773,6 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
return CMD_SUCCESS;
}
#ifdef KEEP_OLD_VPN_COMMANDS
DEFUN (show_ip_bgp_vpn_all,
show_ip_bgp_vpn_all_cmd,
"show [ip] bgp <vpnv4|vpnv6>",
SHOW_STR
IP_STR
BGP_STR
BGP_VPNVX_HELP_STR)
{
afi_t afi;
int idx = 0;
if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi))
return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, 0);
return CMD_SUCCESS;
}
#endif
DEFUN (show_bgp_ip_vpn_all_rd,
show_bgp_ip_vpn_all_rd_cmd,
"show bgp "BGP_AFI_CMD_STR" vpn all [rd ASN:nn_or_IP-address:nn] [json]",

View File

@ -9297,8 +9297,17 @@ DEFUN (show_ip_bgp_vpn_all_route_prefix,
vty_out (vty, "Can't find default instance%s", VTY_NEWLINE);
return CMD_WARNING;
}
network = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL;
network = argv_find (argv, argc, "A.B.C.D/M", &idx) ? argv[idx]->arg : NULL;
if (argv_find (argv, argc, "A.B.C.D", &idx))
network = argv[idx]->arg;
else if (argv_find (argv, argc, "A.B.C.D/M", &idx))
network = argv[idx]->arg;
else
{
vty_out (vty, "Unable to figure out Network%s", VTY_NEWLINE);
return CMD_WARNING;
}
return bgp_show_route (vty, bgp, network, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv));
}
#endif /* KEEP_OLD_VPN_COMMANDS */
@ -9318,8 +9327,16 @@ DEFUN (show_ip_bgp_l2vpn_evpn_all_route_prefix,
{
int idx = 0;
char *network = NULL;
network = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL;
network = argv_find (argv, argc, "A.B.C.D/M", &idx) ? argv[idx]->arg : NULL;
if (argv_find (argv, argc, "A.B.C.D", &idx))
network = argv[idx]->arg;
else if (argv_find (argv, argc, "A.B.C.D/M", &idx))
network = argv[idx]->arg;
else
{
vty_out (vty, "Unable to figure out Network%s", VTY_NEWLINE);
return CMD_WARNING;
}
return bgp_show_route (vty, NULL, network, AFI_L2VPN, SAFI_EVPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv));
}

View File

@ -6677,6 +6677,27 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
return CMD_SUCCESS;
}
/*
* Return if we have a peer configured to use this afi/safi
*/
static int
bgp_show_summary_afi_safi_peer_exists (struct bgp *bgp, int afi, int safi)
{
struct listnode *node;
struct peer *peer;
for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
{
if (!CHECK_FLAG (peer->flags, PEER_FLAG_CONFIG_NODE))
continue;
if (peer->afc[afi][safi])
return 1;
}
return 0;
}
static void
bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi,
u_char use_json, json_object *json)
@ -6685,6 +6706,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi,
int afi_wildcard = (afi == AFI_MAX);
int safi_wildcard = (safi == SAFI_MAX);
int is_wildcard = (afi_wildcard || safi_wildcard);
if (use_json && is_wildcard)
vty_out (vty, "{%s", VTY_NEWLINE);
if (afi_wildcard)
@ -6695,26 +6717,33 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi,
safi = 1; /* SAFI_UNICAST */
while (safi < SAFI_MAX)
{
if (is_wildcard)
if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi))
{
if (use_json)
if (is_wildcard)
{
json = json_object_new_object();
/*
* So limit output to those afi/safi pairs that
* actualy have something interesting in them
*/
if (use_json)
{
json = json_object_new_object();
if (! is_first)
vty_out (vty, ",%s", VTY_NEWLINE);
if (! is_first)
vty_out (vty, ",%s", VTY_NEWLINE);
else
is_first = 0;
vty_out(vty, "\"%s\":", afi_safi_json(afi, safi));
}
else
is_first = 0;
vty_out(vty, "\"%s\":", afi_safi_json(afi, safi));
}
else
{
vty_out (vty, "%s%s Summary:%s",
VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE);
{
vty_out (vty, "%s%s Summary:%s",
VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE);
}
}
bgp_show_summary (vty, bgp, afi, safi, use_json, json);
}
bgp_show_summary (vty, bgp, afi, safi, use_json, json);
safi++;
if (safi == SAFI_RESERVED_4 ||
safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */
@ -6874,27 +6903,33 @@ afi_safi_print (afi_t afi, safi_t safi)
return "Unknown";
}
/*
* Please note that we have intentionally camelCased
* the return strings here. So if you want
* to use this function, please ensure you
* are doing this within json output
*/
const char *
afi_safi_json (afi_t afi, safi_t safi)
{
if (afi == AFI_IP && safi == SAFI_UNICAST)
return "IPv4Unicast";
return "ipv4Unicast";
else if (afi == AFI_IP && safi == SAFI_MULTICAST)
return "IPv4Multicast";
return "ipv4Multicast";
else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
return "IPv4VPN";
return "ipv4Vpn";
else if (afi == AFI_IP && safi == SAFI_ENCAP)
return "IPv4Encap";
return "ipv4Encap";
else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
return "IPv6Unicast";
return "ipv6Unicast";
else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
return "IPv6Multicast";
return "ipv6Multicast";
else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
return "IPv6VPN";
return "ipv6Vpn";
else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
return "IPv6Encap";
return "ipv6Encap";
else if (afi == AFI_L2VPN && safi == SAFI_EVPN)
return "L2VPN EVPN";
return "l2VpnEvpn";
else
return "Unknown";
}
@ -8775,9 +8810,11 @@ DEFUN (show_ip_bgp_neighbors,
int idx = 0;
if (argv_find (argv, argc, "WORD", &idx))
vrf = argv[idx]->arg;
if (argv_find (argv, argc, "view", &idx) ||
argv_find (argv, argc, "vrf", &idx))
vrf = argv[idx+1]->arg;
idx++;
if (argv_find (argv, argc, "A.B.C.D", &idx) ||
argv_find (argv, argc, "X:X::X:X", &idx) ||
argv_find (argv, argc, "WORD", &idx))

View File

@ -294,7 +294,7 @@ AC_ARG_ENABLE(rr-semantics,
AC_ARG_ENABLE([protobuf],
AS_HELP_STRING([--enable-protobuf], [Enable experimental protobuf support]))
AC_ARG_ENABLE([oldvpn_commands],
AS_HELP_STRING([--enable-old-vpn-commands], [Keep old vpn commands]))
AS_HELP_STRING([--enable-oldvpn-commands], [Keep old vpn commands]))
AC_CHECK_HEADERS(json-c/json.h)
AC_CHECK_LIB(json-c, json_object_get, LIBS="$LIBS -ljson-c")
@ -406,7 +406,7 @@ fi
#
# Logic for old vpn commans support.
#
if test "$enable_old_vpn_commands" = "yes"; then
if test "$enable_oldvpn_commands" = "yes"; then
AC_DEFINE(KEEP_OLD_VPN_COMMANDS,, [Define for compiling with old vpn commands])
fi

View File

@ -147,19 +147,19 @@ parse_type_spec (int idx_lsa, int argc, struct cmd_token **argv)
if (argc > idx_lsa)
{
if (strmatch (argv[0]->text, "router"))
if (strmatch (argv[idx_lsa]->text, "router"))
type = htons (OSPF6_LSTYPE_ROUTER);
else if (strmatch (argv[0]->text, "network"))
else if (strmatch (argv[idx_lsa]->text, "network"))
type = htons (OSPF6_LSTYPE_NETWORK);
else if (strmatch (argv[0]->text, "as-external"))
else if (strmatch (argv[idx_lsa]->text, "as-external"))
type = htons (OSPF6_LSTYPE_AS_EXTERNAL);
else if (strmatch (argv[0]->text, "intra-prefix"))
else if (strmatch (argv[idx_lsa]->text, "intra-prefix"))
type = htons (OSPF6_LSTYPE_INTRA_PREFIX);
else if (strmatch (argv[0]->text, "inter-router"))
else if (strmatch (argv[idx_lsa]->text, "inter-router"))
type = htons (OSPF6_LSTYPE_INTER_ROUTER);
else if (strmatch (argv[0]->text, "inter-prefix"))
else if (strmatch (argv[idx_lsa]->text, "inter-prefix"))
type = htons (OSPF6_LSTYPE_INTER_PREFIX);
else if (strmatch (argv[0]->text, "link"))
else if (strmatch (argv[idx_lsa]->text, "link"))
type = htons (OSPF6_LSTYPE_LINK);
}
@ -296,7 +296,7 @@ DEFUN (show_ipv6_ospf6_database_id,
"Dump LSAs\n"
"Display LSA's internal information\n")
{
int idx_ipv4 = 4;
int idx_ipv4 = 5;
int idx_level = 6;
int level;
struct listnode *i, *j;
@ -388,7 +388,7 @@ DEFUN (show_ipv6_ospf6_database_router,
DEFUN (show_ipv6_ospf6_database_type_id,
show_ipv6_ospf6_database_type_id_cmd,
"show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> [linkstate-id] A.B.C.D [<detail|dump|internal>]",
"show ipv6 ospf6 database <router|network|inter-prefix|inter-router|as-external|group-membership|type-7|link|intra-prefix> linkstate-id A.B.C.D [<detail|dump|internal>]",
SHOW_STR
IPV6_STR
OSPF6_STR

View File

@ -76,6 +76,7 @@ endif
if OSPF6D
vtysh_scan += $(top_srcdir)/ospf6d/ospf6_abr.c
vtysh_scan += $(top_srcdir)/ospf6d/ospf6_asbr.c
vtysh_scan += $(top_srcdir)/ospf6d/ospf6_area.c
vtysh_scan += $(top_srcdir)/ospf6d/ospf6_bfd.c
vtysh_scan += $(top_srcdir)/ospf6d/ospf6_flood.c