summaryrefslogtreecommitdiff
path: root/zebra/zebra_dplane.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2018-11-12 15:57:03 -0500
committerMark Stapp <mjs@voltanet.io>2018-11-21 10:38:08 -0500
commit62b8bb7a1776ea98e5874a4a057617e335a7f77c (patch)
treebd76e8af2363cff81492e93f132cbc4de019e669 /zebra/zebra_dplane.c
parentad6aad4d0bc06f7711d05e1d05576ea25aac04c5 (diff)
zebra: separate netlink socket for dataplane
Use a separate netlink socket for the dataplane's updates, to avoid races between the dataplane pthread and the zebra main pthread. Revise zebra shutdown so that the dataplane netlink socket is cleaned-up later, after all shutdown-time dataplane work has been done. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'zebra/zebra_dplane.c')
-rw-r--r--zebra/zebra_dplane.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index 95df243829..ba0f1b41aa 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -249,6 +249,8 @@ static struct zebra_dplane_globals {
/* Prototypes */
static int dplane_thread_loop(struct thread *event);
+static void dplane_info_from_zns(struct zebra_dplane_info *ns_info,
+ struct zebra_ns *zns);
/*
* Public APIs
@@ -706,16 +708,17 @@ static int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx,
zvrf = vrf_info_lookup(re->vrf_id);
zns = zvrf->zns;
- zebra_dplane_info_from_zns(&(ctx->zd_ns_info), zns, true /*is_cmd*/);
+ /* Internal copy helper */
+ dplane_info_from_zns(&(ctx->zd_ns_info), zns);
#if defined(HAVE_NETLINK)
/* Increment message counter after copying to context struct - may need
* two messages in some 'update' cases.
*/
if (op == DPLANE_OP_ROUTE_UPDATE)
- zns->netlink_cmd.seq += 2;
+ zns->netlink_dplane.seq += 2;
else
- zns->netlink_cmd.seq++;
+ zns->netlink_dplane.seq++;
#endif /* NETLINK*/
/* Copy nexthops; recursive info is included too */
@@ -1163,12 +1166,30 @@ void dplane_provider_enqueue_out_ctx(struct zebra_dplane_provider *prov,
memory_order_relaxed);
}
+/*
+ * Accessor for provider object
+ */
bool dplane_provider_is_threaded(const struct zebra_dplane_provider *prov)
{
return (prov->dp_flags & DPLANE_PROV_FLAG_THREADED);
}
/*
+ * Internal helper that copies information from a zebra ns object; this is
+ * called in the zebra main pthread context as part of dplane ctx init.
+ */
+static void dplane_info_from_zns(struct zebra_dplane_info *ns_info,
+ struct zebra_ns *zns)
+{
+ ns_info->ns_id = zns->ns_id;
+
+#if defined(HAVE_NETLINK)
+ ns_info->is_cmd = true;
+ ns_info->nls = zns->netlink_dplane;
+#endif /* NETLINK */
+}
+
+/*
* Provider api to signal that work/events are available
* for the dataplane pthread.
*/