nsg-ethz / p4-utils

Extension to Mininet that makes P4 networks easier to build
GNU General Public License v2.0
183 stars 67 forks source link

For table with empty key, `table_add` method will return `Error: Invalid table name (xxx)` #38

Closed Benature closed 2 years ago

Benature commented 2 years ago

I have some tables that have no match keys, when I use controller.table_add to add table action, it output with

Error: Invalid table name (get_swid)
edgar-costa commented 2 years ago

This seems related to issue: #35

You can not do a table_add with a keyless table. You can only set the default action.

Benature commented 2 years ago

But default action in P4 cannot make actions' arguments specific for each switch.

edgar-costa commented 2 years ago

You should be able to set the default action with 1 argument no?

edgar-costa commented 2 years ago

Use this instead https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/utils/thrift_API.py#L1019

Benature commented 2 years ago

Thank you, but using table_set_default, I still get the Error: Invalid table name (test_tbl)

the p4 code of the table is

    action test_action(bit<32> arg) {
        meta.test = arg;
    }
    table test_tbl{
        key = {}
        actions = {
            test_action;
            NoAction;
        }
        default_action = NoAction;
    }
edgar-costa commented 2 years ago

Maybe it is a bug, I would have to try it myself.

Can you try to define the table without the line key = {}

Benature commented 2 years ago

OK, I've tried this, there is no difference.

    action test_action(bit<32> arg) {
        meta.test = arg;
    }
    table test_tbl{
        actions = {
            test_action;
            NoAction;
        }
        default_action = NoAction;
    }