tests: add a simple proof of concept test for gnrc_sock + gnrc_neterr#12678
tests: add a simple proof of concept test for gnrc_sock + gnrc_neterr#12678miri64 merged 1 commit intoRIOT-OS:masterfrom
Conversation
46565c4 to
1f3ebcc
Compare
|
When I add |
Yes, because the packet is actually send in that case (there is no ND for link-local addresses |
|
(you can easily confirm this with a sniffer) |
|
If you change to a global address it should read (on |
|
(only of course, if you don't configure a route to that global address beforehand :P) |
|
Hm that's what I tried too: --- a/tests/gnrc_sock_neterr/main.c 2019-11-09 21:50:10.033931663 +0100
+++ b/tests/gnrc_sock_neterr/main.c 2019-11-09 21:56:06.783147677 +0100
@@ -22,7 +22,7 @@
#include "net/sock/udp.h"
#define TEST_PORT (38664U)
-#define TEST_REMOTE { 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+#define TEST_REMOTE { 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }
#define TEST_PAYLOAD { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }
@@ -44,6 +44,10 @@
memcpy(remote.addr.ipv6, _test_remote, sizeof(_test_remote));
remote.port = TEST_PORT - 1;
+ char addr_str[IPV6_ADDR_MAX_STR_LEN];
+ ipv6_addr_to_str(addr_str,(ipv6_addr_t*) &remote.addr.ipv6, sizeof(addr_str));
+ printf("sending %d bytes to %s\n", sizeof(_test_payload), addr_str);
+
/* remote is not reachable, so it should return an error */
res = sock_udp_send(&_udp_sock, _test_payload, sizeof(_test_payload), &remote);
if (res == -EHOSTUNREACH) {No routes or border routers anywhere to be seen here. |
|
Again with changed module behavior? |
|
It may be, that you are just triggering a condition, where it reaches a normal |
|
So the expected behavior is to get Then this test would indeed have uncovered a bug - even more reason to have it! |
Yepp, but fixing this bug is the task of another PR. I will amend the test however for the second check. |
|
The bug is caused by a number of factors playing together btw:
My proposed fix is
|
Mh... no, that doesn't fix the problem, as |
|
Yepp, that fixes it :-). |
As analyzed in RIOT-OS#12678 there are cases where different reports can be generated for the different snips of the packet send via the `sock`. To catch all errors generated by the stack, the sock has to subscribe for all snips of the packet sent. If any of the snips reports an error distinct from `GNRC_NETERR_SUCCESS` or the previous one, we report that status instead of just the first we receive. This way we are ensured to have the first error reported by the stack for the given packet.
As analyzed in RIOT-OS#12678 there are cases where different reports can be generated for the different snips of the packet send via the `sock`. To catch all errors generated by the stack, the sock has to subscribe for all snips of the packet sent. If any of the snips reports an error distinct from `GNRC_NETERR_SUCCESS` or the previous one, we report that status instead of just the first we receive. This way we are ensured to have the first error reported by the stack for the given packet.
As analyzed in RIOT-OS#12678 there are cases where different reports can be generated for the different snips of the packet send via the `sock`. To catch all errors generated by the stack, the sock has to subscribe for all snips of the packet sent. If any of the snips reports an error distinct from `GNRC_NETERR_SUCCESS` or the previous one, we report that status instead of just the first we receive. This way we are ensured to have the first error reported by the stack for the given packet.
As analyzed in RIOT-OS#12678 there are cases where different reports can be generated for the different snips of the packet send via the `sock`. To catch all errors generated by the stack, the sock has to subscribe for all snips of the packet sent. If any of the snips reports an error distinct from `GNRC_NETERR_SUCCESS` or the previous one, we report that status instead of just the first we receive. This way we are ensured to have the first error reported by the stack for the given packet.
|
See #12682 |
|
|
||
| memcpy(remote.addr.ipv6, _test_link_local_remote, | ||
| sizeof(_test_link_local_remote)); | ||
| _test_udp_send(&remote, "EHOSTUNREACH", EHOSTUNREACH); |
There was a problem hiding this comment.
Maybe add something like
| _test_udp_send(&remote, "EHOSTUNREACH", EHOSTUNREACH); | |
| #ifdef MODULE_GNRC_SIXLOWPAN | |
| _test_udp_send(&remote, "OK", -sizeof(_test_payload)); | |
| #else | |
| _test_udp_send(&remote, "EHOSTUNREACH", EHOSTUNREACH); | |
| #endif |
There was a problem hiding this comment.
I don't expect anyone to test this this way in the future.
There was a problem hiding this comment.
I view the code in examples/ and tests/ as extended documentation. I suppose I'm not the only one who does that.
So when I want to understand how to use the gnrc_neterr module, I would look at tests/gnrc_sock_neterr and conclude that sending a datagram to a non-existing link-local address would always generate an error - after all, there is a testcase to ensure it is so.
It wouldn't be an unreasonable thing to assume if ACK_REQ is enabled.
So at least a comment would be appropriate that with 6LoWPAN the behaviour is different, referencing RFC 6775.
There was a problem hiding this comment.
So when I want to understand how to use the
gnrc_neterrmodule, I would look attests/gnrc_sock_neterrand conclude that sending a datagram to a non-existing link-local address would always generate an error - after all, there is a testcase to ensure it is so.
Again, if you change the test parameters (adding a device that acts differently under IPv6) you may get different results.
It wouldn't be an unreasonable thing to assume if
ACK_REQis enabled.
I don't get this comment... what has an option in the MAC layer to do with error handling in the application layer? The sock API is not there to ensure the packet reached the next host. This is also not how sockets in POSIX work. If you want reliability there you have to configure the socket as such (e.g. by using TCP).
I will however adapt the test. add a comment.
There was a problem hiding this comment.
I will however
adapt the test.add a comment.
The #ifdef MODULE_GNRC_SIXLOWPAN is the wrong macro. It should rather check if the netif the packet is sent over is a 6LN. This however is getting too complicated for what is supposed to be a simple test, just for the case that somebody gets the idea of changing test parameters around (btw if GNRC_NETIF_NUMOF>1 the behavior for link-local addresses changes yet again!) and expecting the same results.
There was a problem hiding this comment.
I don't get this comment... what has an option in the MAC layer to do with error handling in the application layer? The sock API is not there to ensure the packet reached the next host. This is also not how sockets in POSIX work.
I'm just saying that someone not familiar with the implementation might assume the lower layer only reports success then if a link-layer ACK was received.
But the comment should help clear that up.
As analyzed in RIOT-OS#12678 there are cases where different reports can be generated for the different snips of the packet send via the `sock`. To catch all errors generated by the stack, the sock has to subscribe for all snips of the packet sent. If any of the snips reports an error distinct from `GNRC_NETERR_SUCCESS` or the previous one, we report that status instead of just the first we receive. This way we are ensured to have the first error reported by the stack for the given packet.
benpicco
left a comment
There was a problem hiding this comment.
Test demonstrates the use of gnrc_neterr and helped uncover a bug in it, so even more reason to have it.
Please squash.
2f367f9 to
6b50db1
Compare
|
Squashed. |
As analyzed in RIOT-OS#12678 there are cases where different reports can be generated for the different snips of the packet send via the `sock`. To catch all errors generated by the stack, the sock has to subscribe for all snips of the packet sent. If any of the snips reports an error distinct from `GNRC_NETERR_SUCCESS` or the previous one, we report that status instead of just the first we receive. This way we are ensured to have the first error reported by the stack for the given packet.
Contribution description
This introduces a simple proof-of-concept test that GNRC's
sockimplementation still works withgnrc_neterrcompiled in and that errors reported by the stack are handed to thesockobject.Testing procedure
Confirm that
EHOSTUNREACHis not reported bygnrc_sockitself:Run the test on a board of your choice:
Issues/PRs references
Issue popped up in #12625, but overall unrelated.