Re: [PATCH v3 1/2] bpf: add a longest prefix match trie map implementation

2017-01-18 Thread Alexei Starovoitov
On Wed, Jan 18, 2017 at 03:30:14PM +0100, David Herrmann wrote: > Hi > > On Sat, Jan 14, 2017 at 5:55 PM, Alexei Starovoitov wrote: > > Another alternative is to extend samples/bpf/map_perf_test > > It has perf tests for most map types today (including lru) > > and trie would be natural addition

Re: [PATCH v3 1/2] bpf: add a longest prefix match trie map implementation

2017-01-18 Thread David Herrmann
Hi On Sat, Jan 14, 2017 at 5:55 PM, Alexei Starovoitov wrote: > Another alternative is to extend samples/bpf/map_perf_test > It has perf tests for most map types today (including lru) > and trie would be natural addition there. > I would prefer this latter option. I hooked into gettid() and inst

Re: [PATCH v3 1/2] bpf: add a longest prefix match trie map implementation

2017-01-14 Thread Alexei Starovoitov
On 1/14/17 4:17 AM, Daniel Mack wrote: +static struct bpf_map *trie_alloc(union bpf_attr *attr) +{ + size_t cost, cost_per_node; + struct lpm_trie *trie; + int ret; + + /* check sanity of attributes */ + if (attr->max_entries == 0 || + attr->map_flags != BP

[PATCH v3 1/2] bpf: add a longest prefix match trie map implementation

2017-01-14 Thread Daniel Mack
This trie implements a longest prefix match algorithm that can be used to match IP addresses to a stored set of ranges. Internally, data is stored in an unbalanced trie of nodes that has a maximum height of n, where n is the prefixlen the trie was created with. Tries may be created with prefix le