Skip to content

libcontainer: read /proc/net/udp queues as tx:rx - #3979

Open
AnujYamdagni wants to merge 1 commit into
google:masterfrom
AnujYamdagni:fix-udp-queue-order
Open

AnujYamdagni wants to merge 1 commit into
google:masterfrom
AnujYamdagni:fix-udp-queue-order

Conversation

@AnujYamdagni

Copy link
Copy Markdown

scanUDPStats reads the queue column of /proc/net/udp as rx:tx, but the kernel writes tx_queue:rx_queue (the file header says so, and udp4_format_sock prints the write queue first). So container_network_udp_usage_total and container_network_udp6_usage_total report the transmit queue as udp_state="rxqueued" and the receive queue as txqueued, and the API's RxQueued/TxQueued fields are swapped the same way. The udp metric is off by default, so only users who enable it see this.

The fix swaps the scan order. The test fixture already has the tx_queue rx_queue header, but its expected values matched the bug, so this change corrects them too.

Test plan (Go 1.27.4, linux/amd64, master at cacca25), in lib/:

  • go test -count=1 -run TestScanUDPStats ./container/libcontainer/: with the corrected expectations, master fails (RxQueued:0xa, TxQueued:0xb, want 0xb, 0xa); with this change it passes.
  • go test -race -count=1 ./container/libcontainer/ ./metrics/: ok.

Not tested: a live container with non-empty UDP queues.

The queue column of /proc/net/udp and /proc/net/udp6 is
tx_queue:rx_queue, as the file header and the kernel's udp4_format_sock
show, but scanUDPStats reads it as rx:tx. The rxqueued and txqueued
values of container_network_udp_usage_total and
container_network_udp6_usage_total are therefore swapped.

Scan the column in the right order. The test fixture already has the
right header; fix its expected values, which matched the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant