Skip to content
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

Open
wants to merge 3 commits into
base: bird-import-proto
Choose a base branch
from

Conversation

Markuu-s
Copy link

No description provided.

Comment on lines 147 to 160
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);
}

Copy link
Collaborator

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

Copy link
Author

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.

Comment on lines +114 to +115
inline static const std::string socketStr = "socket";
inline static const std::string vrfStr = "vrf";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline static const std::string socketStr = "socket";
inline static const std::string vrfStr = "vrf";
static constexpr auto socketStr = "socket";
static constexpr auto vrfStr = "vrf";

Comment on lines +108 to +119
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;
};
Copy link
Collaborator

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

Suggested change
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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we need

Suggested change
void config_parser_t::loadConfig_route_bird(controlplane::base_t& baseNext,
void config_parser_t::loadConfig_route_bird([[maybe_unused]] controlplane::base_t& baseNext,

Comment on lines +219 to +223
birdsImport.push_back(import);
YANET_LOG_INFO("loadConfig_route_bird: socket(%s), vrf(%s)\n",
import.socket.data(),
import.vrf.data());
}
Copy link
Collaborator

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

Suggested change
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));
}

Comment on lines +956 to 964
for (auto& module : modules)
{
if (rib_t* rib = dynamic_cast<rib_t*>(module))
{
rib->bird_import_get();
rib->moduleStart();
}
}
}
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(void)vrf;
YANET_GCC_BUG_UNUSED(vrf);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants