summaryrefslogtreecommitdiff
path: root/pbrd/pbr_zebra.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-03-19 09:04:17 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-04-06 13:22:43 -0400
commitb13e5ad68a740b66c921c5ab1314e0898f0ed310 (patch)
treef08e165c4507040ecfd17ec9c10b109f5b5fa941 /pbrd/pbr_zebra.c
parentd36d0d57711ec79bb7ff4360b62d80b1a9809f6f (diff)
pbrd: Remove pbr_events
The pbr_events.c file was a mistake in that it overly complicated the code and made it hard to think about what was happening. Remove all the events and just do the work where needed. Additionally rethink the sending of the pbr map to zebra and only send one notification at a time instead of having the sending function attempt to figure out what to do. Clean up some of the no form of commands to make them work properly. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Diffstat (limited to 'pbrd/pbr_zebra.c')
-rw-r--r--pbrd/pbr_zebra.c68
1 files changed, 12 insertions, 56 deletions
diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c
index b066965249..971fe65aaf 100644
--- a/pbrd/pbr_zebra.c
+++ b/pbrd/pbr_zebra.c
@@ -56,7 +56,7 @@ static struct interface *zebra_interface_if_lookup(struct stream *s)
return if_lookup_by_name(ifname_tmp, VRF_DEFAULT);
}
-static struct pbr_interface *pbr_if_new(struct interface *ifp)
+struct pbr_interface *pbr_if_new(struct interface *ifp)
{
struct pbr_interface *pbr_ifp;
@@ -497,14 +497,11 @@ static void pbr_encode_pbr_map_sequence(struct stream *s,
stream_putl(s, ifp->ifindex);
}
-void pbr_send_pbr_map(struct pbr_map *pbrm, bool install)
+void pbr_send_pbr_map(struct pbr_map_sequence *pbrms,
+ struct pbr_map_interface *pmi, bool install)
{
- struct listnode *inode, *snode;
- struct pbr_map_sequence *pbrms;
- struct pbr_map_interface *pmi;
+ struct pbr_map *pbrm = pbrms->parent;
struct stream *s;
- uint32_t total;
- ssize_t tspot;
DEBUGD(&pbr_dbg_zebra, "%s: for %s %d", __PRETTY_FUNCTION__, pbrm->name,
install);
@@ -516,59 +513,18 @@ void pbr_send_pbr_map(struct pbr_map *pbrm, bool install)
install ? ZEBRA_RULE_ADD : ZEBRA_RULE_DELETE,
VRF_DEFAULT);
- total = 0;
- tspot = stream_get_endp(s);
- stream_putl(s, 0);
- for (ALL_LIST_ELEMENTS_RO(pbrm->incoming, inode, pmi)) {
-
- DEBUGD(&pbr_dbg_zebra, "%s: \t%s %s %d %s %u",
- __PRETTY_FUNCTION__, install ? "Installing" : "Deleting",
- pbrm->name, install, pmi->ifp->name, pmi->delete);
-
- if (!install && pmi->delete) {
- for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, snode,
- pbrms)) {
- pbr_encode_pbr_map_sequence(s,
- pbrms, pmi->ifp);
- total++;
- }
- continue;
- }
-
- for (ALL_LIST_ELEMENTS_RO(pbrm->seqnumbers, snode, pbrms)) {
-
- DEBUGD(&pbr_dbg_zebra, "%s: \tSeqno: %u %" PRIu64 " valid %u",
- __PRETTY_FUNCTION__, pbrms->seqno, pbrms->reason,
- pbrm->valid);
-
- if (!install &&
- !(pbrms->reason & PBR_MAP_DEL_SEQUENCE_NUMBER))
- continue;
-
- if (!install && !pbrms->installed)
- continue;
-
- if (install && pbrms->installed)
- continue;
+ /*
+ * We are sending one item at a time at the moment
+ */
+ stream_putl(s, 1);
- DEBUGD(&pbr_dbg_zebra, "%s: \t Seq: %u ifp %s",
- __PRETTY_FUNCTION__, pbrms->seqno,
- pmi->ifp->name);
+ DEBUGD(&pbr_dbg_zebra, "%s: \t%s %s %d %s %u",
+ __PRETTY_FUNCTION__, install ? "Installing" : "Deleting",
+ pbrm->name, install, pmi->ifp->name, pmi->delete);
- pbr_encode_pbr_map_sequence(s, pbrms, pmi->ifp);
- total++;
- }
- }
+ pbr_encode_pbr_map_sequence(s, pbrms, pmi->ifp);
- DEBUGD(&pbr_dbg_zebra, "%s: Putting %u at %zu ", __PRETTY_FUNCTION__,
- total, tspot);
-
- stream_putl_at(s, tspot, total);
stream_putw_at(s, 0, stream_get_endp(s));
- if (!total) {
- stream_reset(s);
- return;
- }
zclient_send_message(zclient);
}