All of lore.kernel.org
 help / color / mirror / Atom feed
* [0/2 bpf-next] Expose netdev in XDP progs with BTF_ID
@ 2022-11-09 21:52 John Fastabend
  2022-11-09 21:52 ` [1/2 bpf-next] bpf: expose net_device from xdp for metadata John Fastabend
  2022-11-09 21:52 ` [2/2 bpf-next] bpf: add selftest to read xdp_md fields John Fastabend
  0 siblings, 2 replies; 22+ messages in thread
From: John Fastabend @ 2022-11-09 21:52 UTC (permalink / raw)
  To: hawk, daniel, kuba, davem, ast; +Cc: netdev, bpf, john.fastabend, sdf

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2022-11-16 19:46 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 21:52 [0/2 bpf-next] Expose netdev in XDP progs with BTF_ID John Fastabend
2022-11-09 21:52 ` [1/2 bpf-next] bpf: expose net_device from xdp for metadata John Fastabend
2022-11-10  1:37   ` Yonghong Song
2022-11-10  2:17     ` John Fastabend
2022-11-10 12:45       ` Toke Høiland-Jørgensen
2022-11-10 16:53         ` Yonghong Song
2022-11-10 17:02         ` John Fastabend
2022-11-11 10:51           ` Jesper Dangaard Brouer
2022-11-11 15:15             ` Yonghong Song
2022-11-10 16:46       ` Yonghong Song
2022-11-10 22:58         ` John Fastabend
2022-11-10 23:11           ` John Fastabend
2022-11-11  6:34             ` Yonghong Song
2022-11-13 18:27               ` John Fastabend
2022-11-14 16:51                 ` Yonghong Song
2022-11-14 18:23                   ` John Fastabend
2022-11-16 19:46                     ` Jakub Kicinski
2022-11-11  6:28           ` Yonghong Song
2022-11-11  1:13   ` kernel test robot
2022-11-11  3:04   ` kernel test robot
2022-11-11  5:15   ` kernel test robot
2022-11-09 21:52 ` [2/2 bpf-next] bpf: add selftest to read xdp_md fields John Fastabend

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.