Skip to content

Commit

Permalink
pbrd: Remove pbr_events
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
  • Loading branch information
donaldsharp committed Mar 19, 2018
1 parent 7af4434 commit 6c7c252
Show file tree
Hide file tree
Showing 13 changed files with 410 additions and 741 deletions.
15 changes: 14 additions & 1 deletion lib/nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "prefix.h"
#include "nexthop.h"
#include "mpls.h"
#include "jhash.h"

DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop")
DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label")
Expand Down Expand Up @@ -240,7 +241,7 @@ void nexthop_del_labels(struct nexthop *nexthop)
}
}

const char *nexthop2str(struct nexthop *nexthop, char *str, int size)
const char *nexthop2str(const struct nexthop *nexthop, char *str, int size)
{
switch (nexthop->type) {
case NEXTHOP_TYPE_IFINDEX:
Expand Down Expand Up @@ -310,3 +311,15 @@ unsigned int nexthop_level(struct nexthop *nexthop)

return rv;
}

uint32_t nexthop_hash(struct nexthop *nexthop)
{
uint32_t key;

key = jhash_1word(nexthop->vrf_id, 0x45afe398);
key = jhash_1word(nexthop->ifindex, key);
key = jhash_1word(nexthop->type, key);
key = jhash(&nexthop->gate, sizeof(union g_addr), key);

return key;
}
19 changes: 18 additions & 1 deletion lib/nexthop.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ void nexthop_add_labels(struct nexthop *, enum lsp_types_t, u_int8_t,
mpls_label_t *);
void nexthop_del_labels(struct nexthop *);

/*
* Hash a nexthop. Suitable for use with hash tables.
*
* This function uses the following values when computing the hash:
* - vrf_id
* - ifindex
* - type
* - gate
*
* nexthop
* The nexthop to hash
*
* Returns:
* 32-bit hash of nexthop
*/
uint32_t nexthop_hash(struct nexthop *nexthop);

extern bool nexthop_same(const struct nexthop *nh1, const struct nexthop *nh2);

extern const char *nexthop_type_to_str(enum nexthop_types_t nh_type);
Expand All @@ -126,7 +143,7 @@ extern int nexthop_same_no_recurse(const struct nexthop *next1,
extern int nexthop_labels_match(struct nexthop *nh1, struct nexthop *nh2);
extern int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2);

extern const char *nexthop2str(struct nexthop *nexthop, char *str, int size);
extern const char *nexthop2str(const struct nexthop *nexthop, char *str, int size);
extern struct nexthop *nexthop_next(struct nexthop *nexthop);
extern unsigned int nexthop_level(struct nexthop *nexthop);
#endif /*_LIB_NEXTHOP_H */
220 changes: 0 additions & 220 deletions pbrd/pbr_event.c

This file was deleted.

Loading

0 comments on commit 6c7c252

Please sign in to comment.