lib: fix swapped values, bad setsockopt, and intermittent test failure#21214
lib: fix swapped values, bad setsockopt, and intermittent test failure#21214choppsv1 wants to merge 2 commits intoFRRouting:masterfrom
Conversation
Greptile SummaryThis PR fixes two distinct bugs in the mgmt message connection layer (
Both fixes are clearly correct and the changes are minimal and surgical. No new logic is introduced. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant C as msg_client
participant SC as short_circuit path
participant S as msg_server
Note over C,S: Short-circuit connection setup (fixed)
C->>SC: msg_client_connect_short_circuit()
SC->>SC: socketpair(AF_UNIX, SOCK_STREAM, 0, sockets)
SC->>SC: set_nonblocking(sockets[0])
SC->>SC: setsockopt_so_sendbuf(sockets[0], MSG_CONN_SEND_BUF_SIZE ✅)
Note right of SC: Previously: mstate.max_write_buf (msg count, not bytes ❌)
SC->>SC: setsockopt_so_recvbuf(sockets[0], MSG_CONN_RECV_BUF_SIZE ✅)
Note right of SC: Previously: mstate.max_read_buf (msg count, not bytes ❌)
SC->>S: server->create(sockets[1], &su) → msg_conn_accept_init()
S->>S: setsockopt_so_sendbuf(fd, MSG_CONN_SEND_BUF_SIZE) [already correct]
S->>S: setsockopt_so_recvbuf(fd, MSG_CONN_RECV_BUF_SIZE) [already correct]
Note over C,S: mgmt_msg_init assignment (fixed)
C->>C: mgmt_msg_init(ms, max_read_buf, max_write_buf, ...)
C->>C: ms->max_read_buf = max_read_buf ✅
Note right of C: Previously assigned max_write_buf here ❌
C->>C: ms->max_write_buf = max_write_buf ✅
Note right of C: Previously assigned max_read_buf here ❌
Last reviewed commit: "lib: fix swapped val..." |
2b6c583 to
47f58aa
Compare
47f58aa to
a27068a
Compare
a27068a to
9471ad3
Compare
We had reversed the setting of max read and write message count values for mgmtd connections (both server and client). This effectively allowed clients to send more than they received and the server to process more than it sent (i.e., backwards of what we probably want to keep a loaded system working properly) Also for the mgmtd loopback connection (i.e., sending CLI based YANG config or reciving oper-state) we were actually setting the recv and send kernel buf (setsockopt() which is given in bytes) to these number of message values (so less than 1K). In this case the kernel was ignoring us and using a default value instead which was actually 128K. Go ahead and use the same 128K value for our buffers as well. Signed-off-by: Christian Hopps <[email protected]>
Read and wait on live output from the clients rather than running the client to completion after it receives N notifications. This allows us to wait for the notifications we expect and not be fragile to receiving other notifications in between. Add flush() to stdout of FE_CLIENT otherwise we wait on line output from print() that never comes b/c it's buffered. Signed-off-by: Christian Hopps <[email protected]>
9471ad3 to
7598309
Compare
We had reversed the setting of max read and write message count values for mgmtd connections (both server and client). This effectively allowed clients to send more than they received and the server to process more than it sent (i.e., backwards of what we probably want to keep a loaded system working properly)
Also for the mgmtd loopback connection (i.e., sending CLI based YANG config or reciving oper-state) we were actually setting the recv and send kernel buf (setsockopt() which is given in bytes) to these number of message values. In this case the kernel was ignoring us and using a default value instead which was actually 128K. :)
Finally, fix an intermittent failure in mgmt_notify test that we (again) hit during CI testing of these changes.