SHOW_STR
IP_STR
BGP_STR
+ BGP_INSTANCE_HELP_STR
+ "Address family\n"
+ "Address Family modifier\n"
+ "Address family\n"
+ "Address Family modifier\n"
+ "Address family\n"
+ "Address Family modifier\n"
"Address family\n"
"Address Family modifier\n"
+ "Address family\n"
"Address Family modifier\n"
+ "Display only routes with non-natural netmasks\n"
+ "Display routes matching the communities\n"
+ "Display detailed information about dampening\n"
+ "Display flap statistics of routes\n"
+ "Display paths suppressed due to dampening\n"
+ "Display routes matching the route-map\n"
+ "A route-map to match on\n"
+ "Display routes conforming to the prefix-list\n"
+ "prefix-list name\n"
+ "Display routes conforming to the filter-list\n"
+ "Regular expression access list name\n"
+ "Display routes matching the communities\n"
+ COMMUNITY_AANN_STR
+ "Do not send outside local AS (well-known community)\n"
+ "Do not advertise to any peer (well-known community)\n"
+ "Do not export to next AS (well-known community)\n"
+ "Exact match of the communities\n"
+ "Display routes matching the community-list\n"
+ "community-list number\n"
+ "community-list name\n"
+ "Exact match of the communities\n"
+ "IPv4 prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "IPv6 prefix <network>/<length>\n"
+ "Display route and more specific routes\n"
"JavaScript Object Notation\n")
{
- u_char uj = use_json(argc, argv);
+ char *vrf = NULL;
+ afi_t afi = AFI_IP6;
+ safi_t safi = SAFI_UNICAST;
+ int exact_match;
+ enum bgp_show_type sh_type = bgp_show_type_normal;
+
+ int idx = 0;
+
+ if (argv_find (argv, argc, "ip", &idx))
+ afi = AFI_IP;
+ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
+ vrf = argv[++idx]->arg;
+ if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
+ {
+ afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
+ if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
+ safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
+ }
+ else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
+ {
+ afi = AFI_IP;
+ safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
+ // advance idx if necessary
+ argv_find (argv, argc, "unicast", &idx);
+ }
- 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);
+ int uj = use_json (argc, argv);
+ if (uj) argc--;
+
+ struct bgp *bgp = bgp_lookup_by_name (vrf);
+ if (bgp == NULL)
+ {
+ vty_out (vty, "Can't find BGP instance %s%s", vrf, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (++idx < argc)
+ {
+ if (strmatch(argv[idx]->text, "cidr-only"))
+ return bgp_show (vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj);
+
- else if (strmatch(argv[idx]->text, "dampening"))
- {
- if (strmatch(argv[idx + 1]->text, "dampened-paths"))
- return bgp_show (vty, bgp, afi, safi, bgp_show_type_dampend_paths, NULL, uj);
-
- else if (strmatch(argv[idx + 1]->text, "flap-statistics"))
- return bgp_show (vty, bgp, afi, safi, bgp_show_type_flap_statistics, NULL, uj);
- }
-
+ else if (strmatch(argv[idx]->text, "dampened-paths"))
+ return bgp_show (vty, bgp, afi, safi, bgp_show_type_dampend_paths, NULL, uj);
+
+ else if (strmatch(argv[idx]->text, "flap-statistics"))
+ return bgp_show (vty, bgp, afi, safi, bgp_show_type_flap_statistics, NULL, uj);
+
+ else if (strmatch(argv[idx]->text, "regexp"))
+ return bgp_show_regexp (vty, argc, argv, afi, safi, bgp_show_type_regexp);
+
+ else if (strmatch(argv[idx]->text, "prefix-list"))
+ return bgp_show_prefix_list (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_list);
+
+ else if (strmatch(argv[idx]->text, "filter-list"))
+ return bgp_show_filter_list (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_filter_list);
+
+ else if (strmatch(argv[idx]->text, "route-map"))
+ return bgp_show_route_map (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_route_map);
+
+ else if (strmatch(argv[idx]->text, "community"))
+ {
+ /* show a specific community */
+ if (argv[idx + 1]->type == VARIABLE_TKN ||
+ strmatch(argv[idx + 1]->text, "local-AS") ||
+ strmatch(argv[idx + 1]->text, "no-advertise") ||
+ strmatch(argv[idx + 1]->text, "no-export"))
+ {
+ if (strmatch(argv[idx + 2]->text, "exact_match"))
+ exact_match = 1;
+ return bgp_show_community (vty, vrf, argc, argv, exact_match, afi, safi);
+ }
+ /* show all communities */
+ else
+ return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, uj);
+ }
+ else if (strmatch(argv[idx]->text, "community-list"))
+ {
+ if (strmatch(argv[idx + 2]->text, "exact_match"))
+ exact_match = 1;
+ return bgp_show_community_list (vty, vrf, argv[idx + 1]->arg, exact_match, afi, safi);
+ }
+ /* prefix-longer */
+ else if (argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV6_TKN)
+ return bgp_show_prefix_longer (vty, vrf, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_longer);
+ }
+
+ return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj);
}
-ALIAS (show_ip_bgp_ipv4,
- show_bgp_ipv4_safi_cmd,
- "show bgp ipv4 (unicast|multicast) {json}",
+DEFUN (show_ip_bgp_route,
+ show_ip_bgp_route_cmd,
+ "show [ip] bgp [<view|vrf> WORD] [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>]"
+ "<A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> [<bestpath|multipath>] [json]",
SHOW_STR
+ IP_STR
BGP_STR
+ BGP_INSTANCE_HELP_STR
+ "Address family\n"
+ "Address Family modifier\n"
"Address family\n"
"Address Family modifier\n"
+ "Address family\n"
+ "Address Family modifier\n"
+ "Address family\n"
+ "Address Family modifier\n"
+ "Address family\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"
+ "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
+ "IPv6 prefix <network>/<length>\n"
+ "Display only the bestpath\n"
+ "Display only multipaths\n"
"JavaScript Object Notation\n")
+{
+ int prefix_check = 0;
-DEFUN (show_ip_bgp_route,
- show_ip_bgp_route_cmd,
- "show ip bgp A.B.C.D {json}",
- SHOW_STR
- IP_STR
- BGP_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_UNICAST, NULL, 0, BGP_PATH_ALL, use_json(argc, argv));
-}
+ afi_t afi = AFI_IP6;
+ safi_t safi = SAFI_UNICAST;
+ char *vrf = NULL;
+ char *prefix = NULL;
-DEFUN (show_ip_bgp_route_pathtype,
- show_ip_bgp_route_pathtype_cmd,
- "show ip bgp A.B.C.D (bestpath|multipath) {json}",
- SHOW_STR
- IP_STR
- BGP_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")
-{
+ enum bgp_path_type path_type;
u_char uj = use_json(argc, argv);
- if (strncmp (argv[1], "b", 1) == 0)
- return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj);
- else
- return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj);
-}
+ int idx = 0;
+
+ /* show [ip] bgp */
+ if (argv_find (argv, argc, "ip", &idx))
+ afi = AFI_IP;
+ /* [<view|vrf> WORD] */
+ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
+ vrf = argv[++idx]->arg;
+ /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */
+ if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
+ {
+ afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
+ if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
+ safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
+ }
+ else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
+ {
+ afi = AFI_IP;
+ safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
+ // advance idx if necessary
+ argv_find (argv, argc, "unicast", &idx);
+ }
-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_STR
- BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "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")
-{
- u_char uj = use_json(argc, argv);
+ /* <A.B.C.D|A.B.C.D/M|X:X::X:X|X:X::X:X/M> */
+ if (argv_find (argv, argc, "A.B.C.D", &idx) || argv_find (argv, argc, "X:X::X:X", &idx))
+ prefix_check = 0;
+ else if (argv_find (argv, argc, "A.B.C.D/M", &idx) || argv_find (argv, argc, "X:X::X:X/M", &idx))
+ prefix_check = 1;
- 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);
- 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);
-}
+ if ((argv[idx]->type == IPV6_TKN || argv[idx]->type == IPV6_PREFIX_TKN) && afi != AFI_IP6)
+ {
+ vty_out (vty, "%% Cannot specify IPv6 address or prefix with IPv4 AFI%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ if ((argv[idx]->type == IPV4_TKN || argv[idx]->type == IPV4_PREFIX_TKN) && afi != AFI_IP)
+ {
+ vty_out (vty, "%% Cannot specify IPv4 address or prefix with IPv6 AFI%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
-DEFUN (show_bgp_ipv4_prefix,
- show_bgp_ipv4_prefix_cmd,
- "show bgp ipv4 A.B.C.D/M {json}",
- SHOW_STR
- BGP_STR
- IP_STR
- "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
- JSON_STR)
-{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc, argv));
-}
+ prefix = argv[idx]->arg;
-DEFUN (show_bgp_ipv6_route,
- show_bgp_ipv6_route_cmd,
- "show bgp ipv6 X:X::X:X {json}",
- SHOW_STR
- BGP_STR
- "Address family\n"
- "Network in the BGP routing table to display\n"
- JSON_STR)
-{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, use_json (argc, argv));
-}
+ /* [<bestpath|multipath>] */
+ if (argv_find (argv, argc, "bestpath", &idx))
+ path_type = BGP_PATH_BESTPATH;
+ else if (argv_find (argv, argc, "multipath", &idx))
+ path_type = BGP_PATH_MULTIPATH;
+ else
+ path_type = BGP_PATH_ALL;
-DEFUN (show_bgp_ipv6_prefix,
- show_bgp_ipv6_prefix_cmd,
- "show bgp ipv6 X:X::X:X/M {json}",
- SHOW_STR
- BGP_STR
- IP_STR
- "IPv6 prefix <network>/<length>\n"
- JSON_STR)
-{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, use_json (argc,argv));
+ return bgp_show_route (vty, vrf, prefix, afi, safi, NULL, prefix_check, path_type, uj);
}
-DEFUN (show_ip_bgp_ipv4_route,
- show_ip_bgp_ipv4_route_cmd,
- "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}",
+DEFUN (show_ip_bgp_instance_all,
+ show_ip_bgp_instance_all_cmd,
+ "show [ip] bgp <view|vrf> all [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] [json]",
SHOW_STR
IP_STR
BGP_STR
- "Address family\n"
- "Address Family modifier\n"
- "Address Family modifier\n"
- "Network in the BGP routing table to display\n"
+ BGP_INSTANCE_ALL_HELP_STR
"JavaScript Object Notation\n")
{
- u_char uj = use_json(argc, argv);
+ afi_t afi = AFI_IP;
+ safi_t safi = SAFI_UNICAST;
- 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);
+ int idx = 0;
- return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj);
-}
+ /* show [ip] bgp */
+ if (argv_find (argv, argc, "ip", &idx))
+ afi = AFI_IP;
+ /* [<ipv4 [<unicast|multicast>]|ipv6 [<unicast|multicast>]|encap [unicast]|vpnv4 [unicast]>] */
+ if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx))
+ {
+ afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP;
+ if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx))
+ safi = strmatch (argv[idx]->text, "unicast") ? SAFI_UNICAST : SAFI_MULTICAST;
+ }
+ else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx))
+ {
+ afi = AFI_IP;
+ safi = strmatch (argv[idx]->text, "encap") ? SAFI_ENCAP : SAFI_MPLS_VPN;
+ // advance idx if necessary
+ argv_find (argv, argc, "unicast", &idx);
+ }
-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")
+ u_char uj = use_json(argc, argv);
-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_STR
- IP_STR
- BGP_STR
- "Display VPNv4 NLRI specific information\n"
- "Display information about all VPNv4 NLRIs\n"
- "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));
+ bgp_show_all_instances_routes_vty (vty, afi, safi, uj);
+ return CMD_SUCCESS;
}
-DEFUN (show_bgp_ipv4_vpn_route,
- show_bgp_ipv4_vpn_route_cmd,
- "show bgp ipv4 vpn 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)
-{
- 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_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)
+static int
+bgp_show_regexp (struct vty *vty, int argc, struct cmd_token **argv, afi_t afi,
+ safi_t safi, enum bgp_show_type type)
{
- return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv));
-}
++ return CMD_SUCCESS;
++/* XXX(vtysh-grammar): Needs updating for new CLI backend.
+
-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}",
- SHOW_STR
- BGP_STR
- IP_STR
- "Display VPN NLRI specific information\n"
- "Display information for a route distinguisher\n"
- "VPN Route Distinguisher\n"
- "Network in the BGP routing table to display\n"
- JSON_STR)
-{
- int ret;
- struct prefix_rd prd;
+ int i;
+ struct buffer *b;
+ char *regstr;
+ int first;
+ regex_t *regex;
+ int rc;
+
+ first = 0;
+ b = buffer_new (1024);
+ for (i = 0; i < argc; i++)
+ {
+ if (first)
+ buffer_putc (b, ' ');
+ else
+ {
+ if ((strcmp (argv[i]->arg, "unicast") == 0) || (strcmp (argv[i]->arg, "multicast") == 0))
+ continue;
+ first = 1;
+ }
- ret = str2prefix_rd (argv[0], &prd);
- if (! ret)
+ buffer_putstr (b, argv[i]->arg);
+ }
+ buffer_putc (b, '\0');
+
+ regstr = buffer_getstr (b);
+ buffer_free (b);
+
+ regex = bgp_regcomp (regstr);
+ XFREE(MTYPE_TMP, regstr);
+ if (! regex)
{
- vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ vty_out (vty, "Can't compile regexp %s%s", argv[0]->arg,
+ 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));
+
+ rc = bgp_show (vty, NULL, afi, safi, type, regex, 0);
+ bgp_regex_free (regex);
+ return rc;
++*/
}
-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}",
- SHOW_STR
- BGP_STR
- "Address Family\n"
- "Display VPN NLRI specific information\n"
- "Display information for a route distinguisher\n"
- "VPN Route Distinguisher\n"
- "Network in the BGP routing table to display\n"
- JSON_STR)
+static int
+bgp_show_prefix_list (struct vty *vty, const char *name,
+ const char *prefix_list_str, afi_t afi,
+ safi_t safi, enum bgp_show_type type)
{
- int ret;
- struct prefix_rd prd;
+ struct prefix_list *plist;
+ struct bgp *bgp = NULL;
- ret = str2prefix_rd (argv[0], &prd);
- if (! ret)
+ if (name && !(bgp = bgp_lookup_by_name(name)))
+ {
+ vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ plist = prefix_list_lookup (afi, prefix_list_str);
+ if (plist == NULL)
{
- vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ vty_out (vty, "%% %s is not a valid prefix-list name%s",
+ prefix_list_str, 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 (vty, bgp, afi, safi, type, plist, 0);
}
-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}",
- SHOW_STR
- IP_STR
- BGP_STR
- "Display VPNv4 NLRI specific information\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")
+static int
+bgp_show_filter_list (struct vty *vty, const char *name,
+ const char *filter, afi_t afi,
+ safi_t safi, enum bgp_show_type type)
{
- int ret;
- struct prefix_rd prd;
- u_char uj= use_json(argc, argv);
+ struct as_list *as_list;
+ struct bgp *bgp = NULL;
- ret = str2prefix_rd (argv[0], &prd);
- if (! ret)
+ if (name && !(bgp = bgp_lookup_by_name(name)))
{
- vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
+ vty_out (vty, "%% No such BGP instance exists%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);
-}
-DEFUN (show_ip_bgp_prefix,
- show_ip_bgp_prefix_cmd,
- "show ip bgp A.B.C.D/M {json}",
- SHOW_STR
- IP_STR
- BGP_STR
- "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_UNICAST, NULL, 1, BGP_PATH_ALL, use_json(argc, argv));
+ as_list = as_list_lookup (filter);
+ if (as_list == NULL)
+ {
+ vty_out (vty, "%% %s is not a valid AS-path access-list name%s", filter, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ return bgp_show (vty, bgp, afi, safi, type, as_list, 0);
}
-DEFUN (show_ip_bgp_prefix_pathtype,
- show_ip_bgp_prefix_pathtype_cmd,
- "show ip bgp A.B.C.D/M (bestpath|multipath) {json}",
+DEFUN (show_ip_bgp_dampening_info,
+ show_ip_bgp_dampening_params_cmd,
+ "show ip bgp dampening parameters",
SHOW_STR
IP_STR
BGP_STR
"Neighbor to display information about\n"
"Neighbor on bgp configured interface\n"
"Display routes learned from neighbor\n"
- "JavaScript Object Notation\n")
-
-/* old command */
-DEFUN (ipv6_mbgp_neighbor_routes,
- ipv6_mbgp_neighbor_routes_cmd,
- "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}",
- SHOW_STR
- IPV6_STR
- MBGP_STR
- "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 routes learned from neighbor\n"
+ "Display the dampened routes received from neighbor\n"
+ "Display flap statistics of the routes learned from neighbor\n"
"JavaScript Object Notation\n")
{
+ int idx_view_vrf = 3;
+ int idx_vrf = 4;
+ int idx_afi;
+ int idx_safi;
+ int idx_peer;
+ int idx_sh_type;
+ char *vrf = NULL;
+ afi_t afi;
+ safi_t safi;
struct peer *peer;
+ enum bgp_show_type sh_type = bgp_show_type_neighbor;
u_char uj = use_json(argc, argv);
- peer = peer_lookup_in_view (vty, NULL, argv[0], uj);
+ vrf = bgp_get_argv_vrf (argc, argv, &afi, &safi, &idx_view_vrf, &idx_vrf, &idx_afi);
+ idx_safi = idx_afi + 1;
+ bgp_get_argv_afi_safi (argc, argv, idx_afi, idx_safi, &afi, &safi, &idx_peer);
+
+ peer = peer_lookup_in_view (vty, vrf, argv[idx_peer]->arg, uj);
if (! peer)
- return CMD_WARNING;
-
- bgp_show_ipv6_bgp_deprecate_warning(vty);
- return bgp_show_neighbor_route (vty, peer, AFI_IP6, SAFI_MULTICAST,
- bgp_show_type_neighbor, uj);
-}
+ {
+ vty_out (vty, "No such neighbor%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
-ALIAS (show_bgp_instance_neighbor_flap,
- show_bgp_neighbor_flap_cmd,
- "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
- SHOW_STR
- BGP_STR
- "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 flap statistics of the routes learned from neighbor\n"
- "JavaScript Object Notation\n")
+ idx_sh_type = idx_peer + 1;
-ALIAS (show_bgp_instance_neighbor_flap,
- show_bgp_ipv6_neighbor_flap_cmd,
- "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) flap-statistics {json}",
- SHOW_STR
- BGP_STR
- "Address family\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 flap statistics of the routes learned from neighbor\n"
- "JavaScript Object Notation\n")
+ if (strmatch(argv[idx_sh_type]->text, "routes"))
+ sh_type = bgp_show_type_neighbor;
-ALIAS (show_bgp_instance_neighbor_damp,
- show_bgp_neighbor_damp_cmd,
- "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
- SHOW_STR
- BGP_STR
- "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 the dampened routes received from neighbor\n"
- "JavaScript Object Notation\n")
+ else if (strmatch(argv[idx_sh_type]->text, "dampened-routes"))
+ sh_type = bgp_show_type_damp_neighbor;
-ALIAS (show_bgp_instance_neighbor_damp,
- show_bgp_ipv6_neighbor_damp_cmd,
- "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X|WORD) dampened-routes {json}",
- SHOW_STR
- BGP_STR
- "Address family\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 the dampened routes received from neighbor\n"
- "JavaScript Object Notation\n")
+ else if (strmatch(argv[idx_sh_type]->text, "flap-statistics"))
+ sh_type = bgp_show_type_flap_neighbor;
-#endif /* HAVE_IPV6 */
+ return bgp_show_neighbor_route (vty, peer, afi, safi, sh_type, uj);
+}
- struct bgp_table *bgp_distance_table;
+ struct bgp_table *bgp_distance_table[AFI_MAX][SAFI_MAX];
struct bgp_distance
{
"Distance for routes internal to the AS\n"
"Distance for local routes\n")
{
+ int idx_number = 2;
+ int idx_number_2 = 3;
+ int idx_number_3 = 4;
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[idx_number]->arg);
- bgp->distance_ibgp = atoi (argv[idx_number_2]->arg);
- bgp->distance_local = atoi (argv[idx_number_3]->arg);
- bgp->distance_ebgp[afi][safi] = atoi (argv[0]);
- bgp->distance_ibgp[afi][safi] = atoi (argv[1]);
- bgp->distance_local[afi][safi] = atoi (argv[2]);
++ bgp->distance_ebgp[afi][safi] = atoi (argv[idx_number]->arg);
++ bgp->distance_ibgp[afi][safi] = atoi (argv[idx_number_2]->arg);
++ bgp->distance_local[afi][safi] = atoi (argv[idx_number_3]->arg);
return CMD_SUCCESS;
}
return CMD_SUCCESS;
}
- "distance <1-255> X:X::X:X/M",
+ DEFUN (ipv6_bgp_distance_source,
+ ipv6_bgp_distance_source_cmd,
- bgp_distance_set (vty, argv[0], argv[1], NULL);
++ "distance (1-255) X:X::X:X/M",
+ "Define an administrative distance\n"
+ "Administrative distance\n"
+ "IP source prefix\n")
+ {
- "no distance <1-255> X:X::X:X/M",
++ bgp_distance_set (vty, argv[1]->arg, argv[2]->arg, NULL);
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (no_ipv6_bgp_distance_source,
+ no_ipv6_bgp_distance_source_cmd,
- bgp_distance_unset (vty, argv[0], argv[1], NULL);
++ "no distance (1-255) X:X::X:X/M",
+ NO_STR
+ "Define an administrative distance\n"
+ "Administrative distance\n"
+ "IP source prefix\n")
+ {
- "distance <1-255> X:X::X:X/M WORD",
++ bgp_distance_unset (vty, argv[2]->arg, argv[3]->arg, NULL);
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (ipv6_bgp_distance_source_access_list,
+ ipv6_bgp_distance_source_access_list_cmd,
- bgp_distance_set (vty, argv[0], argv[1], argv[2]);
++ "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")
+ {
- "no distance <1-255> X:X::X:X/M WORD",
++ bgp_distance_set (vty, argv[1]->arg, argv[2]->arg, argv[3]->arg);
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (no_ipv6_bgp_distance_source_access_list,
+ no_ipv6_bgp_distance_source_access_list_cmd,
- bgp_distance_unset (vty, argv[0], argv[1], argv[2]);
++ "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[2]->arg, argv[3]->arg, argv[4]->arg);
+ return CMD_SUCCESS;
+ }
+
DEFUN (bgp_damp_set,
bgp_damp_set_cmd,
- "bgp dampening <1-45> <1-20000> <1-20000> <1-255>",
+ "bgp dampening [(1-45) [(1-20000) (1-20000) (1-255)]]",
"BGP Specific commands\n"
"Enable route-flap dampening\n"
"Half-life time for the penalty\n"
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, &no_bgp_distance2_cmd);
+ install_element (BGP_IPV4_NODE, &bgp_distance_cmd);
+ install_element (BGP_IPV4_NODE, &no_bgp_distance_cmd);
- install_element (BGP_IPV4M_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_IPV6_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_IPV6M_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, &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);
- install_element (BGP_NODE, &bgp_damp_set3_cmd);
install_element (BGP_NODE, &bgp_damp_unset_cmd);
- install_element (BGP_NODE, &bgp_damp_unset2_cmd);
- install_element (BGP_NODE, &bgp_damp_unset3_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
- install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
- install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
- install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
- install_element (BGP_IPV4_NODE, &bgp_damp_unset3_cmd);
/* IPv4 Multicast Mode */
install_element (BGP_IPV4M_NODE, &bgp_damp_set_cmd);
return CMD_SUCCESS;
}
-ALIAS (no_ospf6_timers_lsa,
- no_ospf6_timers_lsa_val_cmd,
- "no timers lsa min-arrival <0-600000>",
- NO_STR
- "Adjust routing timers\n"
- "OSPF6 LSA timers\n"
- "Minimum delay in receiving new version of a LSA\n"
- "Delay in milliseconds\n")
- "distance <1-255>",
+ DEFUN (ospf6_distance,
+ ospf6_distance_cmd,
- o->distance_all = atoi (argv[0]);
++ "distance (1-255)",
+ "Administrative distance\n"
+ "OSPF6 Administrative distance\n")
+ {
+ struct ospf6 *o = vty->index;
+
- "no distance <1-255>",
++ o->distance_all = atoi (argv[1]->arg);
+
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (no_ospf6_distance,
+ no_ospf6_distance_cmd,
- "distance ospf6 {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
++ "no distance (1-255)",
+ NO_STR
+ "Administrative distance\n"
+ "OSPF6 Administrative distance\n")
+ {
+ struct ospf6 *o = vty->index;
+
+ o->distance_all = 0;
+
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (ospf6_distance_ospf6,
+ ospf6_distance_ospf6_cmd,
- if (argc < 3) /* should not happen */
++ "distance ospf6 <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>",
+ "Administrative distance\n"
+ "OSPF6 distance\n"
+ "Intra-area routes\n"
+ "Distance for intra-area routes\n"
+ "Inter-area routes\n"
+ "Distance for inter-area routes\n"
+ "External routes\n"
++ "Distance for external routes\n"
++ "Intra-area routes\n"
++ "Distance for intra-area routes\n"
++ "Inter-area routes\n"
++ "Distance for inter-area routes\n"
++ "External routes\n"
++ "Distance for external routes\n"
++ "Intra-area routes\n"
++ "Distance for intra-area routes\n"
++ "Inter-area routes\n"
++ "Distance for inter-area routes\n"
++ "External routes\n"
+ "Distance for external routes\n")
+ {
+ struct ospf6 *o = vty->index;
+
- if (!argv[0] && !argv[1] && !argv[2])
- {
- vty_out(vty, "%% Command incomplete. (Arguments required)%s",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
++ char *intra, *inter, *external;
++ intra = inter = external = NULL;
++
++ int idx = 0;
++ if (argv_find (argv, argc, "intra-area", &idx))
++ intra = argv[++idx]->arg;
++ if (argv_find (argv, argc, "intra-area", &idx))
++ {
++ vty_out (vty, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE);
++ return CMD_WARNING;
++ }
++
++ idx = 0;
++ if (argv_find (argv, argc, "inter-area", &idx))
++ inter = argv[++idx]->arg;
++ if (argv_find (argv, argc, "inter-area", &idx))
++ {
++ vty_out (vty, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE);
+ return CMD_WARNING;
++ }
++
++ idx = 0;
++ if (argv_find (argv, argc, "external", &idx))
++ external = argv[++idx]->arg;
++ if (argv_find (argv, argc, "external", &idx))
++ {
++ vty_out (vty, "%% Cannot specify external distance twice%s", VTY_NEWLINE);
++ return CMD_WARNING;
++ }
+
- if (argv[0] != NULL)
- o->distance_intra = atoi (argv[0]);
+
- if (argv[1] != NULL)
- o->distance_inter = atoi (argv[1]);
++ if (intra)
++ o->distance_intra = atoi (intra);
+
- if (argv[2] != NULL)
- o->distance_external = atoi (argv[2]);
++ if (inter)
++ o->distance_inter = atoi (inter);
+
- "no distance ospf6 {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
++ if (external)
++ o->distance_external = atoi (external);
+
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (no_ospf6_distance_ospf6,
+ no_ospf6_distance_ospf6_cmd,
- if (argv[0] != NULL)
++ "no distance ospf6 [<intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
+ NO_STR
+ "Administrative distance\n"
+ "OSPF6 distance\n"
+ "Intra-area routes\n"
+ "Distance for intra-area routes\n"
+ "Inter-area routes\n"
+ "Distance for inter-area routes\n"
+ "External routes\n"
++ "Distance for external routes\n"
++ "Intra-area routes\n"
++ "Distance for intra-area routes\n"
++ "Inter-area routes\n"
++ "Distance for inter-area routes\n"
++ "External routes\n"
++ "Distance for external routes\n"
++ "Intra-area routes\n"
++ "Distance for intra-area routes\n"
++ "Inter-area routes\n"
++ "Distance for inter-area routes\n"
++ "External routes\n"
+ "Distance for external routes\n")
+ {
+ struct ospf6 *o = vty->index;
+
++ char *intra, *inter, *external;
++ intra = inter = external = NULL;
++
++ if (argc == 3)
++ {
++ /* If no arguments are given, clear all distance information */
++ o->distance_intra = 0;
++ o->distance_inter = 0;
++ o->distance_external = 0;
++ return CMD_SUCCESS;
++ }
++
++ int idx = 0;
++ if (argv_find (argv, argc, "intra-area", &idx))
++ intra = argv[++idx]->arg;
++ if (argv_find (argv, argc, "intra-area", &idx))
++ {
++ vty_out (vty, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE);
++ return CMD_WARNING;
++ }
++
++ idx = 0;
++ if (argv_find (argv, argc, "inter-area", &idx))
++ inter = argv[++idx]->arg;
++ if (argv_find (argv, argc, "inter-area", &idx))
++ {
++ vty_out (vty, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE);
++ return CMD_WARNING;
++ }
++
++ idx = 0;
++ if (argv_find (argv, argc, "external", &idx))
++ external = argv[++idx]->arg;
++ if (argv_find (argv, argc, "external", &idx))
++ {
++ vty_out (vty, "%% Cannot specify external distance twice%s", VTY_NEWLINE);
++ return CMD_WARNING;
++ }
+ if (argc < 3) /* should not happen */
+ return CMD_WARNING;
+
- if (argv[1] != NULL)
++ if (intra)
+ o->distance_intra = 0;
+
- if (argv[2] != NULL)
++ if (inter)
+ o->distance_inter = 0;
+
- if (argv[0] || argv[1] || argv[2])
- return CMD_SUCCESS;
-
- /* If no arguments are given, clear all distance information */
- o->distance_intra = 0;
- o->distance_inter = 0;
- o->distance_external = 0;
-
++ if (external)
+ o->distance_external = 0;
+
- "distance <1-255> X:X::X:X/M [WORD]",
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (ospf6_distance_source,
+ ospf6_distance_source_cmd,
-
- ospf6_distance_set (vty, o, argv[0], argv[1], argc == 3 ? argv[2] : NULL);
++ "distance (1-255) X:X::X:X/M [WORD]",
+ "Administrative distance\n"
+ "Distance value\n"
+ "IP source prefix\n"
+ "Access list name\n")
+ {
+ struct ospf6 *o = vty->index;
- "no distance <1-255> X:X::X:X/M [WORD]",
++ char *alname = (argc == 4) ? argv[3]->arg : NULL;
++ ospf6_distance_set (vty, o, argv[1]->arg, argv[2]->arg, alname);
+
+ return CMD_SUCCESS;
+ }
+
+ DEFUN (no_ospf6_distance_source,
+ no_ospf6_distance_source_cmd,
-
- ospf6_distance_unset (vty, o, argv[0], argv[1], argc == 3 ? argv[2] : NULL);
++ "no distance (1-255) X:X::X:X/M [WORD]",
+ NO_STR
+ "Administrative distance\n"
+ "Distance value\n"
+ "IP source prefix\n"
+ "Access list name\n")
+ {
+ struct ospf6 *o = vty->index;
++ char *alname = (argc == 5) ? argv[4]->arg : NULL;
++ ospf6_distance_unset (vty, o, argv[2]->arg, argv[3]->arg, alname);
+
+ return CMD_SUCCESS;
+ }
+
DEFUN (ospf6_interface_area,
ospf6_interface_area_cmd,
"interface IFNAME area A.B.C.D",
install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd);
install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd);
*/
- }
-
-
-
+ install_element (OSPF6_NODE, &ospf6_distance_cmd);
+ install_element (OSPF6_NODE, &no_ospf6_distance_cmd);
+ install_element (OSPF6_NODE, &ospf6_distance_ospf6_cmd);
+ install_element (OSPF6_NODE, &no_ospf6_distance_ospf6_cmd);
+ #if 0
+ install_element (OSPF6_NODE, &ospf6_distance_source_cmd);
+ install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd);
+ #endif
+ }