diff options
| author | Russ White <russ@riw.us> | 2021-10-27 15:29:39 -0400 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-27 15:29:39 -0400 | 
| commit | f727c6ae8a62be99bd5be5a191fbd7df455a35f0 (patch) | |
| tree | 9e9bde7f79993485caf03678351041c05379a81e /pbrd/pbr_vty.c | |
| parent | f1506cf36b91014d920f82bbfe655651a2356141 (diff) | |
| parent | 0df2e1888b1e8011bc1e3ec6ed6c34a9e6fcaae9 (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.c | 27 | 
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;  | 
