What's the proper way to multithread gonetmap?
I tried several ways to multithread gonetmap but it doesn't work
for ringIndex := uint32(0); ringIndex < iface.Nif.RxRings+1; ringIndex++ {
ring := iface.GetRing(ringIndex, gonetmap.RX)
go pollingWorker(iface, ring, 1000) // polling specific ring with processRing(ring)
}
for i := uint32(0); i < 8; i++ {
ring := iface.GetRing(ringIndex, gonetmap.RX)
go pollingWorker(iface, 1000) // a loop create ring and use processRing(ring)
}
It's always fail with
ens192 RX0: fail 'cur < head || cur > kring->nr_hwtail' h 47 c 43 t 47 rh 47 rc 43 rt 47
hc 43 ht 47
Seems like different goroutines change cur/head.
Hi, @ntcong ! Thank you for your interest in my project and I apologize for the long answer.
You should not use any synchronization primitives, which means sharing nothing between goroutines. And for what purpose did you need multithreading?
Hi. I'm trying to process a large number of packet, mostly when the server under heavy traffic like DDOS. With only 1 core there's a lot of packet dropping. This is what I did before I switched to nff-go. In case someone wants to do multiprocessing with gonetmap
for ringIndex := uint32(0); ringIndex < uint32(*numRingWorker); ringIndex++ {
netmap := gonetmap.New()
req0 := gonetmap.Request{Version: 14, RingId: uint16(ringIndex), Flags: gonetmap.ReqOneNic, Arg1: 0}
req0.SetName(*ifname)
iface, _ := netmap.RegIf(&req0)
ring := iface.GetRing(ringIndex, gonetmap.RX)
go pollingWorkerRing(iface, ring, 1000)
}