pbrd: properly handle duplicate set vrf XX configs

Properly handle the case where we are sent the same `set vrf`
configs for a pbr map repeatedly. If we are sent the same
config, we return successfully without doing anyting.

If the config is different and its not a [no], then return failure
as we did before since we don't support atomic replace yet.

Before, we would fail anytime even if the config sent was the same
as is already there. This would cause frr-reload to mark as a
failure when it tried to re-apply the same config.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
This commit is contained in:
Stephen Worley 2020-03-19 12:32:13 -04:00
parent 795fbef4df
commit 9bf1b0f74a

View File

@ -444,12 +444,37 @@ DEFPY(pbr_map_vrf, pbr_map_vrf_cmd,
goto done;
}
if (pbrms->vrf_lookup || pbrms->vrf_unchanged) {
vty_out(vty, SET_VRF_EXISTS_STR);
ret = CMD_WARNING_CONFIG_FAILED;
/*
* Determine if a set vrf * command already exists.
*
* If its equivalent, just return success.
*
* Else, return failure, we don't allow atomic swaps yet.
*/
if (vrf_name && pbrms->vrf_lookup) {
/* New vrf specified and one already exists */
/* Is this vrf different from one already configured? */
if (strncmp(pbrms->vrf_name, vrf_name, sizeof(pbrms->vrf_name))
!= 0)
goto vrf_exists;
goto done;
} else if (!vrf_name && pbrms->vrf_unchanged) {
/* Unchanged specified and unchanged already exists */
goto done;
} else if (vrf_name && pbrms->vrf_unchanged) {
/* New vrf specified and unchanged is already set */
goto vrf_exists;
} else if (!vrf_name && pbrms->vrf_lookup) {
/* Unchanged specified and vrf to lookup already exists */
goto vrf_exists;
}
/* Create new lookup VRF or Unchanged */
if (vrf_name) {
if (!pbr_vrf_lookup_by_name(vrf_name)) {
vty_out(vty, "Specified: %s is non-existent\n",
@ -467,6 +492,11 @@ DEFPY(pbr_map_vrf, pbr_map_vrf_cmd,
done:
return ret;
vrf_exists:
vty_out(vty, SET_VRF_EXISTS_STR);
ret = CMD_WARNING_CONFIG_FAILED;
return ret;
}
DEFPY (pbr_policy,