# Netmap test program exits with SIGSEGV



## rometoroam (May 9, 2013)

Hi *a*ll,

I am working on Gb packet capture interface development. I was setting up a netmap example and see how it works so that I can use it for my development. I don't know what I am doing wrong but the test code seems very straightforward. Please help me, what am I doing wrong?


```
# uname -i
FreeBSD 9.1
#ifconfig igb1
igb1: flags=c843<UP,BROADCAST,RUNNING,SIMPLEX,LINK2,MULTICAST> metric 0 mtu 1500
	options=401bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,TSO4,VLAN_HWTSO>
	ether XX:15:17:XX:03:X1
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
```

Attached is my test code and debug output.  Any help will be greatly appreciated.

Cheers,
hmehta


----------



## tmw (May 10, 2013)

Hi,

Do you have /dev/netmap? You didn*'*t check whether open function failed and if it failed then you should not continue the program because it may lead your program to segfault


----------



## ta0kira (May 13, 2013)

When you get the segfault, run `bt` in gdb to get a backtrace. If you haven't compiled with -g, then recompile with that flag and run it again. You can also run it with truss to see if any system calls fail.

Kevin Barry


----------



## rometoroam (May 14, 2013)

*steps to make netmap work*

Thanks for the replies guys. Well *I* took some time and prolly probably many changes to make it work.

*The* nm req structure has the requirement that version should be same as NETMAP_API when register*ing the* interface. It needs to be documented somewhere, ideally *I* would like to see this check is implicit and done by *the* kernel internally rather than *by* user*-*supplied arugment argument.
mmap: *I* was not setting *the* MAP_SHARED/MAP_PRIVATE flag. And as mmap was done for PROT_READ and PROT_WRITE *I* have to open /dev/netmap in O_RDWR mode., else mmap failure fails*.*
/dev/netmap attributes: although ideally you should not require to be super user*,* but in some configuration *I* found this an issue. *I am s*till investigating config differences.
Most importantly, ring interface. Netmap doesn't document anywhere that packets are not captured only in one ring but is are load balanced by default. Basically you have to first get information by calling *the* netmap ioctl to get *the* available ring and every time you have to traverse through the ring. *The r*eason is unclear to me. It makes sense if one ring is full and then you move to the next ring but it seems *that* even *if* the ring is not full it starts capturing packet*s* in *an*other ring, so basically you have to poll through *the* ring.

I am looking for some suggestion*. I*s there a way to fix rings for *the* netmap interface, this may help to localize/assign *the* ring/interface. And how did netmap gets *RX* and *TX* ring counts from *the* interface. *W*hen *I* do `ifconfig igb1` *I* don't get *the* number of *HW* rings in *the* interface.

*T*hanks.
hm


----------

