Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pbrd: add ability to change pbr-policy map on an interface #9

Merged
merged 1 commit into from
Feb 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions pbrd/pbr_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,34 @@ DEFPY (pbr_policy,
"Name of the pbr-map to apply\n")
{
VTY_DECLVAR_CONTEXT(interface, ifp);
struct pbr_map *pbrm;
struct pbr_map *pbrm, *old_pbrm;
struct pbr_interface *pbr_ifp = ifp->info;

pbrm = pbrm_find(mapname);

if (no) {
if (pbrm)
pbr_map_interface_delete(pbrm, ifp);
else
if (strcmp(pbr_ifp->mapname, mapname) == 0)
strcpy(pbr_ifp->mapname, "");
if (strcmp(pbr_ifp->mapname, mapname) == 0) {
strcpy(pbr_ifp->mapname, "");

if (pbrm)
pbr_map_interface_delete(pbrm, ifp);
}
} else {
if (pbrm)
pbr_map_add_interface(pbrm, ifp);
else
if (strcmp(pbr_ifp->mapname, "") == 0) {
strcpy(pbr_ifp->mapname, mapname);

if (pbrm)
pbr_map_add_interface(pbrm, ifp);
} else {
if (!(strcmp(pbr_ifp->mapname, mapname) == 0)) {
old_pbrm = pbrm_find(pbr_ifp->mapname);
if (old_pbrm)
pbr_map_interface_delete(old_pbrm, ifp);
strcpy(pbr_ifp->mapname, mapname);
if (pbrm)
pbr_map_add_interface(pbrm, ifp);
}
}
}

return CMD_SUCCESS;
Expand Down