mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 07:59:35 +00:00
bgp: Add Asserts and remove dead code
Add asserts to how I expect bgp_vty_find_and_parse_afi_safi to be used. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
9317e17dc8
commit
b4898a387b
@ -8065,18 +8065,12 @@ DEFUN (show_ip_bgp,
|
|||||||
int uj = use_json (argc, argv);
|
int uj = use_json (argc, argv);
|
||||||
if (uj) argc--;
|
if (uj) argc--;
|
||||||
|
|
||||||
if (vrf != VRF_ALL)
|
bgp = bgp_lookup_by_vrf_id (vrf);
|
||||||
|
if (bgp == NULL)
|
||||||
{
|
{
|
||||||
vty_out(vty, "VRF-id: %d", vrf);
|
vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
|
||||||
bgp = bgp_lookup_by_vrf_id (vrf);
|
return CMD_WARNING;
|
||||||
if (bgp == NULL)
|
|
||||||
{
|
|
||||||
vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
|
|
||||||
return CMD_WARNING;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
bgp = NULL;
|
|
||||||
|
|
||||||
if (argv_find(argv, argc, "cidr-only", &idx))
|
if (argv_find(argv, argc, "cidr-only", &idx))
|
||||||
return bgp_show (vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj);
|
return bgp_show (vty, bgp, afi, safi, bgp_show_type_cidr_only, NULL, uj);
|
||||||
@ -9332,26 +9326,21 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route,
|
|||||||
int uj = use_json (argc, argv);
|
int uj = use_json (argc, argv);
|
||||||
if (uj) argc--;
|
if (uj) argc--;
|
||||||
|
|
||||||
if (vrf != VRF_ALL)
|
bgp = bgp_lookup_by_vrf_id (vrf);
|
||||||
|
if (bgp == NULL)
|
||||||
{
|
{
|
||||||
bgp = bgp_lookup_by_vrf_id (vrf);
|
if (uj)
|
||||||
if (bgp == NULL)
|
{
|
||||||
{
|
json_object *json_no = NULL;
|
||||||
if (uj)
|
json_no = json_object_new_object();
|
||||||
{
|
json_object_string_add(json_no, "warning", "Can't find BGP view");
|
||||||
json_object *json_no = NULL;
|
vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
|
||||||
json_no = json_object_new_object();
|
json_object_free(json_no);
|
||||||
json_object_string_add(json_no, "warning", "Can't find BGP view");
|
|
||||||
vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE);
|
|
||||||
json_object_free(json_no);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
|
vty_out (vty, "Can't find BGP instance %s%s", argv[5]->arg, VTY_NEWLINE);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
bgp = NULL;
|
|
||||||
|
|
||||||
/* neighbors <A.B.C.D|X:X::X:X|WORD> */
|
/* neighbors <A.B.C.D|X:X::X:X|WORD> */
|
||||||
argv_find (argv, argc, "neighbors", &idx);
|
argv_find (argv, argc, "neighbors", &idx);
|
||||||
|
@ -237,6 +237,10 @@ bgp_vty_find_and_parse_afi_safi_vrf (struct vty *vty, struct cmd_token **argv, i
|
|||||||
{
|
{
|
||||||
char *vrf_name = NULL;
|
char *vrf_name = NULL;
|
||||||
|
|
||||||
|
assert (afi);
|
||||||
|
assert (safi);
|
||||||
|
assert (*vrf == VRF_UNKNOWN);
|
||||||
|
|
||||||
if (argv_find (argv, argc, "ip", idx))
|
if (argv_find (argv, argc, "ip", idx))
|
||||||
*afi = AFI_IP;
|
*afi = AFI_IP;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user