Coder Social home page Coder Social logo

Comments (10)

mihaibudiu avatar mihaibudiu commented on June 24, 2024

We do not support ternary lookups either. Range lookups could be converted to ternary lookups. Bpf has no range maps as far as I know.

from p4c-xdp.

maharishib avatar maharishib commented on June 24, 2024

Is there a way to iterate over each entry in the BPF map. With that, I think I can solve my problem.

from p4c-xdp.

mihaibudiu avatar mihaibudiu commented on June 24, 2024

You can iterate in user space, but not in the kernel.

from p4c-xdp.

maharishib avatar maharishib commented on June 24, 2024

Okay, thanks.

from p4c-xdp.

maharishib avatar maharishib commented on June 24, 2024

Is there any other way to implement range matching, as i want to use the priority of rules also.

from p4c-xdp.

mihaibudiu avatar mihaibudiu commented on June 24, 2024

If you can give an example of how you would do it in raw ebpf perhaps we can implement it in the compiler.

from p4c-xdp.

maharishib avatar maharishib commented on June 24, 2024
Suppose we have to match 3 columns, match data is (V1, V2, V3).
Now, For the first case, consider the table data as below. I want, rule 1 to be matched. (X is don't care, that is I don't care what value is placed there).
------------------------------------------
|column A | column B | column C| priority| => Action
------------------------------------------
|    V1   |    V2    |    V3   |    0    | => ActionParam1
|    V1   |    V2    |    X    |    1    | => ActionParam2
------------------------------------------

Now, For the first case, consider the table data as below. I want, rule 2 to be matched. (X is don't care, that is I don't care what value is placed there).
------------------------------------------
|column A | column B | column C| priority| => Action
------------------------------------------
|    V1   |    V2    |    V3   |    1    | => ActionParam1
|    V1   |    V2    |    X    |    0    | => ActionParam2
------------------------------------------

In bmv2, I implement this don't care condition using range(0->2^(length of the field)-1) and used priority to match the rules.

from p4c-xdp.

maharishib avatar maharishib commented on June 24, 2024

In raw ebpf, I was thinking to iterate over the MAP using bpf_get_next_key. And then for each key, get the whole element if key matches the current packet data using lookup or any other method. Also while iterating, compare it with previously matched rules.

from p4c-xdp.

mihaibudiu avatar mihaibudiu commented on June 24, 2024

You cannot write loops in ebpf programs. Bounded loops are considered, but i don't think iteration over map entries will ever be supported. Anyway, if you want fast packet processing you don't have time for loops.

from p4c-xdp.

maharishib avatar maharishib commented on June 24, 2024

Ok, Thanks

from p4c-xdp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.