Skip to content

Conversation

maribu
Copy link
Member

@maribu maribu commented Jul 31, 2020

Contribution description

  • Changed some code to use IS_ACTIVE() over #if/#ifdef
  • Fixed family in sock_udp_get_local()

Testing procedure

  • No regressions in lwip
  • LWIP_IPV4=1 LWIP_IPV6=1 make -C tests/lwip_sock_udp flash test should no pass

Issues/PRs references

Split out of #14622

The `IS_USED()` macro doesn't work if macros are defined to `(1)` instead of `1`
@maribu maribu added Area: network Area: Networking Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer labels Jul 31, 2020
@maribu maribu requested a review from miri64 July 31, 2020 08:54
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 31, 2020
@miri64
Copy link
Member

miri64 commented Jul 31, 2020

More philosophic usage question: LWIP_IPV4 and LWIP_IPV6 technically are boolean configuration macros of lwIP. Shouldn't we use IS_ACTIVE() then, rather than the IS_USED() typically used for MODULE_ prefixed macros? Maybe @leandrolanzieri can give some clarity.

@leandrolanzieri
Copy link
Contributor

More philosophic usage question: LWIP_IPV4 and LWIP_IPV6 technically are boolean configuration macros of lwIP. Shouldn't we use IS_ACTIVE() then, rather than the IS_USED() typically used for MODULE_ prefixed macros? Maybe @leandrolanzieri can give some clarity.

I'd say yes, if we are checking for the configuration macros directly we should stick to IS_ACTIVE according to the documentation.

But why do we have two checks? There are places in contrib code where we check for IS_USED(MODULE_LWIP_IPV4) and then other places where we check for #ifdef LWIP_IPV4. Are they equivalent in our build system? Would it make sense to unify?

@miri64
Copy link
Member

miri64 commented Jul 31, 2020

But why do we have two checks? There are places in contrib code where we check for IS_USED(MODULE_LWIP_IPV4) and then other places where we check for #ifdef LWIP_IPV4. Are they equivalent in our build system? Would it make sense to unify?

In general I'd say, they are equivalent, yes. If the lwip_ipv6/lwip_ipv4 modules are used, the LWIP_IPV6/LWIP_IPV4 macros are set to 1. Checking the macros is lwIP style, checking the module is RIOT style. I originally tried to use checking macros for more lwIP-specific code (e.g. platform-specific implementations of lwIP functions) and checking modules for RIOT-wrapper code. Obviously, this somewhat mixed over time. I'm not against unifying styles, but IMHO it should be rather moved to the lwIP style where applicable, as this is the guaranteed state: lwIP does not care about IS_USED(MODULE_LWIP_IPV4), so if IS_USED(MODULE_LWIP_IPV4) is different from IS_ACTIVE(LWIP_IPV4) somehow, we might run into compile-time errors.

@miri64 miri64 changed the title pkg/lwip: Use IS_USED() and bugfix pkg/lwip: Use IS_ACTIVE() and bugfix Jul 31, 2020
@maribu
Copy link
Member Author

maribu commented Jul 31, 2020

Squash?

@miri64
Copy link
Member

miri64 commented Jul 31, 2020

Something broke 😕

LWIP_IPV4=1 LWIP_IPV6=1 make -C tests/lwip_sock_tcp/ flash test
``` make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip_sock_tcp' Building application "tests_lwip_sock_tcp" for "native" with MCU "native".

"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/lwip
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/lwip/src/api -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=lwip_api
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/lwip/src/core -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=lwip_core
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/lwip/src/core/ipv4 -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=lwip_ipv4
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/lwip/src/core/ipv6 -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=lwip_ipv6
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/lwip/src/netif -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=lwip_netif
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/build/pkg/lwip -f /home/mlenders/Repositories/RIOT-OS/RIOT/Makefile.base MODULE=lwip
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/boards/native
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/boards/native/drivers
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/core
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/cpu/native
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/cpu/native/periph
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/cpu/native/stdio_native
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/cpu/native/vfs
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/drivers
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/drivers/netdev_eth
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/drivers/periph_common
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/lwip/contrib
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/lwip/contrib/netdev
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/lwip/contrib/sock
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/pkg/lwip/contrib/sock/tcp
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/auto_init
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/div
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/luid
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/net/crosslayer/inet_csum
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/net/netdev_test
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/net/network_layer/ipv4/addr
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/net/network_layer/ipv6/addr
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/ps
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/random
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/random/tinymt32
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/sema
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/test_utils/interactive_sync
"make" -C /home/mlenders/Repositories/RIOT-OS/RIOT/sys/xtimer
text data bss dec hex filename
242864 864 81308 325036 4f5ac /home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip_sock_tcp/bin/native/tests_lwip_sock_tcp.elf
true
r
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip_sock_tcp/bin/native/tests_lwip_sock_tcp.elf
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: 2020.10-devel-459-g6384bc-HEAD)
code 0x51
Calling test_tcp_connect4__EADDRINUSE()
Calling test_tcp_connect4__EAFNOSUPPORT()
Calling test_tcp_connect4__EINVAL_addr()
Calling test_tcp_connect4__EINVAL_netif()
Calling test_tcp_connect4__success_without_port()
Calling test_tcp_connect4__success_local_port()
Calling test_tcp_listen4__EADDRINUSE()
Calling test_tcp_listen4__EAFNOSUPPORT()
Calling test_tcp_listen4__EINVAL()
Calling test_tcp_listen4__success_any_netif()
Calling test_tcp_listen4__success_spec_netif()
Calling test_tcp_accept4__EAGAIN()
Calling test_tcp_accept4__EINVAL()
Calling test_tcp_accept4__ETIMEDOUT()

  • Calling sock_tcp_accept()

  • (timed out with timeout 1000000)
    Calling test_tcp_accept4__success()
    Calling test_tcp_read4__EAGAIN()
    Calling test_tcp_read4__ECONNRESET()
    Calling test_tcp_read4__ENOTCONN()
    Calling test_tcp_read4__ETIMEDOUT()

  • Calling sock_tcp_read()

  • (timed out with timeout 1000000)
    Calling test_tcp_read4__success()
    Calling test_tcp_read4__success_with_timeout()
    Calling test_tcp_read4__success_non_blocking()
    Calling test_tcp_write4__ENOTCONN()
    Calling test_tcp_write4__success()
    Calling test_tcp_connect6__EADDRINUSE()
    Calling test_tcp_connect6__EAFNOSUPPORT()
    Calling test_tcp_connect6__EINVAL_addr()
    Calling test_tcp_connect6__EINVAL_netif()
    Calling test_tcp_connect6__success_without_port()
    Calling test_tcp_connect6__success_local_port()
    Calling test_tcp_listen6__EADDRINUSE()
    tests/lwip_sock_tcp/main.c:644 => failed condition
    *** RIOT kernel panic:
    CONDITION FAILED.

    pid | name | state Q | pri | stack ( used) ( free) | base addr | current

    • | isr_stack | - - | - | 8192 ( -1) ( 8193) | 0x566605c0 | 0x566605c0
      1 | idle | pending Q | 15 | 8192 ( 584) ( 7608) | 0x5665e3a0 | 0x56660200
      2 | main | running Q | 7 | 12288 ( 2892) ( 9396) | 0x5665b3a0 | 0x5665e200
      3 | tcpip_thread | bl mbox _ | 1 | 8192 ( 2216) ( 5976) | 0x56666fe8 | 0x56668e48
      4 | tcp_client | bl rx _ | 6 | 8192 ( 2432) ( 5760) | 0x566571c0 | 0x56659020
      5 | tcp_server | bl rx _ | 5 | 8192 ( 2496) ( 5696) | 0x566591c0 | 0x5665b020
      | SUM | | | 53248 (10620) (42628)

*** halted.

native: exiting
Unexpected end of file in expect script at "child.expect_exact("Calling test_tcp_listen6__EAFNOSUPPORT()")" (tests/lwip_sock_tcp/tests/01-run.py:69)

make: *** [/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip_sock_tcp/../../Makefile.include:772: test] Error 1
make: Leaving directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip_sock_tcp'

</details>

@miri64
Copy link
Member

miri64 commented Jul 31, 2020

Oh no, its also broken in master :-(

@miri64
Copy link
Member

miri64 commented Jul 31, 2020

Oh no, its also broken in master :-(

Regression was introduced in 035acc2

@miri64
Copy link
Member

miri64 commented Jul 31, 2020

I did not mean for you to revert that change ... the change is valid. After some debugging, it seems more there is actually a bug in the test. The line in question checks if listen fails with an -EADDRINUSE. However, the server started a few lines above is started with the SOCK_FLAGS_REUSE_EP flag.

case _SERVER_MSG_START:
if (!server_started) {
expect(0 == sock_tcp_listen(&_server_queue, &_server_addr,
_server_queue_array,
_SERVER_QUEUE_SIZE,
SOCK_FLAGS_REUSE_EP));
server_started = true;
}
break;

035acc2 might just have uncovered that test error.

@maribu
Copy link
Member Author

maribu commented Jul 31, 2020

May I squash?

@miri64
Copy link
Member

miri64 commented Jul 31, 2020

Yes please.

This also fixes an issue detected by `tests/lwip_sock_udp` when both IPv4 and
IPv6 are enabled.
@miri64
Copy link
Member

miri64 commented Jul 31, 2020

See #14668

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.

This PR fixes however two real regressions introduced by 035acc2 in tests/lwip_sock_ip and tests/lwip_sock_udp when build with dual stack support and tests/lwip also still works as expected in dual stack mode. So ACK.

@miri64 miri64 merged commit dcbb282 into RIOT-OS:master Jul 31, 2020
@maribu
Copy link
Member Author

maribu commented Jul 31, 2020

Thanks for the reviews!

@maribu maribu deleted the pkg_lwip branch July 31, 2020 12:22
@miri64 miri64 added the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Jul 31, 2020
@miri64
Copy link
Member

miri64 commented Jul 31, 2020

Can you backport this to the 2020.07-branch, please in case I decide to make a point release?

@maribu
Copy link
Member Author

maribu commented Jul 31, 2020

Backport provided in #14671

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 Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants