Skip to content

tests/lwip_sock: Take lock before calling etharp#17145

Merged
miri64 merged 1 commit intoRIOT-OS:masterfrom
yarrick:core_lock
Nov 6, 2021
Merged

tests/lwip_sock: Take lock before calling etharp#17145
miri64 merged 1 commit intoRIOT-OS:masterfrom
yarrick:core_lock

Conversation

@yarrick
Copy link
Copy Markdown
Contributor

@yarrick yarrick commented Nov 5, 2021

Contribution description

Lock lwIP before adding static entry to etharp (fixing assert)

Testing procedure

BOARD=native LWIP_IPV6=0 LWIP_IPV4=1 make -C tests/lwip_sock_ip/ clean flash test -j

BOARD=native LWIP_IPV6=0 LWIP_IPV4=1 make -C tests/lwip_sock_udp/ clean flash test -j

Issues/PRs references

Fixes #17144

@yarrick yarrick requested a review from miri64 as a code owner November 5, 2021 17:48
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Nov 5, 2021
@yarrick yarrick requested a review from fjmolinas November 5, 2021 17:49
@yarrick yarrick added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 5, 2021
@yarrick yarrick 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 and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 6, 2021
@yarrick yarrick added the Area: network Area: Networking label Nov 6, 2021
@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 6, 2021

(as explanation why I want to keep the tests as is: Dual stack support is not the same #if branch in some cases as either IPv6 or IPv4 are, so until #14669 is resolved, I prefer to keep the tests in our main use case).

@miri64
Copy link
Copy Markdown
Member

miri64 commented Nov 6, 2021

I ran all the lwip_sock tests in all possible configurations

for test in tests/lwip_sock_{ip,tcp,udp}/; do
   for ipv6 in 0 1; do
       for ipv4 in 0 1; do
           if [ $((ipv4 + ipv6)) -eq 0 ]; then
               continue
           fi
           LWIP_IPV4=${ipv4} LWIP_IPV6=${ipv6} make -C ${test} flash -j test || break
        done
    done
done

They succeeded. I also tested tests/lwip on native by sending around some data, in both dual-stack IPv4 mode:

Details

Terminal 1 (DHCPv4 server)

sudo dist/tools/tapsetup/tapsetup
sudo dnsmasq --no-daemon --log-queries --dhcp-range=10.1.194.2,10.1.194.128,1h -i tapbr0

Terminal 2 (tap0)

$ QUIETER=1 LWIP_IPV4=1 LWIP_IPV6=1 make -C tests/lwip --no-print-directory -j flash term
Building application "tests_lwip" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/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
 287450	   1312	 101900	 390662	  5f606	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/bin/native/tests_lwip.elf
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/bin/native/tests_lwip.elf tap0 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

main(): This is RIOT! (Version: 2022.01-devel-392-g91be3-HEAD)
RIOT lwip test application
> tcp connect 10.1.194.45:1337
tcp connect 10.1.194.45:1337
> tcp send abcdef1234567890
tcp send abcdef1234567890
Success: send 8 byte over TCP to server
> udp send 10.1.194.45:1337 1234567890abcdef0987654321
udp send 10.1.194.45:1337 1234567890abcdef0987654321
Success: send 13 byte over UDP to 10.1.194.45:1337
> ip send 10.1.194.45 255 601234714567321
ip send 10.1.194.45 255 601234714567321
Success: send 8 byte over IPv4 to 10.1.194.45 (next header: 255)
> ^C
native: exiting

$ QUIETER=1 LWIP_IPV4=1 LWIP_IPV6=0 make -C tests/lwip --no-print-directory -j flash term
Building application "tests_lwip" for "native" with MCU "native".

/usr/bin/ld: /home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/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
 231035	   1228	 100396	 332659	  51373	/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/bin/native/tests_lwip.elf
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/bin/native/tests_lwip.elf tap0 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

main(): This is RIOT! (Version: 2022.01-devel-392-g91be3-HEAD)
RIOT lwip test application
> tcp connect 10.1.194.45:1337                 
tcp connect 10.1.194.45:1337
> tcp send 0987654321fedcba
tcp send 0987654321fedcba
Success: send 8 byte over TCP to server
> tcp disconnect
tcp disconnect
> udp send 10.1.194.45:1337 0987654321123456790abcdef
udp send 10.1.194.45:1337 0987654321123456790abcdef
Success: send 13 byte over UDP to 10.1.194.45:1337
> ip send 10.1.194.45 255 abcdef0987654321
ip send 10.1.194.45 255 abcdef0987654321
Success: send 8 byte over IPv4 to 10.1.194.45 (next header: 255)
> ^C
native: exiting

Terminal 3 (tap1)

$ PORT=tap1 make -C tests/lwip term
make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip'
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/bin/native/tests_lwip.elf tap1 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

main(): This is RIOT! (Version: 2022.01-devel-392-g91be3-HEAD)
RIOT lwip test application
> ifconfig
ifconfig
Iface ET0 HWaddr: da:27:1d:a8:64:24 Link: up State: up
        Link type: wired
        inet addr: 10.1.194.45 mask: 255.255.255.0 gw: 10.1.194.1
        inet6 addr: fe80:0:0:0:d827:1dff:fea8:6424 scope: link
> tcp server start 1337
tcp server start 1337
Success: started TCP server on port 1337
> udp server start 1337
udp server start 1337
Success: started UDP server on port 1337
> ip server start 255
ip server start 255
Success: started IP server on protocol 255
> TCP client [a01:c24d::]:49153 connected
Received TCP data from client [a01:c24d::]:49153
00000000  AB  CD  EF  12  34  56  78  90
Received UDP data from [a01:c24d::]:49153
00000000  12  34  56  78  90  AB  CD  EF  09  87  65  43  21
Received IP data from [10.1.194.77]:
00000000  60  12  34  71  45  67  32  10
^C
native: exiting

$ PORT=tap1 make -C tests/lwip term
make: Entering directory '/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip'
/home/mlenders/Repositories/RIOT-OS/RIOT/tests/lwip/bin/native/tests_lwip.elf tap1 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

main(): This is RIOT! (Version: 2022.01-devel-392-g91be3-HEAD)
RIOT lwip test application
> ifconfig
ifconfig
Iface ET0 HWaddr: da:27:1d:a8:64:24 Link: up State: up
        Link type: wired
        inet addr: 10.1.194.45 mask: 255.255.255.0 gw: 10.1.194.1
> tcp server start 1337
tcp server start 1337
Success: started TCP server on port 1337
> udp server start 1337
udp server start 1337
Success: started UDP server on port 1337
> ip server start 255
ip server start 255
Success: started IP server on protocol 255
> TCP client [10.1.194.77]:49153 connected
Received TCP data from client [10.1.194.77]:49153
00000000  09  87  65  43  21  FE  DC  BA
TCP connection to [10.1.194.77]:49153 reset
Received UDP data from [10.1.194.77]:49153
00000000  09  87  65  43  21  12  34  56  79  0A  BC  DE  F0
Received IP data from [10.1.194.77]:
00000000  AB  CD  EF  09  87  65  43  21
^C
native: exiting

They both work!

@miri64 miri64 merged commit 3677a93 into RIOT-OS:master Nov 6, 2021
@yarrick yarrick deleted the core_lock branch November 6, 2021 17:06
@fjmolinas
Copy link
Copy Markdown
Contributor

Thanks for the quick reaction @yarrick!

@fjmolinas fjmolinas added this to the Release 2022.01 milestone Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests/lwip_sock_ip: failing on native when using IPV4

3 participants