lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221109215242.1279993-1-john.fastabend@gmail.com>
Date:   Wed,  9 Nov 2022 13:52:40 -0800
From:   John Fastabend <john.fastabend@...il.com>
To:     hawk@...nel.org, daniel@...earbox.net, kuba@...nel.org,
        davem@...emloft.net, ast@...nel.org
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org,
        john.fastabend@...il.com, sdf@...gle.com
Subject: [0/2 bpf-next] Expose netdev in XDP progs with BTF_ID

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ