mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 01:14:48 +00:00
ospfd: remove call to if_lookup_all_vrf
so as to isolate ospf contexts separately for each vrf, the interface used is cornered to the passed vrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
ca6541963c
commit
03ed9f02dc
@ -2530,8 +2530,8 @@ DEFUN (show_ip_ospf_mpls_te_link,
|
|||||||
"Interface name\n")
|
"Interface name\n")
|
||||||
{
|
{
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
int idx_interface = 5;
|
int idx_interface = 0;
|
||||||
struct interface *ifp;
|
struct interface *ifp = NULL;
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
char *vrf_name = NULL;
|
char *vrf_name = NULL;
|
||||||
bool all_vrf;
|
bool all_vrf;
|
||||||
@ -2543,7 +2543,7 @@ DEFUN (show_ip_ospf_mpls_te_link,
|
|||||||
vrf_name = argv[idx_vrf + 1]->arg;
|
vrf_name = argv[idx_vrf + 1]->arg;
|
||||||
all_vrf = strmatch(vrf_name, "all");
|
all_vrf = strmatch(vrf_name, "all");
|
||||||
}
|
}
|
||||||
|
argv_find(argv, argc, "INTERFACE", &idx_interface);
|
||||||
/* vrf input is provided could be all or specific vrf*/
|
/* vrf input is provided could be all or specific vrf*/
|
||||||
if (vrf_name) {
|
if (vrf_name) {
|
||||||
if (all_vrf) {
|
if (all_vrf) {
|
||||||
@ -2557,32 +2557,31 @@ DEFUN (show_ip_ospf_mpls_te_link,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
ospf = ospf_lookup_by_inst_name(inst, vrf_name);
|
ospf = ospf_lookup_by_inst_name(inst, vrf_name);
|
||||||
if (ospf == NULL || !ospf->oi_running)
|
} else
|
||||||
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
||||||
|
if (ospf == NULL || !ospf->oi_running)
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
|
vrf = vrf_lookup_by_id(ospf->vrf_id);
|
||||||
|
if (!vrf)
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
if (idx_interface) {
|
||||||
|
ifp = if_lookup_by_name(
|
||||||
|
argv[idx_interface]->arg,
|
||||||
|
ospf->vrf_id);
|
||||||
|
if (ifp == NULL) {
|
||||||
|
vty_out(vty, "No such interface name in vrf %s\n",
|
||||||
|
vrf->name);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
vrf = vrf_lookup_by_id(ospf->vrf_id);
|
}
|
||||||
|
}
|
||||||
|
if (!ifp) {
|
||||||
FOR_ALL_INTERFACES (vrf, ifp)
|
FOR_ALL_INTERFACES (vrf, ifp)
|
||||||
show_mpls_te_link_sub(vty, ifp);
|
show_mpls_te_link_sub(vty, ifp);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
/* Show All Interfaces. */
|
|
||||||
if (argc == 5) {
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
|
||||||
if (!ospf->oi_running)
|
|
||||||
continue;
|
|
||||||
vrf = vrf_lookup_by_id(ospf->vrf_id);
|
|
||||||
FOR_ALL_INTERFACES (vrf, ifp)
|
|
||||||
show_mpls_te_link_sub(vty, ifp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Interface name is specified. */
|
|
||||||
else {
|
|
||||||
ifp = if_lookup_by_name_all_vrf(argv[idx_interface]->arg);
|
|
||||||
if (ifp == NULL)
|
|
||||||
vty_out(vty, "No such interface name\n");
|
|
||||||
else
|
|
||||||
show_mpls_te_link_sub(vty, ifp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
show_mpls_te_link_sub(vty, ifp);
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4687,7 +4687,7 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf,
|
|||||||
|
|
||||||
ospf_show_vrf_name(ospf, vty, json, use_vrf);
|
ospf_show_vrf_name(ospf, vty, json, use_vrf);
|
||||||
|
|
||||||
ifp = if_lookup_by_name_all_vrf(argv[arg_base]->arg);
|
ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);
|
||||||
if (!ifp) {
|
if (!ifp) {
|
||||||
if (use_json)
|
if (use_json)
|
||||||
json_object_boolean_true_add(json, "noSuchIface");
|
json_object_boolean_true_add(json, "noSuchIface");
|
||||||
@ -4717,34 +4717,50 @@ static int show_ip_ospf_neighbor_int_common(struct vty *vty, struct ospf *ospf,
|
|||||||
|
|
||||||
DEFUN (show_ip_ospf_neighbor_int,
|
DEFUN (show_ip_ospf_neighbor_int,
|
||||||
show_ip_ospf_neighbor_int_cmd,
|
show_ip_ospf_neighbor_int_cmd,
|
||||||
"show ip ospf neighbor IFNAME [json]",
|
"show ip ospf [vrf <NAME>] neighbor IFNAME [json]",
|
||||||
SHOW_STR
|
SHOW_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
"Neighbor list\n"
|
"Neighbor list\n"
|
||||||
"Interface name\n"
|
"Interface name\n"
|
||||||
JSON_STR)
|
JSON_STR)
|
||||||
{
|
{
|
||||||
struct ospf *ospf;
|
struct ospf *ospf;
|
||||||
int idx_ifname = 4;
|
int idx_ifname = 0;
|
||||||
|
int idx_vrf = 0;
|
||||||
bool uj = use_json(argc, argv);
|
bool uj = use_json(argc, argv);
|
||||||
struct listnode *node = NULL;
|
|
||||||
int ret = CMD_SUCCESS;
|
int ret = CMD_SUCCESS;
|
||||||
struct interface *ifp = NULL;
|
struct interface *ifp = NULL;
|
||||||
|
char *vrf_name = NULL;
|
||||||
|
vrf_id_t vrf_id = VRF_DEFAULT;
|
||||||
|
struct vrf *vrf = NULL;
|
||||||
|
|
||||||
|
if (argv_find(argv, argc, "vrf", &idx_vrf))
|
||||||
|
vrf_name = argv[idx_vrf + 1]->arg;
|
||||||
|
if (vrf_name && strmatch(vrf_name, VRF_DEFAULT_NAME))
|
||||||
|
vrf_name = NULL;
|
||||||
|
if (vrf_name) {
|
||||||
|
vrf = vrf_lookup_by_name(vrf_name);
|
||||||
|
if (vrf)
|
||||||
|
vrf_id = vrf->vrf_id;
|
||||||
|
}
|
||||||
|
ospf = ospf_lookup_by_vrf_id(vrf_id);
|
||||||
|
|
||||||
|
if (!ospf || !ospf->oi_running)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (!uj)
|
if (!uj)
|
||||||
show_ip_ospf_neighbour_header(vty);
|
show_ip_ospf_neighbour_header(vty);
|
||||||
|
|
||||||
ifp = if_lookup_by_name_all_vrf(argv[idx_ifname]->arg);
|
argv_find(argv, argc, "IFNAME", &idx_ifname);
|
||||||
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
|
||||||
if (!ospf->oi_running)
|
|
||||||
continue;
|
|
||||||
if (!ifp || ifp->vrf_id != ospf->vrf_id)
|
|
||||||
continue;
|
|
||||||
ret = show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname,
|
|
||||||
argv, uj, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
|
||||||
|
if (!ifp)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = show_ip_ospf_neighbor_int_common(vty, ospf, idx_ifname,
|
||||||
|
argv, uj, 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5576,7 +5592,7 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
|
|||||||
vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance);
|
vty_out(vty, "\nOSPF Instance: %d\n\n", ospf->instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
ifp = if_lookup_by_name_all_vrf(argv[arg_base]->arg);
|
ifp = if_lookup_by_name(argv[arg_base]->arg, ospf->vrf_id);
|
||||||
if (!ifp) {
|
if (!ifp) {
|
||||||
if (!use_json)
|
if (!use_json)
|
||||||
vty_out(vty, "No such interface.\n");
|
vty_out(vty, "No such interface.\n");
|
||||||
@ -10648,28 +10664,45 @@ static void ospf_interface_clear(struct interface *ifp)
|
|||||||
|
|
||||||
DEFUN (clear_ip_ospf_interface,
|
DEFUN (clear_ip_ospf_interface,
|
||||||
clear_ip_ospf_interface_cmd,
|
clear_ip_ospf_interface_cmd,
|
||||||
"clear ip ospf interface [IFNAME]",
|
"clear ip ospf [vrf <NAME>] interface [IFNAME]",
|
||||||
CLEAR_STR
|
CLEAR_STR
|
||||||
IP_STR
|
IP_STR
|
||||||
"OSPF information\n"
|
"OSPF information\n"
|
||||||
|
VRF_CMD_HELP_STR
|
||||||
"Interface information\n"
|
"Interface information\n"
|
||||||
"Interface name\n")
|
"Interface name\n")
|
||||||
{
|
{
|
||||||
int idx_ifname = 4;
|
int idx_ifname = 0;
|
||||||
|
int idx_vrf = 0;
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct ospf *ospf = NULL;
|
struct ospf *ospf = NULL;
|
||||||
|
char *vrf_name = NULL;
|
||||||
|
vrf_id_t vrf_id = VRF_DEFAULT;
|
||||||
|
struct vrf *vrf = NULL;
|
||||||
|
|
||||||
if (argc == 4) /* Clear all the ospfv2 interfaces. */
|
if (argv_find(argv, argc, "vrf", &idx_vrf))
|
||||||
{
|
vrf_name = argv[idx_vrf + 1]->arg;
|
||||||
|
if (vrf_name && strmatch(vrf_name, VRF_DEFAULT_NAME))
|
||||||
|
vrf_name = NULL;
|
||||||
|
if (vrf_name) {
|
||||||
|
vrf = vrf_lookup_by_name(vrf_name);
|
||||||
|
if (vrf)
|
||||||
|
vrf_id = vrf->vrf_id;
|
||||||
|
}
|
||||||
|
if (!argv_find(argv, argc, "IFNAME", &idx_ifname)) {
|
||||||
|
/* Clear all the ospfv2 interfaces. */
|
||||||
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
|
||||||
struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
|
if (vrf_id != ospf->vrf_id)
|
||||||
|
continue;
|
||||||
|
if (!vrf)
|
||||||
|
vrf = vrf_lookup_by_id(ospf->vrf_id);
|
||||||
FOR_ALL_INTERFACES (vrf, ifp)
|
FOR_ALL_INTERFACES (vrf, ifp)
|
||||||
ospf_interface_clear(ifp);
|
ospf_interface_clear(ifp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Interface name is specified. */
|
/* Interface name is specified. */
|
||||||
ifp = if_lookup_by_name_all_vrf(argv[idx_ifname]->arg);
|
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
|
||||||
if (ifp == NULL)
|
if (ifp == NULL)
|
||||||
vty_out(vty, "No such interface name\n");
|
vty_out(vty, "No such interface name\n");
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user