Skip to content

examples/dtls-echo: set address family for sessions#18369

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

examples/dtls-echo: set address family for sessions#18369
miri64 merged 1 commit intoRIOT-OS:masterfrom
miri64:examples/fix/dtls-echo-af

Conversation

@miri64
Copy link
Member

@miri64 miri64 commented Jul 26, 2022

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
@github-actions github-actions bot added the Area: examples Area: Example Applications label Jul 26, 2022
@miri64 miri64 requested a review from benpicco July 26, 2022 14:01
@miri64 miri64 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Process: blocked by feature freeze Integration Process: The impact of this PR is too high for merging it during soft feature freeze. Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch and removed Process: blocked by feature freeze Integration Process: The impact of this PR is too high for merging it during soft feature freeze. labels Jul 26, 2022
@miri64 miri64 requested a review from HendrikVE July 26, 2022 14:02
@miri64 miri64 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jul 26, 2022
Copy link
Member

@maribu maribu 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 looks good, trusting your testing

@miri64 miri64 enabled auto-merge July 26, 2022 14:13
@miri64 miri64 merged commit 23d8e9c into RIOT-OS:master Jul 26, 2022
@miri64 miri64 deleted the examples/fix/dtls-echo-af branch July 26, 2022 17:39
@miri64
Copy link
Member Author

miri64 commented Jul 26, 2022

Backport provided in #18371

@maribu maribu added this to the Release 2022.10 milestone Oct 14, 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: needs backport Integration Process: The PR is required to be backported to a release or feature branch 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.

2 participants