mirror of https://github.com/vishvananda/netlink
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.
This commit is contained in:
parent
a8241965b5
commit
2e4a68ee6c
|
@ -0,0 +1 @@
|
|||
.idea/
|
|
@ -240,6 +240,8 @@ type BpfFilter struct {
|
|||
Fd int
|
||||
Name string
|
||||
DirectAction bool
|
||||
Id int
|
||||
Tag string
|
||||
}
|
||||
|
||||
func (filter *BpfFilter) Type() string {
|
||||
|
|
|
@ -3,6 +3,7 @@ package netlink
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
@ -627,6 +628,10 @@ func parseBpfData(filter Filter, data []syscall.NetlinkRouteAttr) (bool, error)
|
|||
if (flags & nl.TCA_BPF_FLAG_ACT_DIRECT) != 0 {
|
||||
bpf.DirectAction = true
|
||||
}
|
||||
case nl.TCA_BPF_ID:
|
||||
bpf.Id = int(native.Uint32(datum.Value[0:4]))
|
||||
case nl.TCA_BPF_TAG:
|
||||
bpf.Tag = hex.EncodeToString(datum.Value[:len(datum.Value)-1])
|
||||
}
|
||||
}
|
||||
return detailed, nil
|
||||
|
|
|
@ -648,7 +648,10 @@ const (
|
|||
TCA_BPF_FD
|
||||
TCA_BPF_NAME
|
||||
TCA_BPF_FLAGS
|
||||
TCA_BPF_MAX = TCA_BPF_FLAGS
|
||||
TCA_BPF_FLAGS_GEN
|
||||
TCA_BPF_TAG
|
||||
TCA_BPF_ID
|
||||
TCA_BPF_MAX = TCA_BPF_ID
|
||||
)
|
||||
|
||||
type TcBpf TcGen
|
||||
|
|
Loading…
Reference in New Issue