summaryrefslogtreecommitdiff
path: root/pbrd/pbr_vty.c
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2021-10-27 15:29:39 -0400
committerGitHub <noreply@github.com>2021-10-27 15:29:39 -0400
commitf727c6ae8a62be99bd5be5a191fbd7df455a35f0 (patch)
tree9e9bde7f79993485caf03678351041c05379a81e /pbrd/pbr_vty.c
parentf1506cf36b91014d920f82bbfe655651a2356141 (diff)
parent0df2e1888b1e8011bc1e3ec6ed6c34a9e6fcaae9 (diff)
Merge pull request #9837 from idryzhov/cleanup-if-by-name-vrf-all
*: fix usage of if_lookup_by_name_all_vrf
Diffstat (limited to 'pbrd/pbr_vty.c')
-rw-r--r--pbrd/pbr_vty.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c
index a16d00c472..cac056abd0 100644
--- a/pbrd/pbr_vty.c
+++ b/pbrd/pbr_vty.c
@@ -561,14 +561,37 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
nhop.vrf_id = vrf->vrf_id;
if (intf) {
- struct interface *ifp;
+ struct interface *ifp = NULL;
+ struct interface *ifptmp;
+ struct vrf *vrftmp;
+ int count = 0;
+
+ if (vrf_is_backend_netns() && vrf_name) {
+ ifp = if_lookup_by_name_vrf(intf, vrf);
+ } else {
+ RB_FOREACH (vrftmp, vrf_name_head, &vrfs_by_name) {
+ ifptmp = if_lookup_by_name_vrf(intf, vrftmp);
+ if (ifptmp) {
+ ifp = ifptmp;
+ count++;
+ if (!vrf_is_backend_netns())
+ break;
+ }
+ }
+ }
- ifp = if_lookup_by_name_all_vrf(intf);
if (!ifp) {
vty_out(vty, "Specified Intf %s does not exist\n",
intf);
return CMD_WARNING_CONFIG_FAILED;
}
+ if (count > 1) {
+ vty_out(vty,
+ "Specified Intf %s exists in multiple VRFs\n",
+ intf);
+ vty_out(vty, "You must specify the nexthop-vrf\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
if (ifp->vrf_id != vrf->vrf_id) {
struct vrf *actual;