-
Notifications
You must be signed in to change notification settings - Fork 26
Add config-read and run thread_birds with arguments. #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bird-import-proto
Are you sure you want to change the base?
Changes from all commits
c0cfe2f
dd064b6
8b9ca68
e50920e
7c177c7
c5d0822
8581dc1
17e89f6
c5aaf0a
63e7840
a9e7fde
d7ca9ba
2d82f7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -197,6 +197,32 @@ controlplane::base_t config_parser_t::loadConfig(const std::string& rootFilePath | |||||||||||||||||||||||
| return baseNext; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| void config_parser_t::loadConfig_route_bird([[maybe_unused]]controlplane::base_t& baseNext, | ||||||||||||||||||||||||
| std::vector<controlplane::route::bird_import_t>& birdsImport, | ||||||||||||||||||||||||
| const nlohmann::json& birdJson) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| using BirdImport = controlplane::route::bird_import_t; | ||||||||||||||||||||||||
| for (const auto& elemJson : birdJson) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| BirdImport import; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (exist(elemJson, BirdImport::socketStr)) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| import.socket = elemJson[BirdImport::socketStr]; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (exist(elemJson, BirdImport::vrfStr)) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| import.vrf = elemJson[BirdImport::vrfStr]; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+209
to
+217
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if those keys do not exist? We need to use some default value then, right? Otherwise I think it will be two empty strings.
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| YANET_LOG_INFO("loadConfig_route_bird: socket(%s), vrf(%s)\n", | ||||||||||||||||||||||||
| import.socket.data(), | ||||||||||||||||||||||||
| import.vrf.data()); | ||||||||||||||||||||||||
| birdsImport.push_back(std::move(import)); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| void config_parser_t::loadConfig_logicalPort(controlplane::base_t& baseNext, | ||||||||||||||||||||||||
| const std::string& moduleId, | ||||||||||||||||||||||||
| const nlohmann::json& moduleJson) | ||||||||||||||||||||||||
|
|
@@ -367,6 +393,13 @@ void config_parser_t::loadConfig_route(controlplane::base_t& baseNext, | |||||||||||||||||||||||
| route.tunnel_enabled = false; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (exist(moduleJson, "birdImport")) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| loadConfig_route_bird(baseNext, | ||||||||||||||||||||||||
| route.bird_imports, | ||||||||||||||||||||||||
| moduleJson["birdImport"]); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| route.routeId = routeId; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -538,6 +538,18 @@ common::icp::controlplane_values::response cControlPlane::controlplane_values() | |
| return response; | ||
| } | ||
|
|
||
| common::icp::route_config::response cControlPlane::getRoute() const | ||
| { | ||
| common::icp::route_config::response response; | ||
|
|
||
| { | ||
| auto current_guard = generations.current_lock_guard(); | ||
| response = generations.current().routes; | ||
| } | ||
|
|
||
| return response; | ||
| } | ||
|
|
||
| common::icp::getDecapPrefixes::response cControlPlane::command_getDecapPrefixes() | ||
| { | ||
| common::icp::getDecapPrefixes::response response; | ||
|
|
@@ -941,6 +953,14 @@ eResult cControlPlane::loadConfig(const std::string& rootFilePath, | |
| } | ||
|
|
||
| YANET_LOG_INFO("dataplane has been updated (stage 7)\n"); | ||
| for (auto& module : modules) | ||
| { | ||
| if (rib_t* rib = dynamic_cast<rib_t*>(module)) | ||
| { | ||
| rib->bird_import_get(); | ||
| rib->moduleStart(); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+956
to
964
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is every module is also a rib module? I don't quite understand.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this stage, I need to call one method that is only in rib_t (bird_import_get()), using a virtual function for all classes is somehow strange. I'll think about it, or I'm ready to discuss what's best.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| catch (const error_result_t& error) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inlinehere because we need that field to be ODR-usable: linkWe're binding it to a reference by passing it to
existfunction => ODR-usage => we must provide exactly one definition of that static data member in the entire program and the simplest way to do so -- useinlinehere.std::string_viewfor string literals, but the issue with it is thatnlohmann::jsondoesn't have an overload foroperator[]withstd::string_view. However, it does have overloads forstd::stringandconst char*. So you could either use the change I suggested, or go withstd::string_viewand pass.data()like this:Either way works for me.