-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add config-read and run thread_birds with arguments. #265
base: bird-import-proto
Are you sure you want to change the base?
Conversation
common/controlplaneconfig.h
Outdated
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); | ||
} | ||
|
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.
Please rebase your branch onto the latest main
.
There will be conflicts because, for example, we don't use push/pop
boilerplate anymore and instead do this:
class config_t
{
public:
config_t() = default;
SERIALIZABLE(nat64stateful_id, dscp_mark_type, dscp, ipv6_prefixes, ipv4_prefixes, announces, next_module);
public:
nat64stateful_id_t nat64stateful_id;
common::eDscpMarkType dscp_mark_type{common::eDscpMarkType::never};
uint8_t dscp{};
std::vector<common::ipv6_prefix_t> ipv6_prefixes;
std::vector<common::ipv4_prefix_t> ipv4_prefixes;
std::set<common::ip_prefix_t> announces;
controlplane::state_timeout state_timeout;
std::string next_module;
common::globalBase::flow_t flow;
};
That's just an example of the existing code. Note how we use the SERIALIZABLE
macro with the names of the fields used for serialization
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.
Updated bird-import-proto and this branches.
inline static const std::string socketStr = "socket"; | ||
inline static const std::string vrfStr = "vrf"; |
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.
inline static const std::string socketStr = "socket"; | |
inline static const std::string vrfStr = "vrf"; | |
static constexpr auto socketStr = "socket"; | |
static constexpr auto vrfStr = "vrf"; |
class bird_import_t | ||
{ | ||
public: | ||
SERIALIZABLE(socket, vrf); | ||
|
||
public: | ||
inline static const std::string socketStr = "socket"; | ||
inline static const std::string vrfStr = "vrf"; | ||
|
||
std::string socket; | ||
std::string vrf; | ||
}; |
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.
Since everything is public, why not just
class bird_import_t | |
{ | |
public: | |
SERIALIZABLE(socket, vrf); | |
public: | |
inline static const std::string socketStr = "socket"; | |
inline static const std::string vrfStr = "vrf"; | |
std::string socket; | |
std::string vrf; | |
}; | |
struct bird_import_t | |
{ | |
std::string socket; | |
std::string vrf; | |
static constexpr auto socketStr = "socket"; | |
static constexpr auto vrfStr = "vrf"; | |
SERIALIZABLE(socket, vrf); | |
}; |
@@ -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, |
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.
I guess we need
void config_parser_t::loadConfig_route_bird(controlplane::base_t& baseNext, | |
void config_parser_t::loadConfig_route_bird([[maybe_unused]] controlplane::base_t& baseNext, |
birdsImport.push_back(import); | ||
YANET_LOG_INFO("loadConfig_route_bird: socket(%s), vrf(%s)\n", | ||
import.socket.data(), | ||
import.vrf.data()); | ||
} |
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.
interchange those lines, and now we will be able to benefit from moving import
object, which is essentially two std::string
's
birdsImport.push_back(import); | |
YANET_LOG_INFO("loadConfig_route_bird: socket(%s), vrf(%s)\n", | |
import.socket.data(), | |
import.vrf.data()); | |
} | |
YANET_LOG_INFO("loadConfig_route_bird: socket(%s), vrf(%s)\n", | |
import.socket.data(), | |
import.vrf.data()); | |
birdsImport.push_back(std::move(import)); | |
} |
for (auto& module : modules) | ||
{ | ||
if (rib_t* rib = dynamic_cast<rib_t*>(module)) | ||
{ | ||
rib->bird_import_get(); | ||
rib->moduleStart(); | ||
} | ||
} | ||
} |
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.
Is every module is also a rib module? I don't quite understand.
Also, dynamic_cast
will inevitably lead to some errors, if, for example, we decide to change class hierarchy.
Can we use other things here? Like maybe we can utilize one or two virtual functions?
auto route = controlPlane->getRoute(); | ||
for (auto& [vrf, response] : route) | ||
{ | ||
(void)vrf; |
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.
(void)vrf; | |
YANET_GCC_BUG_UNUSED(vrf); |
No description provided.