Commit Graph

14 Commits

Author SHA1 Message Date
Vishvananda Ishaya Abrams a98f31ffc7 filter pfifo qdiscs in tests 2017-09-05 22:56:13 -07:00
Tobias Klauser b1eba2e916 Fix go vet issues in tests
Fix the following two issues reported by go vet:

  bridge_linux_test.go:41: possible formatting directive in Fatal call
  filter_test.go:204: possible formatting directive in Fatal call

by using Fatalf instead of Fatal when using formatting directives.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-05 07:46:37 -07:00
Taku Fukushima a66e14955d Fix byte order and reference bug of U32 filters
This patch fixes the bug of U32 filters which byte orders are not
appropriately updated based on the endianess of the host. Golang's
range returns copied values instead of their references when it
iterates through a map and the indices should be used to access the
specific value of the map by reference.

This patch also fixes the bug of netlink.FilterAdd that breaks the user
facing model changing  the type of cSel, the copied TcU32Sel, from its
pointer to the struct. Previously the pointer is copied and therefore
the data that is given by the users is modified if the endiannesses of
the fields in it need to be changed.

To validate these changes, I added the validation that the user facing
model is identical before and after netlink.FilterAdd. In addition to
that, the fix for the reference bug enables the endianness validations
in the same test case.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2017-05-15 20:56:34 -07:00
Taku Fukushima 8bf4a3aacd Add advanced u32 match feature support
This patch adds the advanced u32 match feature support with the
selection keys. It enables the users to crate a complex filter as follow
for instance:

  $ tc filter add dev eth0 parent 1: prio 1 u32 match ip dport 80 0xff \
                match u32 0x146ca 0xffff at 32 flowid 1:46cb

To expose TcU32Sel and TcU32Key defined in nl package, this patch copies
them to filte.go and their values that require Big-endianness are
handled appropriately in FilterAdd function in filter_linux.go.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2017-04-07 11:03:16 -07:00
Taku Fukushima 1b53666767 Add class ID parsing to parseU32Data
This patch adds a new switch case that handles the class ID attribute of
the U32 filter data listed by FilterList. Without this case block the
class ID of the U32 filter is always set to zero. The new test
conditions are added to TestFilterAddDel and TestFilterU32BpfAddDel in
filter_test.go as well.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2017-04-05 14:49:35 -07:00
Aithal dedc638a06 Fix compilation errors for non linux platforms.
The go get command and make both fail when executed on
non-linux platforms. Modified it so that there are no
compilation errors when developing in such an
environment.
2017-02-20 12:00:54 -08:00
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
Vish Ishaya 7995ff5647 add generic actions and simplify action type (#129) 2016-05-31 13:03:47 -07:00
Brenden Blanco 719d8ca65a Skip test if bpf syscall is unavailable 2016-02-28 23:52:26 -08:00
Brenden Blanco 17b1e35dbc Add clsact and bpf filter support
New in kernel 4.5 is a type of qdisc for lightweight (no qdisc lock)
ingress/egress parsing, called clsact. Add support for such a qdisc
type.

One primary consumer of clsact is the bpf filter, add support for that
as well.
2016-02-28 23:20:29 -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
chantra b1536bf12c Address comments
* fix package import order
* use int instead of int32 for Filter FW Attrs
2015-10-04 22:34:06 -07:00
chantra 824d7a16e5 Add FW filter support 2015-09-18 18:51:33 -07:00
Vishvananda Ishaya acc8a28738 Add basic support for redirect filter 2015-08-19 16:02:04 -07:00