Commit c7b90d0
feat: hold a real mutual-TLS session to the broker from bring-up
The other half. The device now opens a session to the broker at bring-up, over
lwIP's raw TCP and mbedTLS, with the credentials DeviceCertStore already holds —
and never closes it. Held rather than opened-and-closed on purpose: two sessions
that do not overlap measure max(), not sum(), and it is the sum that says what a
second session costs.
flash_text 361,736 -> 362,968 (+1,232)
static_bss 133,152 -> 157,280 (+24,128)
mbedtls_peak 22,208 -> 37,224 (+15,016)
heap_used 4,440 -> 4,440
The last line is the point of the exercise. mbedTLS's buffer used to peak at
22,208 bytes with SolidSyslog's session in it and nothing else; with the
device's own session open alongside it, 37,224. So a second concurrent session
costs about 15,000 bytes, not 22,208 — the difference is the parsed
certificates, the DRBG and the rest of the first session's one-off state, which
a device speaking mTLS has paid for already. Once the baseline is regenerated it
will hold that first session, and what SolidSyslog is charged for TLS memory
becomes the marginal figure, measured rather than argued.
"About", because mbedtls_peak is not byte-reproducible. Five runs of this image
gave 37,152 / 37,224 / 37,236 / 37,244 / 37,248 — a spread wider than the run's
64-byte drift tolerance, for the same reason heap_used moves: gen-certs.sh
builds a fresh PKI every run and DER lengths shift with the key material. The
figures above are the two committed run reports, so the arithmetic is checkable;
the marginal cost it yields is good to about a hundred bytes, not to the byte.
That has to be settled before the baseline is frozen with this key in it.
flash_text and static_bss are exact.
The static RAM growth is almost entirely the buffer: 32 KiB to 55 KiB, which is
the peak times 1.5 rounded up to the next KiB. The margin is not padding —
buffer_alloc hands out contiguous space, and 24 KiB against a 22.2 KiB peak
failed on fragmentation where 32 KiB worked. The remaining 576 bytes are the ssl
context, its config, and the TCP state.
The keep-alive list loses the mbedTLS client surface and most of the TCP entries,
because the session calls them for real now and naming a function there that the
device runs would say something untrue. Flash did not move for it: those call
closures were in the image either way, which is what the list was for. What stays
is what is still unexercised — UDP, the file API, and the teardown path a session
held for the life of the device never reaches.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent be1f78e commit c7b90d0
8 files changed
Lines changed: 456 additions & 72 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
190 | | - | |
191 | | - | |
| 191 | + | |
| 192 | + | |
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
0 commit comments