Commit Graph

4 Commits

Author SHA1 Message Date
Brenden Blanco fadc1088f6 Add support for xdp set/get of a bpf program (#156)
* Add netlink definitions for extra IFLAs
  The relevant IFLA_* are defined in the kernel but not in the syscall
  package.
* Parameterize the return value of loadSimpleBpf
  Allow the return value of the bpf program created by loadSimpleBpf to
  be specified by the caller. Before this, the value was hardcoded to 1.
* Add support for a new IFLA that enables using a bpf program as a
  filter early in the driver path of some NICs.
* Add a test for set/get of an xdp program. Since currently, the XDP
  IFLA is optional, check that the hardware supports it before trying to
  set the field.

Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
2016-08-25 11:08:23 -07:00
Brenden Blanco 809f74071b Fix 32bit warnings in bpf_linux.go
The underlying struct type is still u64 regardless of architecture, but
the local cast should be to uintptr_t to squelch the warning.
2016-03-18 11:13:40 -07:00
Brenden Blanco 719d8ca65a Skip test if bpf syscall is unavailable 2016-02-28 23:52:26 -08:00
Brenden Blanco 6f0327edfd Add BPF TcAction support to U32 filter
Current U32 filter only supports redirect action, but the U32 can
support a lot more. Refactor a bit the action generating/parsing logic
to be more generic and add BPF action support.

When creating a U32 filter, one can supply an array of Actions, which
will be executed by the U32 filter in order:
* The new MirredAction implements the same functionality as RedirIndex
  field in the U32 filter, with that static field kept in the struct for
  backwards compatibility.
* A new BpfAction type is added which allows a program with an open bpf
  file descriptor (implementation is out of scope of this patch) to be
  added as well.

Add a test for the above use case which includes one of each type of
action.
2016-02-28 23:12:34 -08:00