summaryrefslogtreecommitdiff
path: root/lib/northbound_grpc.cpp
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2020-04-27 13:13:57 -0300
committerRenato Westphal <renato@opensourcerouting.org>2020-05-28 19:22:54 -0300
commit13d6b9c1343a1f925e3ffd7be0938bf1f395b461 (patch)
tree93f50208c9c3e0403fb01b697234b815f7889a50 /lib/northbound_grpc.cpp
parent1be4decb04be48d73ea90f6feb0f33af25499c19 (diff)
lib: introduce the northbound context structure
The new northbound context structure contains information about the client performing a configuration transaction. This information will be made available to all configuration callbacks through the args->context parameter. The usefulness of this structure comes from the fact that it can be used as a communication channel (both input and output) between the northbound callbacks and the northbound clients. This can be done through its "client_data" field which contains client-specific data. This should cover some very specific scenarios where a northbound callback should perform an action only if the configuration change is coming from a given client. An example would be sending a PCEP response to a PCE when an SR-TE policy is created or modified through the PCEP northbound client (for that to happen, the northbound callbacks need to have access to the PCEP request ID, which needs to be available). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/northbound_grpc.cpp')
-rw-r--r--lib/northbound_grpc.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp
index 2962a977eb..b038d10118 100644
--- a/lib/northbound_grpc.cpp
+++ b/lib/northbound_grpc.cpp
@@ -672,13 +672,17 @@ class NorthboundImpl
// Execute the user request.
+ struct nb_context context = {};
+ context.client = NB_CLIENT_GRPC;
+
switch (phase) {
case frr::CommitRequest::VALIDATE:
- ret = nb_candidate_validate(candidate->config);
+ ret = nb_candidate_validate(&context,
+ candidate->config);
break;
case frr::CommitRequest::PREPARE:
ret = nb_candidate_commit_prepare(
- candidate->config, NB_CLIENT_GRPC, NULL,
+ &context, candidate->config,
comment.c_str(),
&candidate->transaction);
break;
@@ -693,8 +697,8 @@ class NorthboundImpl
break;
case frr::CommitRequest::ALL:
ret = nb_candidate_commit(
- candidate->config, NB_CLIENT_GRPC, NULL,
- true, comment.c_str(), &transaction_id);
+ &context, candidate->config, true,
+ comment.c_str(), &transaction_id);
break;
}