From 1f71a4c2a6c5cf6327db5e8ed2def7b75c6eddf2 Mon Sep 17 00:00:00 2001 From: Brenden Blanco Date: Fri, 26 Feb 2016 15:05:05 -0800 Subject: [PATCH] Add some missing tc act flags and structs Add structs and constants for tca_act_bpf. Generalize the tc_gen macro as a go struct. --- nl/tc_linux.go | 69 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/nl/tc_linux.go b/nl/tc_linux.go index aa59005..c6d85e9 100644 --- a/nl/tc_linux.go +++ b/nl/tc_linux.go @@ -49,6 +49,15 @@ const ( TCAA_MAX = 1 ) +const ( + TCA_ACT_UNSPEC = iota + TCA_ACT_KIND + TCA_ACT_OPTIONS + TCA_ACT_INDEX + TCA_ACT_STATS + TCA_ACT_MAX +) + const ( TCA_PRIO_UNSPEC = iota TCA_PRIO_MQ @@ -69,6 +78,7 @@ const ( SizeofTcHtbGlob = 0x14 SizeofTcU32Key = 0x10 SizeofTcU32Sel = 0x10 // without keys + SizeofTcActBpf = 0x14 SizeofTcMirred = 0x1c SizeofTcPolice = 2*SizeofTcRateSpec + 0x20 ) @@ -533,9 +543,34 @@ const ( TC_ACT_STOLEN = 4 TC_ACT_QUEUED = 5 TC_ACT_REPEAT = 6 + TC_ACT_REDIRECT = 7 TC_ACT_JUMP = 0x10000000 ) +type TcGen struct { + Index uint32 + Capab uint32 + Action int32 + Refcnt int32 + Bindcnt int32 +} + +type TcActBpf struct { + TcGen +} + +func (msg *TcActBpf) Len() int { + return SizeofTcActBpf +} + +func DeserializeTcActBpf(b []byte) *TcActBpf { + return (*TcActBpf)(unsafe.Pointer(&b[0:SizeofTcActBpf][0])) +} + +func (x *TcActBpf) Serialize() []byte { + return (*(*[SizeofTcActBpf]byte)(unsafe.Pointer(x)))[:] +} + // #define tc_gen \ // __u32 index; \ // __u32 capab; \ @@ -549,11 +584,7 @@ const ( // }; type TcMirred struct { - Index uint32 - Capab uint32 - Action int32 - Refcnt int32 - Bindcnt int32 + TcGen Eaction int32 Ifindex uint32 } @@ -625,3 +656,31 @@ const ( TCA_FW_MASK TCA_FW_MAX = TCA_FW_MASK ) + +const ( + TCA_BPF_FLAG_ACT_DIRECT uint32 = 1 << iota +) + +const ( + TCA_BPF_UNSPEC = iota + TCA_BPF_ACT + TCA_BPF_POLICE + TCA_BPF_CLASSID + TCA_BPF_OPS_LEN + TCA_BPF_OPS + TCA_BPF_FD + TCA_BPF_NAME + TCA_BPF_FLAGS + TCA_BPF_MAX = TCA_BPF_FLAGS +) + +const ( + TCA_ACT_BPF_UNSPEC = iota + TCA_ACT_BPF_TM + TCA_ACT_BPF_PARMS + TCA_ACT_BPF_OPS_LEN + TCA_ACT_BPF_OPS + TCA_ACT_BPF_FD + TCA_ACT_BPF_NAME + TCA_ACT_BPF_MAX = TCA_ACT_BPF_NAME +)