Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

compiler support for lpm #114

Open
kwjjyn opened this issue Jun 6, 2019 · 5 comments
Open

compiler support for lpm #114

kwjjyn opened this issue Jun 6, 2019 · 5 comments

Comments

@kwjjyn
Copy link

kwjjyn commented Jun 6, 2019

Hi,
Could this compiler support lpm for looking up key? For example , I could add 10.10.1.0/24 to the map of the table defined in P4 as key and want to match this subnet.

@mihaibudiu
Copy link
Contributor

If I understand right, this should be very easy to do as far as the compiler is concerned.

@mihaibudiu
Copy link
Contributor

I have pushed a PR against the compiler adding LPM table support.
p4lang/p4c#1962
I don't have a recent enough kernel, so perhaps you can help us test?

@kwjjyn
Copy link
Author

kwjjyn commented Jun 7, 2019

hi, Mihai Budiu
I saw this PR fail. Does this update relate to the kernel version? And if I want to test whether the compiler support lpm when I define a table in P4 like this :

table dstmactable {
        key = { hd.ipv4.dstAddr : lpm; }
        actions = {
            Fallback_action;
            Drop_action;
        }
        default_action = Drop_action;
        implementation = hash_table(64);
    }

do I need to pull the new commit of p4c and rebuild it firstly? And the key of dstmactable table also should be the ip address and netmask. How do I specify and add these infomation as key. For example, I want to add 10.0.0.0/24 as key , and in the control plane , maybe this way to specify the key is right?

key.field0 = 0x0a00000020   // 0x0a000000 is 10.0.0.0 , 0x20 is netmask 24.

@mihaibudiu
Copy link
Contributor

The PR did not pass because of a minor C++ style issue.

You can test this by indeed pulling this PR and building it; you can also wait until the PR is merged into master, but I don't know how soon that will be.

Interestingly, this PR may actually do what you want for the kernel, but it will break our user-level tests, since we do not support LPM tables in user space. I will file a separate issue for that. Since I didn't write a user-level test, we will be fine for now.

To insert entries in this table you will have to use the APIs specific to tries, see for example torvalds/linux@b95a5c4. The key is specified as the actual key plus a length. Currently we do not generate a specific key+length structure for this purpose, that's something that we could probably also add.

Please note that next week I will be traveling and I may be unable to respond to requests in a timeline manner.

@kwjjyn
Copy link
Author

kwjjyn commented Jun 7, 2019

Thank you for your prompt reply. And I'll test it by pulling the PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants