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

Support ICMP Time Exceeded Message #issues57 #274

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

darkgrey1554
Copy link
Collaborator

No description provided.

@darkgrey1554 darkgrey1554 linked an issue Feb 7, 2025 that may be closed by this pull request
dataplane/worker.cpp Outdated Show resolved Hide resolved
dataplane/worker.cpp Outdated Show resolved Hide resolved
dataplane/worker.cpp Outdated Show resolved Hide resolved
dataplane/icmp.cpp Outdated Show resolved Hide resolved
@darkgrey1554 darkgrey1554 force-pushed the icmp_ttl_exceeded_answer branch 5 times, most recently from e3986bf to 572877c Compare February 10, 2025 11:23
@ol-imorozko
Copy link
Collaborator

ol-imorozko commented Feb 10, 2025

Add support ICMP Time Exceeded Message is grammatically incorrect. I suggest to just use Support ICMP Time Exceeded Message.
Also it would be really helpful if you add commit description about why we need this. You can just copy issue description and have smth like:

Support ICMP Time Exceeded Message

YANET doesn't support ICMP response, when receiving packet with TTL = 1.
By RFC792 YANET should send ICMP Time Exceeded Message,
when packet cannot be forwarded or balanced.

Comment on lines +427 to +430
else if (type == common::idp::updateGlobalBase::requestType::update_host_config)
{
result = update_host_config(std::get<common::idp::updateGlobalBase::update_host_config::request>(data));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This commit is about supporting some kind of ICMP response message.
Could you clarify these changes please?
I'm not following why we have this "update_host_config" sub-theme going on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The icmp response should contain the IP of the current local device. It was decided that the IP of the local device will be obtained from the configuration.
A new section was introduced in the config (), which is passed to Dataplane

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then it should be done in a separate commit, otherwise it's hard to grasp the intentions, especially from the commit title.
I suggest to split the first commit into two -- one that will add that update mechanism with commit description equal to what you told me here, and the other that will actually do ICMP-related things

common/type.h Outdated Show resolved Hide resolved
dataplane/type.h Outdated Show resolved Hide resolved
@ol-imorozko
Copy link
Collaborator

Also we shouldn't have commits like "fix comments" etc.
If you fix something addressed to a certain commit, you should just change that commit accordingly and force-push branch.

@darkgrey1554 darkgrey1554 changed the title Add support ICMP Time Exceeded Message #issues57 Support ICMP Time Exceeded Message #issues57 Feb 11, 2025
@darkgrey1554 darkgrey1554 force-pushed the icmp_ttl_exceeded_answer branch from 572877c to 8c028c0 Compare February 11, 2025 08:06
@darkgrey1554 darkgrey1554 force-pushed the icmp_ttl_exceeded_answer branch 5 times, most recently from ee2c91c to fb65b5f Compare February 11, 2025 08:54
Comment on lines +199 to +200
uint8_t zero_buf[16]{};
return !memcmp(bytes, zero_buf, std::size(bytes));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Still, we don't need to create temporary object/array for comparison. std::all_of is perfectly fine:

[[nodiscard]] bool is_default() const
{
    return std::all_of(address.begin(), address.end(), [](uint8_t byte) {
        return byte == 0;
    });
}

Comment on lines +8 to +11
namespace
{
const uint8_t TTL = 128;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need an anonymous namespace since we're using that only in this cpp file.
I suggest just constexpr uint8_t TTL = 128;

Comment on lines +22 to +27
uint32_t create_icmp_package_time_exceeded(rte_mbuf* mbuf_target, const CreateTimeExceededPackagePayload& payload)
{
if (mbuf_target == nullptr || payload.mbuf_source == nullptr)
{
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

return false when the function returns uint32_t?

Comment on lines +90 to +93
uint8_t addr[16];
rte_memcpy(addr, ip_header->dst_addr, 16);
rte_memcpy(ip_header->dst_addr, ip_header->src_addr, 16);
rte_memcpy(ip_header->src_addr, addr, 16);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we can use RTE_SWAP for this

// copy network header and next 64bits of source package (RFC 792)
rte_ipv4_hdr* ip_header = rte_pktmbuf_mtod_offset(mbuf_target, rte_ipv4_hdr*, metadata->network_headerOffset);
rte_memcpy(rte_pktmbuf_mtod_offset(mbuf_target, char*, metadata->transport_headerOffset + sizeof(rte_icmp_hdr)),
rte_pktmbuf_mtod_offset(payload.mbuf_source, char*, YADECAP_METADATA(payload.mbuf_source)->network_headerOffset),
Copy link
Collaborator

Choose a reason for hiding this comment

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

why YADECAP_METADATA(payload.mbuf_source) instead of just metadata?

rte_ipv6_hdr* ip_header = rte_pktmbuf_mtod_offset(mbuf_target, rte_ipv6_hdr*, metadata->network_headerOffset);

rte_memcpy(rte_pktmbuf_mtod_offset(mbuf_target, char*, metadata->transport_headerOffset + sizeof(rte_icmp_hdr)),
rte_pktmbuf_mtod_offset(payload.mbuf_source, char*, YADECAP_METADATA(payload.mbuf_source)->network_headerOffset),
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@ol-imorozko
Copy link
Collaborator

Overall LGTM apart from really tiny issues

@ol-imorozko
Copy link
Collaborator

Add support ICMP Time Exceeded Message is grammatically incorrect. I suggest to just use Support ICMP Time Exceeded Message. Also it would be really helpful if you add commit description about why we need this. You can just copy issue description and have smth like:

Support ICMP Time Exceeded Message

YANET doesn't support ICMP response, when receiving packet with TTL = 1.
By RFC792 YANET should send ICMP Time Exceeded Message,
when packet cannot be forwarded or balanced.

Also do this, please. Not just in pr description, but in an actual commit message too

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.

ICMP time exceeded
3 participants