1

I am trying to access fmap which is already present in cgroup skb bpf object file, from tc egress ebpf hook.

By default, the map is getting created in /sys/fs/bpf/tc/globals/fmap. But i want to access the /sys/fs/bpf/fmap in tc egress cgroup. How to pass fmap path to tc program.

tc filter add dev egress bpf object-file ./parse_simple.o section simple direct-action

struct flow
{

        __be32  saddr;

        __be32  daddr;

};

 
struct bpf_elf_map SEC("maps") fmap = { 

        .type       = BPF_MAP_TYPE_LRU_HASH,

        .size_key   = sizeof(struct flow),

        .size_value = sizeof(u32),

        .pinning    = PIN_GLOBAL_NS,

        .max_elem   = 100,

};
Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128
  • https://stackoverflow.com/questions/69190723/ebpf-will-bpf-object-pin-maps-pin-internal-maps-for-bpf-map-type-hash-of-ma – mohamed.hanif Mar 09 '22 at 09:35

1 Answers1

1

libbpf bpf_map__pin() can be used to set the pin path. So if I set the path as PIN_GLOBAL_NS (/sys/fs/bpf/tc/globals) in the cgroup skb loading program, tc is able to access the same map. But I don't know the reverse (access the map which is pinned in non tc base path [example: /sys/fs/bpf/fmap]).

Reference

tomerpacific
  • 4,704
  • 13
  • 34
  • 52