diff --git a/kf/bpf.go b/kf/bpf.go index ef069a42..30087833 100644 --- a/kf/bpf.go +++ b/kf/bpf.go @@ -13,6 +13,7 @@ import ( "context" "errors" "fmt" + "github.com/cilium/ebpf/link" "io" "net" "net/http" @@ -1142,7 +1143,10 @@ func (b *BPF) LoadXDPRootProgram(ifaceName string, eBPFProgram *BPF) error { return fmt.Errorf("%s:failed to pin the map", rootArrayMapFileName) } - err = AttachXDP(bpfRootProg, iface.Index) + _, err = link.AttachXDP(link.XDPOptions{ + Program: bpfRootProg, + Interface: iface.Index, + }) if err != nil { return fmt.Errorf("could not attach XDP program: %s", err) } diff --git a/kf/kf_unix.go b/kf/kf_unix.go index e05025f3..b3d1d5aa 100644 --- a/kf/kf_unix.go +++ b/kf/kf_unix.go @@ -21,7 +21,6 @@ import ( "github.com/l3af-project/l3afd/models" "github.com/cilium/ebpf" - "github.com/cilium/ebpf/link" "github.com/florianl/go-tc" "github.com/florianl/go-tc/core" "github.com/rs/zerolog/log" @@ -203,16 +202,6 @@ func VerifyNCreateTCDirs() error { return nil } -func AttachXDP(bpfRootProg *ebpf.Program, index int) error { - // Attach the program - _, err := link.AttachXDP(link.XDPOptions{ - Program: bpfRootProg, - Interface: index, - }) - - return err -} - // LoadTCRootProgram - Load and add tc filters func (b *BPF) LoadTCRootProgram(ifaceName, direction string, eBPFProgram *BPF) error { iface, err := net.InterfaceByName(ifaceName) diff --git a/kf/kf_windows.go b/kf/kf_windows.go index 1d02dba1..0e4a2582 100644 --- a/kf/kf_windows.go +++ b/kf/kf_windows.go @@ -11,8 +11,6 @@ import ( "errors" "fmt" "os" - - "github.com/cilium/ebpf" ) // DisableLRO - XDP programs are failing when Large Receive Offload is enabled, to fix this we use to manually disable. @@ -58,11 +56,6 @@ func VerifyNCreateTCDirs() error { return nil } -// AttachXDP - Attach BPF Program -func AttachXDP(bpfRootProg *ebpf.Program, index int) error { - return fmt.Errorf("AttachXDP - Unsupported on windows") -} - // LoadTCRootProgram - not implemented in windows func (b *BPF) LoadTCRootProgram(ifaceName, direction string, eBPFProgram *BPF) error { // not implement nothing todo diff --git a/kf/nfconfig_test.go b/kf/nfconfig_test.go index 57d9dca8..bc90f55b 100644 --- a/kf/nfconfig_test.go +++ b/kf/nfconfig_test.go @@ -24,7 +24,6 @@ var ( hostInterfaces map[string]bool pMon *pCheck mMon *kfMetrics - // val []byte valVerChange *models.BPFPrograms valStatusChange *models.BPFPrograms ingressXDPBpfs map[string]*list.List