scroot / gopacket

Automatically exported from code.google.com/p/gopacket
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

PF_RING and gopacket did not work correctly togerther #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello!

I'm correctly installed pf_ring kernel module and it works perfectly (I checked 
it using pf_ring distribution examples).

But I can't work with PF_RING from go because I got error:
./test 
panic: pfring NewRing error: operation not supported

goroutine 1 [running]:
runtime.panic(0x521aa0, 0xc2110712f0)
    /usr/lib/golang/src/pkg/runtime/panic.c:266 +0xb6
main.main()
    /root/tests_pf_ring/test.go:13 +0x8c

goroutine 3 [syscall]:
runtime.goexit()
    /usr/lib/golang/src/pkg/runtime/proc.c:1394

Here I can provide source code:
package main

import "code.google.com/p/gopacket"
import "code.google.com/p/gopacket/layers"
import "code.google.com/p/gopacket/pfring"
import "fmt"

func main() {
 ring, err := pfring.NewRing("eth0", 128, 0)

 if err != nil {
   panic(err)
 }

  packetSource := gopacket.NewPacketSource(ring, layers.LayerTypeEthernet)
     for packet := range packetSource.Packets() {
     //handlePacket(packet)  // Do something with a packet here.
    fmt.Println(packet)
   }

    fmt.Println( "Hello" )
    return
}

My platform:
go version
go version go1.2.2 linux/amd64

Please help me :(

Original issue reported on code.google.com by pavel.odintsov on 14 Jun 2014 at 10:18

GoogleCodeExporter commented 9 years ago
Hey, Pavel,

Thanks for the report!  I'll try to figure this out today and update the issue 
accordingly.

Can you tell me what version of PF_RING you have installed?

  --Graeme

Original comment by gconnell@google.com on 16 Jun 2014 at 4:48

GoogleCodeExporter commented 9 years ago
Hello!

I'm using latest stable version of PF_RING 6.0.1.

Original comment by pavel.odintsov on 16 Jun 2014 at 5:02

GoogleCodeExporter commented 9 years ago
Hello again!

I suppose this bug related with pf_ring_open strange behaviour.

I added this code to my current working project 
(https://github.com/FastVPSEestiOu/fastnetmon):
printf("pf_handle: %p strerror: %s errno: %d\n", pf_ring_descr,
strerror(errno), errno);
pf_ring_descr = pfring_open(dev, snaplen, flags);
printf("pf_handle: %p strerror: %s errno: %d\n", pf_ring_descr,
strerror(errno), errno);

And got very strange  output:
pf_handle: (nil) strerror: Success errno: 0
pf_handle: 0x9d02e0 strerror: Operation not supported errno: 95

In gopacket/pfring code you relayed on errno variable but it consist invalid 
value. Maybe you can check only pf_ring_open() return value and do not check 
errno?

Original comment by pavel.odintsov on 16 Jun 2014 at 6:00

GoogleCodeExporter commented 9 years ago
Hello!

This bug was in PF_RING library, developers approve it and fixed it. It's fixed 
now in svn version. I tried PF_RING version from subversion and all works fine 
for me :)

Original comment by pavel.odintsov on 16 Jun 2014 at 7:24

GoogleCodeExporter commented 9 years ago
Thanks for the update.  Marking as fixed.

Original comment by gconnell@google.com on 16 Jun 2014 at 7:27