Skip to content

Conversation

@antoninbas
Copy link
Contributor

The GetFlowTableID function was incorrectly attempting to cast tableCache objects directly to binding.Table, but the cache stores *Table wrapper objects. The wrapper's ofTable field contains the actual binding.Table implementation. This caused a panic in the /ovsflows HTTP handler.

Fix the type assertion to match the pattern used in getTableByID:

objs[0].(*Table).ofTable.GetID()

Also add unit tests for GetFlowTableID, GetFlowTableName, and GetTableList to prevent regressions.

The GetFlowTableID function was incorrectly attempting to cast tableCache
objects directly to binding.Table, but the cache stores *Table wrapper
objects. The wrapper's ofTable field contains the actual binding.Table
implementation. This caused a panic in the `/ovsflows` HTTP handler.

Fix the type assertion to match the pattern used in getTableByID:
```
objs[0].(*Table).ofTable.GetID()
```

Also add unit tests for GetFlowTableID, GetFlowTableName, and
GetTableList to prevent regressions.

Signed-off-by: Antonin Bas <[email protected]>
@antoninbas antoninbas added kind/bug Categorizes issue or PR as related to a bug. action/backport Indicates a PR that requires backports. labels Oct 24, 2025
Copy link
Contributor

@luolanzone luolanzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@hongliangl hongliangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this. This bug has been introduced since OVS flexible pipeline framework was merged.

@antoninbas antoninbas merged commit 0a913f3 into antrea-io:main Oct 27, 2025
52 of 61 checks passed
@antoninbas antoninbas deleted the of-fix-type-assertion-panic-in-GetFlowTableID branch October 27, 2025 17:38
antoninbas added a commit to antoninbas/antrea that referenced this pull request Oct 27, 2025
The GetFlowTableID function was incorrectly attempting to cast tableCache
objects directly to binding.Table, but the cache stores *Table wrapper
objects. The wrapper's ofTable field contains the actual binding.Table
implementation. This caused a panic in the `/ovsflows` HTTP handler.

Fix the type assertion to match the pattern used in getTableByID:
```
objs[0].(*Table).ofTable.GetID()
```

Also add unit tests for GetFlowTableID, GetFlowTableName, and
GetTableList to prevent regressions.

Signed-off-by: Antonin Bas <[email protected]>
antoninbas added a commit to antoninbas/antrea that referenced this pull request Oct 27, 2025
The GetFlowTableID function was incorrectly attempting to cast tableCache
objects directly to binding.Table, but the cache stores *Table wrapper
objects. The wrapper's ofTable field contains the actual binding.Table
implementation. This caused a panic in the `/ovsflows` HTTP handler.

Fix the type assertion to match the pattern used in getTableByID:
```
objs[0].(*Table).ofTable.GetID()
```

Also add unit tests for GetFlowTableID, GetFlowTableName, and
GetTableList to prevent regressions.

Signed-off-by: Antonin Bas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action/backport Indicates a PR that requires backports. kind/bug Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants