Re: XDP BPF Stack Limit Issues

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

 



Thank you for pointing this out Jesper! I'm honestly surprised I didn't realize this before.


I've made this change and I'm able to compile the XDP/BPF program without any issues now.


Thank you again!

On 12/17/2020 2:50 AM, Jesper Dangaard Brouer wrote:
I have to look elsewhere[2] to see that:
  #define MAX_FILTERS 55

Your problem is that you create an array with 55 pointers each 8 bytes
equal 440 bytes on the stack (max stack is 512).  Why do you need to
lookup all 55 map elements in a loop before using them?

https://gist.github.com/gamemann/663674924e16286b02a835637912c2a5#file-xdp_fw_ipv6_maps-c-L267

  struct filter *filter[MAX_FILTERS];
  for (uint8_t i = 0; i < MAX_FILTERS; i++)
     {
         key = i;
filter[i] = bpf_map_lookup_elem(&filters_map, &key);
     }
  [...]
  for (uint8_t i = 0; i < MAX_FILTERS; i++)
     {
         // Check if ID is above 0 (if 0, it's an invalid rule).
         if (!filter[i] || filter[i]->id < 1)
   [...]



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

  Powered by Linux