You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi lizrice, I'm having some trouble loading xdp_lb. Loading the xdp program to eth0 of the lizrice/ubuntu-ebpf-lb container through the makefile script you provided can run perfectly, but when I load it through the cilium/ebpf library, it can be loaded successfully, and there is debugging information when accessing lb through the client, but Load balancing cannot be achieved. After capturing packets from backend-A/B, I found that there is only the IP information of the data packet from client to lb.
I guess the modification of the destination address and source address was unsuccessful, but judging from the debug information, the modification was successful. Can you help me take a look? The following is the loading code:
package main
import (
"bufio""context""flag""github.com/cilium/ebpf/link""io""log""net""os""os/signal""syscall"
)
// $BPF_CLANG and $BPF_CFLAGS are set by the Makefile.//go:generate go run github.com/cilium/ebpf/cmd/bpf2go -cc $BPF_CLANG -cflags $BPF_CFLAGS bpf lb4.c -- -I../../headers -Ilb4.hvar (
InterfaceNamestring
)
funcinit() {
flag.StringVar(&InterfaceName, "n", "lo", "a network interface name")
}
funcmain() {
flag.Parse()
iflen(InterfaceName) ==0 {
log.Fatalf("Please specify a network interface")
}
// Look up the network interface by name.iface, err:=net.InterfaceByName(InterfaceName)
iferr!=nil {
log.Fatalf("lookup network iface %s: %s", InterfaceName, err)
}
// Load pre-compiled programs into the kernel.objs:=bpfObjects{}
iferr:=loadBpfObjects(&objs, nil); err!=nil {
log.Fatalf("loading objects: %s", err)
}
deferobjs.Close()
// Attach the program.l, err:=link.AttachXDP(link.XDPOptions{
Program: objs.XdpLoadBalancer,
Interface: iface.Index,
})
iferr!=nil {
log.Fatalf("could not attach XDP program: %s", err)
}
deferl.Close()
log.Printf("Attached XDP program to iface %q (index %d)", iface.Name, iface.Index)
log.Printf("Press Ctrl-C to exit and remove the program")
log.Printf("Successfully started! Please run \"sudo cat /sys/kernel/debug/tracing/trace_pipe\" to see output of the BPF programs\n")
// Wait for a signal and close the XDP program,stopper:=make(chan os.Signal, 1)
signal.Notify(stopper, os.Interrupt, syscall.SIGTERM)
cxt, cancel:=context.WithCancel(context.Background())
gofunc(cxt context.Context) {
f, err:=os.Open("/sys/kernel/debug/tracing/trace_pipe")
iferr!=nil {
log.Panicf("open file failed, %v", err)
}
deferf.Close()
r:=bufio.NewReader(f)
for {
select {
case<-cxt.Done():
returndefault:
// ReadLine is a low-level line-reading primitive.// Most callers should use ReadBytes('\n') or ReadString('\n') instead or use a Scanner.bytes, _, err:=r.ReadLine()
iferr==io.EOF {
break
}
iferr!=nil {
panic(err)
}
log.Println(string(bytes))
}
}
}(cxt)
<-stoppercancel()
log.Println("Received signal, exiting XDP program..")
}
Kernel:Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-84-generic x86_64)
Hi lizrice, I'm having some trouble loading xdp_lb. Loading the xdp program to eth0 of the lizrice/ubuntu-ebpf-lb container through the makefile script you provided can run perfectly, but when I load it through the cilium/ebpf library, it can be loaded successfully, and there is debugging information when accessing lb through the client, but Load balancing cannot be achieved. After capturing packets from backend-A/B, I found that there is only the IP information of the data packet from client to lb.
I guess the modification of the destination address and source address was unsuccessful, but judging from the debug information, the modification was successful. Can you help me take a look? The following is the loading code:
Complete project address :https://github.com/Zhouchaowen/ebpf_labs/blob/master/xdp/lb4/main.go
The text was updated successfully, but these errors were encountered: