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

compiler support for range lookup #115

Closed
maharishib opened this issue Jul 30, 2019 · 10 comments
Closed

compiler support for range lookup #115

maharishib opened this issue Jul 30, 2019 · 10 comments

Comments

@maharishib
Copy link

Hi,
Could this compiler support range for looking up key(just like bmv2)?

@mihaibudiu
Copy link
Contributor

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.

@maharishib
Copy link
Author

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

@mihaibudiu
Copy link
Contributor

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

@maharishib
Copy link
Author

Okay, thanks.

@maharishib
Copy link
Author

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

@mihaibudiu
Copy link
Contributor

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

@maharishib
Copy link
Author

maharishib commented Jul 31, 2019

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.

@maharishib
Copy link
Author

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.

@mihaibudiu
Copy link
Contributor

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.

@maharishib
Copy link
Author

Ok, Thanks

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