1

Could someone provide a replacement for kmap_load_page(page) or kmap_atomic(page) so that page memory can be read with an offset, i.e. how can the following be done in the BPF program?

struct request *req;
struct bio *bio = req->bio;
struct bio_vec *bi_ivec = bio->bio->bi_io_vec;
void *page;

page = kmap_local_page(bi_ivec->bv_page);

bpf_probe_read(&curr_io->data, bi_ivec->bv_len,
               page + bi_ivec->bv_offset);

kunmap(bi_ivec->bv_page);

Above code gives error currently because I think kernel code can not be called from a BPF program just by including the header file.

  • 1
    Mapping pages of memory is not something eBPF can do at this moment. You are right, you can't just include the header files of the kernel and expect it to work. This will require creating new helper functions via a kernel patchset – Dylan Reimerink Aug 01 '22 at 10:26

0 Answers0