Skip to content

Statman and ICMP#1222

Merged
alfreb merged 50 commits intoincludeos:devfrom
AnnikaH:dev
Mar 21, 2017
Merged

Statman and ICMP#1222
alfreb merged 50 commits intoincludeos:devfrom
AnnikaH:dev

Conversation

@AnnikaH
Copy link
Copy Markdown
Member

@AnnikaH AnnikaH commented Mar 6, 2017

No description provided.

AnnikaH added 25 commits March 3, 2017 16:27
…eation of Stat throws Exception, empty name-input to get-method now throws immediate Exception
…(RFC 1122). Removed deprecated ICMP messages (Source Quench and Information - RFC 6918 and 6633)
…nstead of previously updated statman_.end() iterator
…ed message, port and protocol unreachable validated in test.py
… span. Get(name) method using last_used-iterator instead of end
…moving them on timeout), updating integration test correspondingly and setting timeout to 40 (reply) and 50 (test)
@AnnikaH
Copy link
Copy Markdown
Member Author

AnnikaH commented Mar 10, 2017

Jenkins test please

@AnnikaH
Copy link
Copy Markdown
Member Author

AnnikaH commented Mar 20, 2017

Jenkins test please

Copy link
Copy Markdown
Contributor

@AndreasAakesson AndreasAakesson left a comment

Choose a reason for hiding this comment

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

Looking good 👍 Just some minor stuff/improvements

Comment thread api/net/inet4.hpp Outdated
* Error report in accordance with RFC 1122
* An ICMP error message has been received - forward to transport layer (UDP or TCP)
*/
void error_report(Error_type type, Error_code code, Span icmp_payload) override {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be put in .cpp?

Comment thread api/net/ip4/icmp4.hpp
ICMP_callback(ICMPv4& icmp, Tuple t, icmp_func cb)
: tuple{t}, callback{cb}
{
timer_id = Timers::oneshot(std::chrono::seconds(40), [&icmp, t](Timers::id_t) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe have the timeout duration configurable (like passed into the origin call that creates a ICMP callback)?
Or at least define the timeout duration static outside the callback struct, and have it globally configurable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would make sense as part of ping(...)

Comment thread api/net/ip4/icmp4.hpp
auto it = ping_callbacks_.find(std::make_pair(ping_response.id(), ping_response.sequence()));

if (it != ping_callbacks_.end()) {
it->second.callback(ICMP_packet{ping_response.id(), ping_response.sequence(), ping_response.ip().ip_src(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To make it cleaner you could add a constructor to struct ICMP_packet that takes a const icmp4::Packet& and hide all these lines there (with a shorter name).

} // < namespace code

static std::string __attribute__((unused)) get_type_string(Type type) {
return [&type] () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This lambda doesn't fill any purpose here.

}

static std::string __attribute__((unused)) get_code_string(Type type, uint8_t code) {
return [&type, &code] () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above.
Maybe have helper functions for the nested switch cases? It also could make sense to move this to a cpp file.

Comment thread src/net/ip4/icmp4.cpp
}

void ICMPv4::destination_unreachable(Packet_ptr pckt, icmp4::code::Dest_unreachable code) {
if ((size_t)pckt->size() < sizeof(IP4::header) + icmp4::Packet::header_size()) // Drop if not a full header
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could make it more DRY by creating a inline helper function for this, and also use UNLIKELY:
if(UNLIKELY(not full_header(*pckt))) return;
(Could this be done before any of the functions are called?)

Comment thread src/net/ip4/icmp4.cpp Outdated

void ICMPv4::forward_to_transport_layer(icmp4::Packet& req) {
// inet forwards to transport layer (UDP or TCP)
inet_.error_report(req.type(), req.code(), req.payload());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest passing the underlying packet as IP packet pointer to retain storage of the underlying buffer. e.g.

auto packet_ptr = req.release(); 
packet_ptr -> set_layer_begin(req.payload());  // hide information below payload, interpret the rest as Packet_IP4
inet_.error_report(type, code, std::move(packet_ptr));

Comment thread src/net/ip4/ip4.cpp
{
stack_.icmp().destination_unreachable(std::move(packet), icmp4::code::Dest_unreachable::PROTOCOL);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

TRAILER_NEGO = 0x0010, // RFC 893 Trailer negotiation
TRAILER_FIRST = 0x0110, // RFC 893, 1122 Trailer encapsulation
TRAILER_LAST = 0x0f10
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Comment thread api/net/ip4/icmp4.hpp
operator bool() const noexcept
{ return type_ != icmp4::Type::NO_REPLY; }

std::string to_string();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Const?

Comment thread api/net/ip4/icmp4.hpp
ICMP_callback(ICMPv4& icmp, Tuple t, icmp_func cb)
: tuple{t}, callback{cb}
{
timer_id = Timers::oneshot(std::chrono::seconds(40), [&icmp, t](Timers::id_t) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would make sense as part of ping(...)

Comment thread src/net/dhcp/dhcpd.cpp
netmask_{stack_.netmask()},
router_{stack_.gateway()},
dns_{stack_.gateway()},
dns_{stack_.dns()},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there's a getter for both the DNS client and the DNS address, this is ambiguous

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For IP I think we used ip_obj and ip_addr

(t >= net::ntohs(static_cast<uint16_t>(Ethertype::TRAILER_FIRST)) and
t <= net::ntohs(static_cast<uint16_t>(Ethertype::TRAILER_LAST))))) {
debug("<Ethernet OUT> Ethernet type Trailer is not supported. Packet is not transmitted\n");
return;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 (we might want to add TX_dropped as either delegate or just stat - but we can do that later)

Comment thread src/net/ip4/udp.cpp
}
}

void UDP::error_report(Error_type type, Error_code code,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Signature will change to e.g. UDP::error_report(ICMP_Error) or something, as discussed

Comment thread src/net/tcp/tcp.cpp
return ss.str();
}

void TCP::error_report(Error_type type, Error_code code,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

New signature as discussed for UDP

});

// Also possible without callback:
// inet.icmp().ping(IP4::addr{193,90,147,109}); // google.com
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would also be nice to do DNS resolution - so you could ping("google.com", callback). For later.

@alfreb alfreb merged commit 6180dc9 into includeos:dev Mar 21, 2017
fwsGonzo added a commit that referenced this pull request Apr 6, 2017
Updates based on feedback on #1222 and more
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.

3 participants