Re: Accessing userspace created persistent eBPF maps from kernel bpf restricted C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 8, 2017 at 10:37 AM, Zvi Effron <zeffron@xxxxxxxxxxxxx> wrote:
>> Well, I have to switch between maps based on an "entity switch" in the
>> producing the event.
>> The map type and format is fixed and pinned.  Say it could be one per
>> pid, if pid is the entity
>> switch.  /sys/bpf/pidno could be the pinned location.  Based on the
>> pid at the time of event,
>> I want to consult the map of that pid so I can
>> filter/aggregate/histogram events sent to user space.
>> The "entity switch" could be  major:minor:inode, or other such as well
>> (not easy to get from bpf now, but
>> you get the idea).  I can't have one or just a few maps because the
>> key value pairs will be
>> different for different entity switches.  I might not filter if
>> /sys/pid/pidno map is not present.
>
>> Thanks for your suggestion (Zvi and Daniel).  I will explore
>> BPF_TYPE_ARRAY_OF_MAPS  if it
>> can fit this case.
>
> It sounds like BPF_TYPE_HASH_OF_MAPS might be more of what you need,
> then. It's the same as BPF_TYPE_ARRAY_OF_MAPS, only it allows for a
> key instead of an index. You could use the major:minor:inode or
> whatever as the key, and then your problem becomes how the eBPF
> program can calculate the key.

If you know the details of each map (map type, key/value format), you
can have an app specific map
(one element to indicate (active map fd, active map property)) and you
can have a giant if statement

  /* fd is the map fd */
  if (active_map == map1) {
    ...
  } else if (active_map == map2) {
    ...
  }

>
> Good luck!
> --Zvi



[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux