Commit Graph

27 Commits

Author SHA1 Message Date
Ivan Kolodyazhny
05506ada9f Implement filter goto action support 2023-01-30 09:12:08 -08:00
Ivan Kolodyazhny
378a404a26 Implement chains support
This patch implements both tc and filter chains.

We also need to align tc filter delition implementation
with iprote2 to delete filters withichain by passing
additional bits during filter deletion call.
2022-12-14 10:59:49 -08:00
chengzhycn
d3b8a16e9b add actions support for fwfilter
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
2022-10-27 09:19:20 -07:00
chengzhycn
8baf7b0c69 add support for skbedit mask 2022-10-26 18:47:10 -07:00
Nicholas Hollett
5cb84e47ad filter: Add support for the csum action in u32
This patch adds support for the U32 action that can force a csum
recalculation in different layers of a packet.
2022-03-29 10:02:56 -07:00
Wu Zongyong
9ada19101f filter: add support for police action
This patch adds support for tc police action. And codes of fw filter
have been refactored with the police action for reducing redundant
codes.

Signed-off-by: Wu Zongyong <wuzongyong@linux.alibaba.com>
2021-11-29 08:39:51 -08:00
tanbangcheng
06362a6c16 Add DestPort to TunnelKeyAction
Fix parsing of TCA_TUNNEL_KEY_ENC_IPV6_SRC & TCA_TUNNEL_KEY_ENC_IPV6_DST
2020-09-24 21:30:07 -04:00
Zhiyuan Hou
ed8931371a filter, action: Add support for skbedit
Signed-off-by: Zhiyuan Hou <zhiyuan2048@linux.alibaba.com>
2019-12-17 09:15:28 -08:00
Zhiyuan Hou
e25c252266 filter, action: Add support for tunnel_key
Signed-off-by: Zhiyuan Hou <zhiyuan2048@linux.alibaba.com>
2019-12-03 14:07:18 -08:00
Farid Zakaria
2e4a68ee6c Add support for additional TC BPF filter attributes
In order to support BPF_SYSCALL `PROG_GET_FD_BY_ID` -- the ID of the
eBPF must be available.

Add the additional enumerations and handle them when parsing the BPF
filter.
2019-07-01 11:37:39 -07:00
Krister Johansen
00009fb860 Add support for TC_ACT_CONNMARK
Implements the connmark action described in tc-connmark(8)

Signed-off-by: Krister Johansen <krister.johansen@oracle.com>
2019-05-22 08:35:24 -07:00
Taku Fukushima
2bc5004800 Replace redundant copied u32 types with type aliases
This patch replaces TcU32Sel and TcU32Key that are copied from nl
package with type aliases for the original types. This eliminates the
usages of unsafe packages and redundant copied structs that are
identical to the original ones.

Type aliases are newly introduced in Go 1.9 and it is not backward
compatibile. Therefore this patch shall be merged only if the project is
entirely migrated to Go 1.9. Currently we are building this project
with Go 1.10 and Go 1.11, so it is reasonable to require Go version
greater than 1.9.

See #206 and #261, which is the previous life of this patch.

This patch also moves TcU32Sel, TcU32Key and U32 structs from filter.go
to filter_linux.go to make it possible to build on macOS. See #243 for
more details.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2018-12-16 11:33:25 -08:00
Taku Fukushima
dc00cf9d5c Add Hash to U32
This patch adds "Hash" attribute that represents the ID of the hash
table with which the filter is associated to U32 struct. If the hash
table is not created yet, a new hash table is created with the
specified ID.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2018-04-19 09:01:18 -07:00
Taku Fukushima
23a36f223d Add Divisor to U32
This patch adds "Divisor" attribute that represents the divisor of the
hash table buckets to U32 struct.

With "Divisor" attribute, only a hash table without its associated
filters can be created. This new capability allows users to construct
the more flexible filter configurations with the hash table that has
the divisor greater than 1, for instance.

Although a hash table is created through the same interfaces as the
filters, it cannot be listed or deleted though the same interfaces as
the filters at this moment. Only real filters can be listed with
FilterList and deleted with FilterDel.

Signed-off-by: Taku Fukushima <taku@soracom.jp>
2018-04-19 09:01:18 -07:00
Sargun Dhillon
1882fa99fc Add Matchall filter 2018-01-05 09:42:30 -08:00
Ian Bishop
0e3b74dbe2 replace syscall with golang.org/x/sys/unix 2017-10-26 09:45:08 -07:00
Trevor Rosen
177f1ceba5 Move consts to Linux-specific file
Fixes #243
2017-09-24 11:05:54 -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
Alexander Morozov
63381f39fc filter: fix recursive string call (#162)
Signed-off-by: Alexander Morozov <lk4d4math@gmail.com>
2016-08-25 11:08:35 -07:00
Vish Ishaya
0bc457d244 fix darwin build by moving code (#138)
Fixes issue #135
2016-06-15 08:44:14 -07:00
Vish Ishaya
7995ff5647 add generic actions and simplify action type (#129) 2016-05-31 13:03:47 -07:00
Vishvananda Ishaya
adb0f53af6 Cleanup from golint and go vet 2016-03-19 17:12:26 -07: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