Skip to content

examples/dtls-echo: set address family for sessions [backport 2022.07]#18371

Merged
miri64 merged 1 commit intoRIOT-OS:2022.07-branchfrom
miri64:backport/2022.07/examples/fix/dtls-echo-af
Jul 26, 2022
Merged

examples/dtls-echo: set address family for sessions [backport 2022.07]#18371
miri64 merged 1 commit intoRIOT-OS:2022.07-branchfrom
miri64:backport/2022.07/examples/fix/dtls-echo-af

Conversation

@miri64
Copy link
Member

@miri64 miri64 commented Jul 26, 2022

Backport of #18369

Contribution description

d424aae introduced address families to the RIOT interpretation of tinydtls-session_ts. However, while fixing the naming for the addr field, it did not set the family member for the sessions in the dtls-echo example, having that example run into an assertion. This patch fixes that.

Testing procedure

I used the same script to find the issue to test its fix (assuming you are in RIOTBASE:

sudo dist/tools/tapsetup/tapsetup
cat << EOF > test_dtls.py
#! /usr/bin/env python3
import sys

from riotctrl.ctrl import RIOTCtrl

sys.path.append("dist/pythonlibs")
from riotctrl_shell.netif import IfconfigListParser, Ifconfig

if __name__ == "__main__":
    RIOTCtrl.MAKE_ARGS = ("-j",)
    ctrl0 = RIOTCtrl(application_directory="examples/dtls-echo", env={"WERROR": "0"})
    ctrl1 = RIOTCtrl(
        application_directory="examples/dtls-echo", env={"PORT": "tap1", "WERROR": "0"}
    )
    ctrl0.make_run(["flash"])
    with ctrl0.run_term(reset=False), ctrl1.run_term(reset=False):
        ctrl0.term.logfile = sys.stdout
        ctrl1.term.logfile = sys.stdout
        shell0 = Ifconfig(ctrl0)
        shell1 = Ifconfig(ctrl1)
        netifs = IfconfigListParser().parse(shell1.ifconfig_list())
        server_addr = list(netifs.values())[0]["ipv6_addrs"][0]["addr"]
        res = shell1.cmd("dtlss start")
        assert res.strip() == "dtlss start"
        res = shell0.cmd(f"dtlsc {server_addr} hello")
        res1 = shell1.cmd("help")
        assert "Client: got DTLS Data App -- hello --" in res
EOF
chmod +x test_dtls.py
./test_dtls.py

It should succeed and its output should contain the following crucial lines:

> dtlsc fe80::d827:1dff:fea8:6424 hello
dtlsc fe80::d827:1dff:fea8:6424 hello
Client: got DTLS Data App -- hello --
> help

Server: got DTLS Data App: --- hello ---	(echo!)

Issues/PRs references

Follow-up on #17765

d424aae introduced address families to
the RIOT interpretation of tinydtls-`session_t`s. However, while fixing
the naming for the `addr` field, it did not set the `family` member for
the sessions in the `dtls-echo` example, having that example run into [an
assertion][1]. This patch fixes that.

[1]: https://github.com/eclipse/tinydtls/blob/bda40789a7c280f248eeca6d09ddd624cdaf5dc8/session.c#L146

(cherry picked from commit 2679fca)
@miri64 miri64 added Area: examples Area: Example Applications CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) labels Jul 26, 2022
@miri64 miri64 enabled auto-merge July 26, 2022 19:33
@miri64 miri64 merged commit 7e9a860 into RIOT-OS:2022.07-branch Jul 26, 2022
@miri64 miri64 deleted the backport/2022.07/examples/fix/dtls-echo-af branch July 26, 2022 22:37
@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: examples Area: Example Applications CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: release backport Integration Process: The PR is a release backport of a change previously provided to master Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants