Skip to content

table with no keys and size=1 #1334

@ml1050

Description

@ml1050

Hi!

Adding exactly one entry to a table with size=1 and no keys used to work with an old version of simple_switch_grpc, but it fails now.

    action set_lb_key(bit<8> k, bit<8> n) {
        _lb_key = k;
        _num_workers = n;
    }

    table get_lb_key {
        actions = {
            set_lb_key;
        }
        size = 1;
    }

Here is a patch to make it work again.

diff --git a/src/bm_sim/match_units.cpp b/src/bm_sim/match_units.cpp
index 699af02..c47cfe8 100644
--- a/src/bm_sim/match_units.cpp
+++ b/src/bm_sim/match_units.cpp
@@ -805,7 +805,7 @@ template<typename V>
 MatchErrorCode
 MatchUnitAbstract<V>::add_entry(const std::vector<MatchKeyParam> &match_key,
                                 V value, entry_handle_t *handle, int priority) {
-  if (this->get_size_key() == 0) return MatchErrorCode::NO_TABLE_KEY;
+  if (this->get_size_key() == 0 && match_key.size()) return MatchErrorCode::NO_TABLE_KEY;
   MatchErrorCode rc = add_entry_(match_key, std::move(value), handle, priority);
   if (rc != MatchErrorCode::SUCCESS) return rc;
   EntryMeta &meta = entry_meta[HANDLE_INTERNAL(*handle)];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions