Skip to content

Fix integer overflow in OpenFlow meter stats#7786

Open
Av1ralS1ngh wants to merge 1 commit intoantrea-io:mainfrom
Av1ralS1ngh:fix/openflow-meter-stats-overflow-7784
Open

Fix integer overflow in OpenFlow meter stats#7786
Av1ralS1ngh wants to merge 1 commit intoantrea-io:mainfrom
Av1ralS1ngh:fix/openflow-meter-stats-overflow-7784

Conversation

@Av1ralS1ngh
Copy link

GetMeterStats retrieves per-meter packet drop counts from OVS via OpenFlow multipart replies. The OVS PacketBandCount field isuint64, but the callback signature truncated it to int64, causing silent overflow when cumulative drop counts exceed math.MaxInt64.

This change updates the entire call chain to use uint64:

What changed:

  • pkg/ovs/openflow/interfaces.go: updated GetMeterStats callback signature from func(int, int64) to func(int, uint64).

  • pkg/ovs/openflow/ofctrl_bridge.go: removed explicit int64 cast; stats.BandStats[0].PacketBandCount is passed directly as uint64.

  • pkg/agent/openflow/client.go: updated handleMeterStatsReply to accept uint64.

  • pkg/agent/openflow/pipeline.go: changed ovsMeterPacketDrops from map[int]*atomic.Int64 to map[int]*atomic.Uint64.

  • pkg/ovs/openflow/ofctrl_bridge_test.go: aligned test assertions with uint64 types.

  • pkg/ovs/openflow/testing/mock_openflow.go: regenerated mock to match updated interface.

  • pkg/agent/openflow/meter_test.go [NEW]: test covering initial counts, incremental updates, and values exceeding MaxInt64.

    Fixes Integer overflow in OpenFlow meter stats handling #7784

Use uint64 for packet counts in GetMeterStats to prevent overflow.

Update interfaces, implementation, and tests.
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.

Integer overflow in OpenFlow meter stats handling

1 participant