diff options
| author | Mark Stapp <mjs@voltanet.io> | 2019-01-24 09:16:12 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-24 09:16:12 -0500 |
| commit | c8d3e7955417ac882dd9b078011c52ee97c3577a (patch) | |
| tree | d4c8353576fe7f7ece5f6c89cd0c2353075e4cc7 | |
| parent | a28436ca476f4a862ede8f36e7257741b404f876 (diff) | |
| parent | 1485bbe75554e5d01bcd8203fe75662c04f460f2 (diff) | |
Merge pull request #3642 from donaldsharp/sequence
zebra: Add code to track sequence number from zebra_router
| -rw-r--r-- | zebra/zebra_dplane.c | 6 | ||||
| -rw-r--r-- | zebra/zebra_router.c | 12 | ||||
| -rw-r--r-- | zebra/zebra_router.h | 5 |
3 files changed, 21 insertions, 2 deletions
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index fc316dbcb6..6fbad2f71e 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -24,6 +24,7 @@ #include "lib/memory.h" #include "lib/queue.h" #include "lib/zebra.h" +#include "zebra/zebra_router.h" #include "zebra/zebra_memory.h" #include "zebra/zserv.h" #include "zebra/zebra_dplane.h" @@ -863,7 +864,7 @@ static int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, /* Trying out the sequence number idea, so we can try to detect * when a result is stale. */ - re->dplane_sequence++; + re->dplane_sequence = zebra_router_get_next_sequence(); ctx->zd_seq = re->dplane_sequence; ret = AOK; @@ -1012,7 +1013,8 @@ dplane_route_update_internal(struct route_node *rn, old_re && (old_re != re)) { ctx->zd_is_update = true; - old_re->dplane_sequence++; + old_re->dplane_sequence = + zebra_router_get_next_sequence(); ctx->zd_old_seq = old_re->dplane_sequence; ctx->u.rinfo.zd_old_tag = old_re->tag; diff --git a/zebra/zebra_router.c b/zebra/zebra_router.c index f0cc8d4fd7..3e94d6bca8 100644 --- a/zebra/zebra_router.c +++ b/zebra/zebra_router.c @@ -21,6 +21,9 @@ */ #include "zebra.h" +#include <pthread.h> +#include "lib/frratomic.h" + #include "zebra_router.h" #include "zebra_memory.h" #include "zebra_pbr.h" @@ -169,6 +172,13 @@ static void zebra_router_free_table(struct zebra_router_table *zrt) XFREE(MTYPE_ZEBRA_NS, zrt); } +uint32_t zebra_router_get_next_sequence(void) +{ + return 1 + + atomic_fetch_add_explicit(&zrouter.sequence_num, 1, + memory_order_relaxed); +} + void zebra_router_terminate(void) { struct zebra_router_table *zrt, *tmp; @@ -194,6 +204,8 @@ void zebra_router_terminate(void) void zebra_router_init(void) { + zrouter.sequence_num = 0; + zebra_vxlan_init(); zebra_mlag_init(); diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h index 1e0788d1ba..f63dcd984e 100644 --- a/zebra/zebra_router.h +++ b/zebra/zebra_router.h @@ -62,6 +62,9 @@ struct zebra_router { #if defined(HAVE_RTADV) struct rtadv rtadv; #endif /* HAVE_RTADV */ + + /* A sequence number used for tracking routes */ + _Atomic uint32_t sequence_num; }; extern struct zebra_router zrouter; @@ -83,4 +86,6 @@ extern unsigned long zebra_router_score_proto(uint8_t proto, extern void zebra_router_sweep_route(void); extern void zebra_router_show_table_summary(struct vty *vty); + +extern uint32_t zebra_router_get_next_sequence(void); #endif |
