Skip to content

Commit

Permalink
pbrd: convert from reason code to deleted flag
Browse files Browse the repository at this point in the history
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
  • Loading branch information
dslicenc authored and donaldsharp committed Mar 15, 2018
1 parent 763ddb7 commit fd1898f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pbrd/pbr_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ extern void pbr_map_delete(const char *name, uint32_t seqno)
pbrm = pbrm_find(name);

for (ALL_LIST_ELEMENTS(pbrm->seqnumbers, node, nnode, pbrms)) {
if (pbrms->reason & PBR_MAP_DEL_SEQUENCE_NUMBER)
if (pbrms->delete)
pbr_send_pbr_map(pbrms, 0);

if (!(pbrms->reason & PBR_MAP_DEL_SEQUENCE_NUMBER))
if (pbrms->delete == false)
continue;

if (pbrms->nhg)
Expand Down
7 changes: 6 additions & 1 deletion pbrd/pbr_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ struct pbr_map_sequence {
bool nhs_installed;

bool installed;

/*
* Are we deleting the pbmrms
*/
bool delete;

/*
* A reason of 0 means we think the pbr_map_sequence is good to go
* We can accumuluate multiple failure states
Expand All @@ -116,7 +122,6 @@ struct pbr_map_sequence {
#define PBR_MAP_INVALID_NO_NEXTHOPS (1 << 2)
#define PBR_MAP_INVALID_BOTH_NHANDGRP (1 << 3)
#define PBR_MAP_INVALID_SRCDST (1 << 4)
#define PBR_MAP_DEL_SEQUENCE_NUMBER (1 << 5)
uint64_t reason;

QOBJ_FIELDS
Expand Down
1 change: 1 addition & 0 deletions pbrd/pbr_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ void pbr_nht_delete_individual_nexthop(const char *name, uint32_t seqno)
struct nexthop *nh;

pbrms = pbrms_get(name, seqno);
pbrms->delete = true;

memset(&find, 0, sizeof(find));
strcpy(&find.name[0], pbrms->internal_nhg_name);
Expand Down
4 changes: 2 additions & 2 deletions pbrd/pbr_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map WORD [seq (1-65535)]",

if (seqno) {
pbrms = pbrms_get(pbrm->name, seqno);
pbrms->reason |= PBR_MAP_DEL_SEQUENCE_NUMBER;
pbrms->delete = true;
} else {
for (ALL_LIST_ELEMENTS(pbrm->seqnumbers, node, next_node,
pbrms)) {
if (pbrms)
pbrms->reason |= PBR_MAP_DEL_SEQUENCE_NUMBER;
pbrms->delete = true;
}
}

Expand Down
6 changes: 3 additions & 3 deletions pbrd/pbr_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,9 @@ void pbr_send_pbr_map(struct pbr_map_sequence *pbrms, bool install)
__PRETTY_FUNCTION__, pbrms->seqno, pbrms->reason,
pbrm->valid);

if (!install &&
!(pbrms->reason & PBR_MAP_DEL_SEQUENCE_NUMBER))
encode = false;
if (!install && (pbrms->delete == false))
encode = false;

if (!install && !pbrms->installed)
encode = false;

Expand Down

0 comments on commit fd1898f

Please sign in to comment.