From 1485bbe75554e5d01bcd8203fe75662c04f460f2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 22 Jan 2019 07:39:14 -0500 Subject: zebra: Add code to track sequence number from zebra_router The sequence number used should be unique and increase by 1 for netlink commands. This will allow the code to match up batched commands to actual requests, so that we can signal the failure correctly back. So start the movement and tracking of sequence numbers as an atomic uint32_t in zebra_router. Modify the dataplane code to start tracking contexts from this value. In future commits we will move more of the sequencing data into using this value. Signed-off-by: Donald Sharp --- zebra/zebra_router.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'zebra/zebra_router.c') 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 +#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(); -- cgit v1.2.3