diff options
| -rw-r--r-- | bgpd/bgp_nexthop.c | 75 | ||||
| -rw-r--r-- | bgpd/subdir.am | 1 | ||||
| -rw-r--r-- | doc/user/bgp.rst | 3 | 
3 files changed, 33 insertions, 46 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 36c5699b04..23a5aa2190 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -738,6 +738,7 @@ bool bgp_subgrp_multiaccess_check_v4(struct in_addr nexthop,  static void bgp_show_bgp_path_info_flags(uint32_t flags, json_object *json)  {  	json_object *json_flags = NULL; +  	if (!json)  		return; @@ -1104,7 +1105,6 @@ static void bgp_show_nexthops(struct vty *vty, struct bgp *bgp,  			json_object_object_add(  				json, (afi == AFI_IP) ? "ipv4" : "ipv6",  				json_afi); -  		return;  	} @@ -1126,7 +1126,7 @@ static int show_ip_bgp_nexthop_table(struct vty *vty, const char *name,  {  	struct bgp *bgp; -	if (name && strcmp(name, VRF_DEFAULT_NAME) != 0) +	if (name && !strmatch(name, VRF_DEFAULT_NAME))  		bgp = bgp_lookup_by_name(name);  	else  		bgp = bgp_get_default(); @@ -1199,9 +1199,11 @@ static void bgp_show_all_instances_nexthops_vty(struct vty *vty,  	}  } -DEFUN (show_ip_bgp_nexthop, +#include "bgpd/bgp_nexthop_clippy.c" + +DEFPY (show_ip_bgp_nexthop,         show_ip_bgp_nexthop_cmd, -       "show [ip] bgp [<view|vrf> VIEWVRFNAME] nexthop [<A.B.C.D|X:X::X:X>] [detail] [json]", +       "show [ip] bgp [<view|vrf> VIEWVRFNAME$vrf] nexthop [<A.B.C.D|X:X::X:X>$nhop] [<ipv4$afi [A.B.C.D$nhop]|ipv6$afi [X:X::X:X$nhop]>] [detail$detail] [json$uj]",         SHOW_STR         IP_STR         BGP_STR @@ -1209,43 +1211,35 @@ DEFUN (show_ip_bgp_nexthop,         "BGP nexthop table\n"         "IPv4 nexthop address\n"         "IPv6 nexthop address\n" +       "BGP nexthop IPv4 table\n" +       "IPv4 nexthop address\n" +       "BGP nexthop IPv6 table\n" +       "IPv6 nexthop address\n"         "Show detailed information\n"         JSON_STR)  {  	int rc = 0; -	int idx = 0; -	int nh_idx = 0; -	char *vrf = NULL; -	char *nhop_ip = NULL;  	json_object *json = NULL; -	bool uj = use_json(argc, argv); -	bool detail = false; +	afi_t afiz = AFI_UNSPEC;  	if (uj)  		json = json_object_new_object(); -	if (argv_find(argv, argc, "view", &idx) -	    || argv_find(argv, argc, "vrf", &idx)) -		vrf = argv[++idx]->arg; - -	if (argv_find(argv, argc, "A.B.C.D", &nh_idx) -	    || argv_find(argv, argc, "X:X::X:X", &nh_idx)) -		nhop_ip = argv[nh_idx]->arg; +	if (afi) +		afiz = bgp_vty_afi_from_str(afi); -	if (argv_find(argv, argc, "detail", &idx)) -		detail = true; - -	rc = show_ip_bgp_nexthop_table(vty, vrf, nhop_ip, false, json, -				       AFI_UNSPEC, detail); +	rc = show_ip_bgp_nexthop_table(vty, vrf, nhop_str, false, json, afiz, +				       detail);  	if (uj)  		vty_json(vty, json); +  	return rc;  } -DEFUN (show_ip_bgp_import_check, +DEFPY (show_ip_bgp_import_check,         show_ip_bgp_import_check_cmd, -       "show [ip] bgp [<view|vrf> VIEWVRFNAME] import-check-table [detail] [json]", +       "show [ip] bgp [<view|vrf> VIEWVRFNAME$vrf] import-check-table [detail$detail] [json$uj]",         SHOW_STR         IP_STR         BGP_STR @@ -1255,58 +1249,47 @@ DEFUN (show_ip_bgp_import_check,         JSON_STR)  {  	int rc = 0; -	int idx = 0; -	char *vrf = NULL;  	json_object *json = NULL; -	bool uj = use_json(argc, argv); -	bool detail = false;  	if (uj)  		json = json_object_new_object(); -	if (argv_find(argv, argc, "view", &idx) -	    || argv_find(argv, argc, "vrf", &idx)) -		vrf = argv[++idx]->arg; - -	if (argv_find(argv, argc, "detail", &idx)) -		detail = true; -  	rc = show_ip_bgp_nexthop_table(vty, vrf, NULL, true, json, AFI_UNSPEC,  				       detail);  	if (uj)  		vty_json(vty, json); +  	return rc;  } -DEFUN (show_ip_bgp_instance_all_nexthop, +DEFPY (show_ip_bgp_instance_all_nexthop,         show_ip_bgp_instance_all_nexthop_cmd, -       "show [ip] bgp <view|vrf> all nexthop [json]", +       "show [ip] bgp <view|vrf> all nexthop [<ipv4|ipv6>$afi] [detail$detail] [json$uj]",         SHOW_STR         IP_STR         BGP_STR         BGP_INSTANCE_ALL_HELP_STR         "BGP nexthop table\n" +       "BGP IPv4 nexthop table\n" +       "BGP IPv6 nexthop table\n" +       "Show detailed information\n"         JSON_STR)  {  	json_object *json = NULL; -	bool uj = use_json(argc, argv); -	int idx = 0; -	afi_t afi = AFI_UNSPEC; -	bool detail = false; +	afi_t afiz = AFI_UNSPEC;  	if (uj)  		json = json_object_new_object(); -	argv_find_and_parse_afi(argv, argc, &idx, &afi); - -	if (argv_find(argv, argc, "detail", &idx)) -		detail = true; +	if (afi) +		afiz = bgp_vty_afi_from_str(afi); -	bgp_show_all_instances_nexthops_vty(vty, json, afi, detail); +	bgp_show_all_instances_nexthops_vty(vty, json, afiz, detail);  	if (uj)  		vty_json(vty, json); +  	return CMD_SUCCESS;  } diff --git a/bgpd/subdir.am b/bgpd/subdir.am index 88f53da35e..c1f5a61438 100644 --- a/bgpd/subdir.am +++ b/bgpd/subdir.am @@ -215,6 +215,7 @@ clippy_scan += \  	bgpd/bgp_routemap.c \  	bgpd/bgp_rpki.c \  	bgpd/bgp_vty.c \ +        bgpd/bgp_nexthop.c \  	# end  nodist_bgpd_bgpd_SOURCES = \ diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index a1e6f35e34..cd5672511f 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -4483,6 +4483,9 @@ Displaying Update Group Information  Displaying Nexthop Information  -------------------- +.. clicmd:: show [ip] bgp [<view|vrf> VIEWVRFNAME] nexthop ipv4 [A.B.C.D] [detail] [json] + +.. clicmd:: show [ip] bgp [<view|vrf> VIEWVRFNAME] nexthop ipv6 [X:X::X:X] [detail] [json]  .. clicmd:: show [ip] bgp [<view|vrf> VIEWVRFNAME] nexthop [<A.B.C.D|X:X::X:X>] [detail] [json]  | 
