fix: CoAP Ping response uses RST instead of ACK per RFC 7252 §4.2#655
fix: CoAP Ping response uses RST instead of ACK per RFC 7252 §4.2#655sandrolain wants to merge 3 commits into
Conversation
RFC 7252 §4.2 specifies that an Empty Confirmable message (CoAP Ping) must be rejected with a matching Reset message, not acknowledged. This fixes the sendPong() function to set message.Reset instead of message.Acknowledgement for Confirmable empty messages. Fixes plgd-dev#603, plgd-dev#486
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughRespond to empty Confirmable CoAP pings with Reset (RST) instead of Acknowledgement (ACK) in the UDP client; add a test that sends a raw Confirmable Empty and asserts the server responds with RST and matching MID. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
udp/client/conn_test.go (1)
874-874: Minor: Unnecessary type assertion.
net.Conninterface already includesSetReadDeadline, so the type assertion to*net.UDPConnis not required.♻️ Suggested simplification
- err = conn.(*net.UDPConn).SetReadDeadline(time.Now().Add(time.Second * 2)) + err = conn.SetReadDeadline(time.Now().Add(time.Second * 2))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@udp/client/conn_test.go` at line 874, The line uses an unnecessary concrete-type assertion on conn before calling SetReadDeadline; replace the assertion form conn.(*net.UDPConn).SetReadDeadline(...) with the interface call conn.SetReadDeadline(...) (keeping the same deadline expression time.Now().Add(time.Second * 2)) so the code uses the net.Conn interface method directly and removes the needless type cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@udp/client/conn_test.go`:
- Line 874: The line uses an unnecessary concrete-type assertion on conn before
calling SetReadDeadline; replace the assertion form
conn.(*net.UDPConn).SetReadDeadline(...) with the interface call
conn.SetReadDeadline(...) (keeping the same deadline expression
time.Now().Add(time.Second * 2)) so the code uses the net.Conn interface method
directly and removes the needless type cast.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e7255feb-b296-4077-aebf-106af4eebdb7
📒 Files selected for processing (2)
udp/client/conn.goudp/client/conn_test.go
Files changed:
udp/client/conn.go(+3),udp/client/conn_test.go(+54)Problem:
sendPong()was settingmessage.Acknowledgementon the responseto a Confirmable empty message (CoAP Ping). RFC 7252 §4.2 requires the receiver
to reply with a matching Reset message, not an Acknowledgement. This caused
interoperability failures with compliant CoAP clients (reported in #603, #486).
Fix: One-line change —
message.Acknowledgement→message.Resetinudp/client/conn.go. A new testTestConnPingResponseIsResetverifies thecorrect message type is sent.
Summary by CodeRabbit
Bug Fixes
Tests