From fd1898fedb23d50585a0fec028bdeb4625987365 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Thu, 15 Mar 2018 22:13:25 +0000 Subject: [PATCH] pbrd: convert from reason code to deleted flag Signed-off-by: Don Slice --- pbrd/pbr_map.c | 4 ++-- pbrd/pbr_map.h | 7 ++++++- pbrd/pbr_nht.c | 1 + pbrd/pbr_vty.c | 4 ++-- pbrd/pbr_zebra.c | 6 +++--- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pbrd/pbr_map.c b/pbrd/pbr_map.c index dbe8ecbe2f67..dcfaf7cd31f3 100644 --- a/pbrd/pbr_map.c +++ b/pbrd/pbr_map.c @@ -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) diff --git a/pbrd/pbr_map.h b/pbrd/pbr_map.h index 841f840880ca..5a150bd3ea1d 100644 --- a/pbrd/pbr_map.h +++ b/pbrd/pbr_map.h @@ -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 @@ -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 diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index ca65080abd15..395b8edc7ec6 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -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); diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index b92facffcb5b..e0be35f2d7d9 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -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; } } diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index c0369f736b2b..bfc7ef017762 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -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;