[0/2 bpf-next] Expose netdev in XDP progs with BTF_ID

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

 



In one of our network monitoring tools we collect metadata about the
interfaces. This is done in a map and then userspace can read the
stats out as needed. Currently, this is done through kprobes but
it causes unnecessary overhead (we have an XDP program running and
its slower than XDP anyways) and extra complexity as we have two
programs instead of one. The main hook we use to chase down the
needed data is the net_device. From this we can get the name of
the interface, its network namespace (and eventually pod in K8s
world), qdisc information, etc.

Because some of the data is per packet data, e.g. getting a unique
key for the ifindex+inum, we can't simply do it with an iterator.

Patch1 exposes the net_device in the xdp_md and patch 2 adds some
tests to walk the net_device to report name, ifindex, and inum.

John Fastabend (2):
  bpf: expose net_device from xdp for additional metadata
  bpf: add selftest to read xdp_md fields

 include/uapi/linux/bpf.h                      |  1 +
 net/core/filter.c                             | 19 ++++++++++
 tools/include/uapi/linux/bpf.h                |  1 +
 .../testing/selftests/bpf/prog_tests/xdp_md.c | 35 +++++++++++++++++++
 .../testing/selftests/bpf/progs/test_xdp_md.c | 25 +++++++++++++
 5 files changed, 81 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_md.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_xdp_md.c

-- 
2.33.0




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux