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

net/gnrc/sock: Implement sock_aux_local #14704

Merged
merged 3 commits into from Dec 4, 2020
Merged

Conversation

maribu
Copy link
Member

@maribu maribu commented Aug 5, 2020

Contribution description

This PR adds the implementation of the sock_aux_local for GNRC, that provides access to the local address via the extended SOCK API of #14703.

Testing procedure

  • make -C tests/gnrc_sock_udp flash test
  • make -C tests/gnrc_sock_ip flash test

Issues/PRs references

Depends on #14703

Same as #14705, but for GNRC

@maribu maribu added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first labels Aug 5, 2020
@maribu maribu requested review from miri64 and jia200x August 5, 2020 07:35
sys/net/gnrc/sock/ip/gnrc_sock_ip.c Outdated Show resolved Hide resolved
sys/net/gnrc/sock/ip/gnrc_sock_ip.c Outdated Show resolved Hide resolved
@maribu
Copy link
Member Author

maribu commented Nov 4, 2020

I changed the implementation a bit (I think it is now more elegant) and used #if IS_USED() over #ifdef in all places.

@maribu
Copy link
Member Author

maribu commented Dec 3, 2020

I rebased on master and solved merged conflict (all regarding the documentation fixes in the API, not relevant to this PR).

I did however not squash

@maribu
Copy link
Member Author

maribu commented Dec 3, 2020

I messed up the rebase. This time it should have worked.

sys/net/gnrc/sock/gnrc_sock.c Outdated Show resolved Hide resolved
tests/gnrc_sock_ip/Makefile Outdated Show resolved Hide resolved
tests/gnrc_sock_udp/Makefile Outdated Show resolved Hide resolved
@miri64 miri64 removed the State: waiting for other PR State: The PR requires another PR to be merged first label Dec 3, 2020
@miri64 miri64 added CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Dec 3, 2020
@maribu
Copy link
Member Author

maribu commented Dec 4, 2020

OK, only the expected failures: The ds3231 test requires hardware to be plugged in to work (and was blacklisted on the CI in #15554). And the issue with libhydrogen on clang is also preexisting.

sys/net/gnrc/sock/gnrc_sock.c Outdated Show resolved Hide resolved
@miri64 miri64 removed the CI: run tests If set, CI server will run tests on hardware for the labeled PR label Dec 4, 2020
Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

One last thing:

sys/net/gnrc/sock/ip/gnrc_sock_ip.c Outdated Show resolved Hide resolved
sys/net/gnrc/sock/udp/gnrc_sock_udp.c Outdated Show resolved Hide resolved
@miri64
Copy link
Member

miri64 commented Dec 4, 2020

Please squash. I will give the tests a final local run.

@miri64
Copy link
Member

miri64 commented Dec 4, 2020

I ran the tests with the following script on native:

TEST_RUNS=0
for test in tests/gnrc_sock_{ip,udp}; do
    RIOT_CI_BUILD=1 AUX_LOCAL=1 make -C ${test} --no-print-directory -j clean flash test || break
    RIOT_CI_BUILD=1 AUX_LOCAL=0 make -C ${test} --no-print-directory -j clean flash test || break
    TEST_RUNS=$((TEST_RUNS+1))
done
[ ${TEST_RUNS} -eq 2 ] && echo "success" || echo "fail"
Success was printed in the end and the build sizes differed:
Building application "tests_gnrc_sock_ip" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_ip/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
   text	   data	    bss	    dec	    hex	filename
 148536	    692	  59532	 208760	  32f78	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_ip/bin/native/tests_gnrc_sock_ip.elf
true 
r
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_ip/bin/native/tests_gnrc_sock_ip.elf /dev/ttyACM0 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

Help: Press s to start test, r to print it is ready
READY
s
START
main(): This is RIOT! (Version: buildtest)
Calling test_sock_ip_create__EAFNOSUPPORT()
Calling test_sock_ip_create__EINVAL_addr()
Calling test_sock_ip_create__EINVAL_netif()
Calling test_sock_ip_create__no_endpoints()
Calling test_sock_ip_create__only_local()
Calling test_sock_ip_create__only_local_reuse_ep()
Calling test_sock_ip_create__only_remote()
Calling test_sock_ip_create__full()
Calling test_sock_ip_recv__EADDRNOTAVAIL()
Calling test_sock_ip_recv__EAGAIN()
Calling test_sock_ip_recv__ENOBUFS()
Calling test_sock_ip_recv__EPROTO()
Calling test_sock_ip_recv__ETIMEDOUT()
 * Calling sock_ip_recv()
 * (timed out with timeout 1000000)
Calling test_sock_ip_recv__socketed()
Calling test_sock_ip_recv__socketed_with_remote()
Calling test_sock_ip_recv__unsocketed()
Calling test_sock_ip_recv__unsocketed_with_remote()
Calling test_sock_ip_recv__with_timeout()
Calling test_sock_ip_recv__non_blocking()
Calling test_sock_ip_recv__aux()
Calling test_sock_ip_recv_buf__success()
Calling test_sock_ip_send__EAFNOSUPPORT_INET()
Calling test_sock_ip_send__EAFNOSUPPORT_UNSPEC()
Calling test_sock_ip_send__EINVAL_addr()
Calling test_sock_ip_send__EINVAL_netif()
Calling test_sock_ip_send__ENOTCONN()
Calling test_sock_ip_send__socketed_no_local_no_netif()
Calling test_sock_ip_send__socketed_no_netif()
Calling test_sock_ip_send__socketed_no_local()
Calling test_sock_ip_send__socketed()
Calling test_sock_ip_send__socketed_other_remote()
Calling test_sock_ip_send__unsocketed_no_local_no_netif()
Calling test_sock_ip_send__unsocketed_no_netif()
Calling test_sock_ip_send__unsocketed_no_local()
Calling test_sock_ip_send__unsocketed()
Calling test_sock_ip_send__no_sock_no_netif()
Calling test_sock_ip_send__no_sock()
ALL TESTS SUCCESSFUL

Building application "tests_gnrc_sock_ip" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_ip/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
   text	   data	    bss	    dec	    hex	filename
 148328	    692	  59532	 208552	  32ea8	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_ip/bin/native/tests_gnrc_sock_ip.elf
true 
r
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_ip/bin/native/tests_gnrc_sock_ip.elf /dev/ttyACM0 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

Help: Press s to start test, r to print it is ready
READY
s
START
main(): This is RIOT! (Version: buildtest)
Calling test_sock_ip_create__EAFNOSUPPORT()
Calling test_sock_ip_create__EINVAL_addr()
Calling test_sock_ip_create__EINVAL_netif()
Calling test_sock_ip_create__no_endpoints()
Calling test_sock_ip_create__only_local()
Calling test_sock_ip_create__only_local_reuse_ep()
Calling test_sock_ip_create__only_remote()
Calling test_sock_ip_create__full()
Calling test_sock_ip_recv__EADDRNOTAVAIL()
Calling test_sock_ip_recv__EAGAIN()
Calling test_sock_ip_recv__ENOBUFS()
Calling test_sock_ip_recv__EPROTO()
Calling test_sock_ip_recv__ETIMEDOUT()
 * Calling sock_ip_recv()
 * (timed out with timeout 1000000)
Calling test_sock_ip_recv__socketed()
Calling test_sock_ip_recv__socketed_with_remote()
Calling test_sock_ip_recv__unsocketed()
Calling test_sock_ip_recv__unsocketed_with_remote()
Calling test_sock_ip_recv__with_timeout()
Calling test_sock_ip_recv__non_blocking()
Calling test_sock_ip_recv__aux()
Calling test_sock_ip_recv_buf__success()
Calling test_sock_ip_send__EAFNOSUPPORT_INET()
Calling test_sock_ip_send__EAFNOSUPPORT_UNSPEC()
Calling test_sock_ip_send__EINVAL_addr()
Calling test_sock_ip_send__EINVAL_netif()
Calling test_sock_ip_send__ENOTCONN()
Calling test_sock_ip_send__socketed_no_local_no_netif()
Calling test_sock_ip_send__socketed_no_netif()
Calling test_sock_ip_send__socketed_no_local()
Calling test_sock_ip_send__socketed()
Calling test_sock_ip_send__socketed_other_remote()
Calling test_sock_ip_send__unsocketed_no_local_no_netif()
Calling test_sock_ip_send__unsocketed_no_netif()
Calling test_sock_ip_send__unsocketed_no_local()
Calling test_sock_ip_send__unsocketed()
Calling test_sock_ip_send__no_sock_no_netif()
Calling test_sock_ip_send__no_sock()
ALL TESTS SUCCESSFUL

Building application "tests_gnrc_sock_udp" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_udp/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
   text	   data	    bss	    dec	    hex	filename
 155796	    692	  67756	 224244	  36bf4	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_udp/bin/native/tests_gnrc_sock_udp.elf
true 
r
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_udp/bin/native/tests_gnrc_sock_udp.elf /dev/ttyACM0 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

Help: Press s to start test, r to print it is ready
READY
s
START
main(): This is RIOT! (Version: buildtest)
Calling test_sock_udp_create__EADDRINUSE()
Calling test_sock_udp_create__EAFNOSUPPORT()
Calling test_sock_udp_create__EINVAL_addr()
Calling test_sock_udp_create__EINVAL_netif()
Calling test_sock_udp_create__no_endpoints()
Calling test_sock_udp_create__only_local()
Calling test_sock_udp_create__only_local_port0()
Calling test_sock_udp_create__only_local_reuse_ep()
Calling test_sock_udp_create__only_remote()
Calling test_sock_udp_create__full()
Calling test_sock_udp_recv__EADDRNOTAVAIL()
Calling test_sock_udp_recv__EAGAIN()
Calling test_sock_udp_recv__ENOBUFS()
Calling test_sock_udp_recv__EPROTO()
Calling test_sock_udp_recv__ETIMEDOUT()
 * Calling sock_udp_recv()
 * (timed out with timeout 1000000)
Calling test_sock_udp_recv__socketed()
Calling test_sock_udp_recv__socketed_with_remote()
Calling test_sock_udp_recv__socketed_with_port0()
Calling test_sock_udp_recv__unsocketed()
Calling test_sock_udp_recv__unsocketed_with_remote()
Calling test_sock_udp_recv__with_timeout()
Calling test_sock_udp_recv__non_blocking()
Calling test_sock_udp_recv__aux()
Calling test_sock_udp_recv_buf__success()
Calling test_sock_udp_send__EAFNOSUPPORT()
Calling test_sock_udp_send__EINVAL_addr()
Calling test_sock_udp_send__EINVAL_netif()
Calling test_sock_udp_send__EINVAL_port()
Calling test_sock_udp_send__ENOTCONN()
Calling test_sock_udp_send__socketed_no_local_no_netif()
Calling test_sock_udp_send__socketed_no_netif()
Calling test_sock_udp_send__socketed_no_local()
Calling test_sock_udp_send__socketed()
Calling test_sock_udp_send__socketed_other_remote()
Calling test_sock_udp_send__unsocketed_no_local_no_netif()
Calling test_sock_udp_send__unsocketed_no_netif()
Calling test_sock_udp_send__unsocketed_no_local()
Calling test_sock_udp_send__unsocketed()
Calling test_sock_udp_send__no_sock_no_netif()
Calling test_sock_udp_send__no_sock()
ALL TESTS SUCCESSFUL

Building application "tests_gnrc_sock_udp" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_udp/bin/native/cpu/tramp.o: warning: relocation against `_native_saved_eip' in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
   text	   data	    bss	    dec	    hex	filename
 155556	    692	  67756	 224004	  36b04	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_udp/bin/native/tests_gnrc_sock_udp.elf
true 
r
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/gnrc_sock_udp/bin/native/tests_gnrc_sock_udp.elf /dev/ttyACM0 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

Help: Press s to start test, r to print it is ready
READY
s
START
main(): This is RIOT! (Version: buildtest)
Calling test_sock_udp_create__EADDRINUSE()
Calling test_sock_udp_create__EAFNOSUPPORT()
Calling test_sock_udp_create__EINVAL_addr()
Calling test_sock_udp_create__EINVAL_netif()
Calling test_sock_udp_create__no_endpoints()
Calling test_sock_udp_create__only_local()
Calling test_sock_udp_create__only_local_port0()
Calling test_sock_udp_create__only_local_reuse_ep()
Calling test_sock_udp_create__only_remote()
Calling test_sock_udp_create__full()
Calling test_sock_udp_recv__EADDRNOTAVAIL()
Calling test_sock_udp_recv__EAGAIN()
Calling test_sock_udp_recv__ENOBUFS()
Calling test_sock_udp_recv__EPROTO()
Calling test_sock_udp_recv__ETIMEDOUT()
 * Calling sock_udp_recv()
 * (timed out with timeout 1000000)
Calling test_sock_udp_recv__socketed()
Calling test_sock_udp_recv__socketed_with_remote()
Calling test_sock_udp_recv__socketed_with_port0()
Calling test_sock_udp_recv__unsocketed()
Calling test_sock_udp_recv__unsocketed_with_remote()
Calling test_sock_udp_recv__with_timeout()
Calling test_sock_udp_recv__non_blocking()
Calling test_sock_udp_recv__aux()
Calling test_sock_udp_recv_buf__success()
Calling test_sock_udp_send__EAFNOSUPPORT()
Calling test_sock_udp_send__EINVAL_addr()
Calling test_sock_udp_send__EINVAL_netif()
Calling test_sock_udp_send__EINVAL_port()
Calling test_sock_udp_send__ENOTCONN()
Calling test_sock_udp_send__socketed_no_local_no_netif()
Calling test_sock_udp_send__socketed_no_netif()
Calling test_sock_udp_send__socketed_no_local()
Calling test_sock_udp_send__socketed()
Calling test_sock_udp_send__socketed_other_remote()
Calling test_sock_udp_send__unsocketed_no_local_no_netif()
Calling test_sock_udp_send__unsocketed_no_netif()
Calling test_sock_udp_send__unsocketed_no_local()
Calling test_sock_udp_send__unsocketed()
Calling test_sock_udp_send__no_sock_no_netif()
Calling test_sock_udp_send__no_sock()
ALL TESTS SUCCESSFUL

success

Non-native should be covered by the tests on Murdock and we already discussed, that their failures where unrelated.

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

Static tests failed because of a missing doc.

Comment on lines 68 to 82
#if !IS_USED(MODULE_SOCK_AUX_LOCAL)
uint8_t this_struct_is_not_empty;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Murdock wants this to be documented. Maybe just hide it from it?

Suggested change
#if !IS_USED(MODULE_SOCK_AUX_LOCAL)
uint8_t this_struct_is_not_empty;
#endif
#if !IS_USED(MODULE_SOCK_AUX_LOCAL) && !IS_ACTIVE(DOXYGEN)
uint8_t this_struct_is_not_empty;
#endif

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if Doxygen is so smart that it can parse IS_ACTIVE() - it would need a C99 compliant preprocessor for this.

Maybe it is indeed the easiest to just document it.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if Doxygen is so smart that it can parse IS_ACTIVE() - it would need a C99 compliant preprocessor for this.

I think in that case it is just enough to check if it is not defined

Suggested change
#if !IS_USED(MODULE_SOCK_AUX_LOCAL)
uint8_t this_struct_is_not_empty;
#endif
#if !IS_USED(MODULE_SOCK_AUX_LOCAL) && !defined(DOXYGEN)
uint8_t this_struct_is_not_empty;
#endif

Provide address the IP packet / UDP datagram was received on in the auxiliary
data, if module sock_aux_local is used.
@maribu
Copy link
Member Author

maribu commented Dec 4, 2020

I extended the doc of the struct and squashed right in. See here for the diff.

@miri64
Copy link
Member

miri64 commented Dec 4, 2020

I think the revert commit can also squashed into the commit it reverts ;-).

@maribu
Copy link
Member Author

maribu commented Dec 4, 2020

I think the revert commit can also squashed into the commit it reverts ;-).

Good catch. Maybe I should stop blindly trusting --autosquash.

@miri64
Copy link
Member

miri64 commented Dec 4, 2020

I think the revert commit can also squashed into the commit it reverts ;-).

Good catch. Maybe I should stop blindly trusting --autosquash.

It's awesome, but I never understood why Revert commits are not included in that :-/

Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

ACK. Code is sane and I provided tests as well as ran the tests on Murdock.

@miri64 miri64 merged commit ba89d86 into RIOT-OS:master Dec 4, 2020
@maribu
Copy link
Member Author

maribu commented Dec 4, 2020

Thanks :-)

@maribu maribu deleted the sock-aux-gnrc branch December 4, 2020 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants