Commit Graph

7 Commits (aef10c735c02ca290aa7c985744dedb31b5a0daa)

Author SHA1 Message Date
Vincent Li 64d12aacc8 ebpf: Update eBPF map to BTF defined map
legacy map definition is removed from libbpf1.0+.
update the legacy map definition to BTF defined map.

Distros with < libbpf1.0 (0.5, 0.6, 0.7, 0.8) bpf_helpers.h
support BTF map definition, this change does not break
old libbpf and support new libpbf1.0+.

Bug: #6250

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
Co-authored-by: Victor Julien <vjulien@oisf.net>
10 months ago
Eric Leblond 9f016f8ba1 ebpf: improve parsing in filter.bpf
Parse VLAN and only filter on IPv4. This patch also change the type
of the counter to get a per CPU hash.
5 years ago
Eric Leblond 638a006e87 ebpf: remove BPF_LL_OFF in nhoff offset
It fixes invalid parsing in with recent kernels and does
not affect older kernels.
5 years ago
Eric Leblond 954762a429 ebpf: add filter by maps on example filter 5 years ago
Jesper Dangaard Brouer 7906c521cd ebpf: take clang -target bpf include issue of stdint.h into account
This patch prepares code before enabling the clang -target bpf.

The clang compiler does not like #include <stdint.h> when
using '-target bpf' it will fail with:

 fatal error: 'gnu/stubs-32.h' file not found

This is because using clang -target bpf, then clang will have '__bpf__'
defined instead of '__x86_64__' hence the gnu/stubs-32.h include
attempt as /usr/include/gnu/stubs.h contains, on x86_64:

  #if !defined __x86_64__
  # include <gnu/stubs-32.h>
  #endif
  #if defined __x86_64__ && defined __LP64__
  # include <gnu/stubs-64.h>
  #endif
  #if defined __x86_64__ && defined __ILP32__
  # include <gnu/stubs-x32.h>
  #endif

This can be worked around by installing the 32-bit version of
glibc-devel.i686 on your distribution.

But the BPF programs does not really need to include stdint.h,
if converting:
  uint64_t -> __u64
  uint32_t -> __u32
  uint16_t -> __u16
  uint8_t  -> __u8

This patch does this type syntax conversion.

The build of a ebpf files had an issue for system like Debian
because they don't have a asm/types.h in the include path if the
architecture is not defined which is the case due to target bpf.

This results in:

 clang-5.0 -Wall -Iinclude -O2 \
         -D__KERNEL__ -D__ASM_SYSREG_H \
         -target bpf -S -emit-llvm vlan_filter.c -o vlan_filter.ll
 In file included from vlan_filter.c:19:
 In file included from include/linux/bpf.h:11:
 /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not
 found
 #include <asm/types.h>
          ^~~~~~~~~~~~~
 1 error generated.
 Makefile:523: recipe for target 'vlan_filter.bpf' failed

This patch fixes the issue by adding a include path setting the
architecture to the one of the builder.

Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
Sidned-off-by: Eric Leblond <eric@regit.org>
7 years ago
Eric Leblond cde438f670 af-packet: add missing copyright header
And also fixes the copyright date in some files.
7 years ago
Eric Leblond 91e1256b01 af-packet: add support for eBPF cluster and filter
This patch introduces the ebpf cluster mode. This mode is using
an extended BPF function that is loaded into the kernel and
provide the load balancing.

An example of cluster function is provided in the ebpf
subdirectory and provide ippair load balancing function.
This is a function which uses the same method as
the one used in autofp ippair to provide a symetrical
load balancing based on IP addresses.

A simple filter example allowing to drop IPv6 is added to the
source.

This patch also prepares the infrastructure to be able to load
and use map inside eBPF files. This will be used later for flow
bypass.
7 years ago