Skip to content

nanocoap: Default the blocksize2 to the configured value#21951

Closed
Teufelchen1 wants to merge 1 commit intoRIOT-OS:masterfrom
Teufelchen1:fix_nanocoap
Closed

nanocoap: Default the blocksize2 to the configured value#21951
Teufelchen1 wants to merge 1 commit intoRIOT-OS:masterfrom
Teufelchen1:fix_nanocoap

Conversation

@Teufelchen1
Copy link
Copy Markdown
Contributor

Contribution description

Hii 🐧

The CoAP Blocksize RFC7959 says:

   There is no default value for the Block1 and Block2 Options.  Absence
   of one of these options is equivalent to an option value of 0 with
   respect to the value of NUM and M that could be given in the option,
   i.e., it indicates that the current block is the first and only block
   of the transfer (block number 0, M bit not set).  However, in
   contrast to the explicit value 0, which would indicate an SZX of 0
   and thus a size value of 16 bytes, there is no specific explicit size
   implied by the absence of the option -- the size is left unspecified.
   (As for any uint, the explicit value 0 is efficiently indicated by a
   zero-length option; this, therefore, is different in semantics from
   the absence of the option.)

RIOTs current behaviour is indeed to treat a missing Block2 option as SZX == 0 and consequently sends 16 bytes of response.
I think this "feels" like a bug. Why would I want only 16 bytes if I (as the request sender) didn't bother to restrict the block size? It is very likely that I can handle more than 16 byte responses. In addition, any resource that is bigger than 16 bytes will be truncated to 16 bytes.

We already have a configuration for our maximum blocksize, I propose to default to that.

Testing procedure

Issues/PRs references

@Teufelchen1 Teufelchen1 requested a review from miri64 as a code owner December 11, 2025 15:31
@github-actions github-actions bot added Area: network Area: Networking Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System labels Dec 11, 2025
@Teufelchen1 Teufelchen1 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 11, 2025
@riot-ci
Copy link
Copy Markdown

riot-ci commented Dec 11, 2025

Murdock results

✔️ PASSED

3cc50ab nanocoap: Default the blocksize2 to the configured value

Success Failures Total Runtime
10949 0 10950 09m:40s

Artifacts

@benpicco
Copy link
Copy Markdown
Contributor

Since you've merged #21952 I think we can close this.

@benpicco benpicco closed this Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: CoAP Area: Constrained Application Protocol implementations Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants