Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions snippets/ethernet/ethernet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ CONFIG_NET_MGMT_EVENT=y
# boot up to 30 s waiting for a link.
CONFIG_NET_CONFIG_SETTINGS=n

# SO_SNDTIMEO, DoIP's bound on a send to a tester that stopped reading. Without
# it the option is refused and a blocked send waits 10 s
# (CONFIG_NET_SOCKET_MAX_SEND_WAIT).
CONFIG_NET_CONTEXT_SNDTIMEO=y

CONFIG_NET_MAX_CONTEXTS=12
CONFIG_NET_MAX_CONN=12
CONFIG_ZVFS_OPEN_MAX=16
Expand Down
23 changes: 23 additions & 0 deletions testing/suites/doip/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ def test_a_third_tester_is_refused(host):
assert c.closed()


def test_a_tester_that_stops_reading_is_closed_within_a_second(host):
with Raw(host) as stalled, Raw(host) as other:
assert stalled.activate(0x0E80) == 0x10
assert other.activate(0x0E81) == 0x10
# More answers than its receive buffer and the entity's send window hold, none read.
stalled.sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 2048)
stalled.sock.settimeout(0.2)
try:
for _ in range(600):
stalled.send(doip.DIAGNOSTIC, struct.pack("!HH", 0x0E80, ECU) + b"\x22\xf1\x90")
except TimeoutError:
pass
# The entity waits on it 1 s at most, once; the other tester is answered again after.
worst, end = 0.0, time.monotonic() + frames.bound(3.0)
while time.monotonic() < end:
started = time.monotonic()
assert other.request(b"\x3e\x00", source=0x0E81) == b"\x7e\x00"
worst = max(worst, time.monotonic() - started)
assert worst < frames.bound(1.0) + 2 * SLACK_S, worst
# Its socket is the entity's to give again: one open, the other tester's.
assert doip.udp(host, ENTITY_STATUS)[0][3][2] == 1


def test_initial_inactivity(host):
with Raw(host) as a:
started = time.monotonic()
Expand Down
Loading