-
Notifications
You must be signed in to change notification settings - Fork 29
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 8 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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -141,6 +141,32 @@ class interface_t | |||||||||
| common::globalBase::tFlow flow; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| class bird_import_t | ||||||||||
| { | ||||||||||
| public: | ||||||||||
| void pop(common::stream_in_t& stream) | ||||||||||
| { | ||||||||||
| stream.pop(socket); | ||||||||||
| stream.pop(vrf); | ||||||||||
| stream.pop(flow); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void push(common::stream_out_t& stream) const | ||||||||||
| { | ||||||||||
| stream.push(socket); | ||||||||||
| stream.push(vrf); | ||||||||||
| stream.push(flow); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public: | ||||||||||
| inline static const std::string socketStr = "socket"; | ||||||||||
| inline static const std::string vrfStr = "vrf"; | ||||||||||
|
Comment on lines
+114
to
+115
Contributor
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.
Suggested change
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.
Contributor
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.
We're binding it to a reference by passing it to
if (exist(elemJson, BirdImport::socketStr))
{
import.socket = elemJson[BirdImport::socketStr.data()];
}
if (exist(elemJson, BirdImport::vrfStr))
{
import.vrf = elemJson[BirdImport::vrfStr.data()];
}Either way works for me.
|
||||||||||
|
|
||||||||||
| std::string socket; | ||||||||||
| std::string vrf; | ||||||||||
| common::globalBase::tFlow flow; | ||||||||||
| }; | ||||||||||
|
ol-imorozko marked this conversation as resolved.
|
||||||||||
|
|
||||||||||
| class config_t | ||||||||||
| { | ||||||||||
| public: | ||||||||||
|
|
@@ -168,6 +194,7 @@ class config_t | |||||||||
| stream.pop(local_prefixes); | ||||||||||
| stream.pop(peers); | ||||||||||
| stream.pop(interfaces); | ||||||||||
| stream.pop(bird_imports); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void push(common::stream_out_t& stream) const | ||||||||||
|
|
@@ -183,6 +210,7 @@ class config_t | |||||||||
| stream.push(local_prefixes); | ||||||||||
| stream.push(peers); | ||||||||||
| stream.push(interfaces); | ||||||||||
| stream.push(bird_imports); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public: | ||||||||||
|
|
@@ -197,6 +225,7 @@ class config_t | |||||||||
| std::set<common::ip_prefix_t> local_prefixes; ///< for fallback to default | ||||||||||
| std::map<uint32_t, std::string> peers; | ||||||||||
| std::map<std::string, interface_t> interfaces; | ||||||||||
| std::vector<bird_import_t> bird_imports; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| 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(controlplane::base_t& baseNext, | ||||||||||||||||||||||||
|
Markuu-s marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||
| 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
Contributor
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
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| birdsImport.push_back(import); | ||||||||||||||||||||||||
| YANET_LOG_INFO("loadConfig_route_bird: socket(%s), vrf(%s)\n", | ||||||||||||||||||||||||
| import.socket.data(), | ||||||||||||||||||||||||
| import.vrf.data()); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Markuu-s marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| 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 |
|---|---|---|
|
|
@@ -526,6 +526,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; | ||
|
|
@@ -924,6 +936,12 @@ 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
Contributor
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.
Contributor
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) | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.