Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcpreplay fails to open already allocated tap0 device #411

Closed
rmstoi opened this issue Jul 3, 2017 · 7 comments
Closed

tcpreplay fails to open already allocated tap0 device #411

rmstoi opened this issue Jul 3, 2017 · 7 comments
Labels

Comments

@rmstoi
Copy link

rmstoi commented Jul 3, 2017

Hi,

I've been using tcpreplay with the Zephyr Project RTOS
https://github.com/zephyrproject-rtos/zephyr

tcpreplay version 4, provided from the package repositories (Debian, Ubuntu, Fedora) does not work anymore with the TAP interface. The last working version is tcpreplay 3.4.4.

The problem is that tun network device allocation (/dev/net/tun) is done by tunslip6.c in Zephyr net-tools before tcpreplay.

https://github.com/zephyrproject-rtos/net-tools/blob/master/tunslip6.c#L720

So when tcpreplay is ran, it tries to also open tun device and reports:

tcpreplay -i tap0 packet.pcapng

Fatal Error in sendpacket.c:sendpacket_open() line 539:
 failed to open device tap0: Unable to create tuntap interface: tap0

I can workaround this by recompiling tcpreplay with:

./configure --disable-tuntap

but it would be nice if tcpreplay from the package repository works.

Maybe tcpreplay could have a command line option to open /dev/net/tun?
Otherwise it would use already opened device.

Thanks!

@fklassen
Copy link
Member

fklassen commented Jul 3, 2017

Will investigate for next release

@fklassen fklassen added the bug label Jul 3, 2017
@whitequark
Copy link

Simpler workaround: rename the device from tap0 to e.g. xxx0 (or anything that doesn't start with tap).

@fklassen
Copy link
Member

fklassen commented Feb 9, 2018

@whitequark that explains why my testing never found anything wrong. I will keep the default name tap0.

This is legacy code, and we may be better of with it deleted. I'll have a look.

fklassen added a commit that referenced this issue Oct 21, 2018
fklassen added a commit that referenced this issue Oct 21, 2018
@fklassen
Copy link
Member

fixed in PR #504

fklassen added a commit that referenced this issue Oct 23, 2018
* 4.3: (22 commits)
  Bug #418 don't ignore 2nd packet timing
  Bug #411 allow TAP on all platforms
  Bug #174 ensure --with-testnic does not affect replay
  Bug #406 change packet length to network order
  Bug #413 fix manpage typos
  Bug #485 Heap overflow fixed in #484
  Enhancement_#482 update CHANGELOG/CREDITS
  Enhancement_#482 test Makefile merge error fixup
  Enhancement_#482 test Makefile cleanup
  Bug #489 free after memcpy
  Bug #488 heap overflow csum replace4 (#496)
  Bug #486 CVE-2018-17974 realloc memory if packet size increases (#492)
  Enhancement #493 - fixes for Codacy identified issues
  Bug #486 Enforce max snaplen rather than doing realloc
  Bug #486 CVE-2018-17974 realloc memory if packet size increases
  Bug #484 CVE-2018-17582 Check for corrupt PCAP files
  4.3 - revert travis updates from merge
  Simplify plugin Makefiles
  allow out-of-tree build
  Remove dead code
  ...
fklassen added a commit that referenced this issue Oct 23, 2018
…ging

* 4.3: (36 commits)
  Enhancement #506 disable C99 and fix warnings (#507)
  Bug #418 don't ignore 2nd packet timing
  Bug #411 allow TAP on all platforms
  Bug #174 ensure --with-testnic does not affect replay
  Bug #406 change packet length to network order
  Bug #413 fix manpage typos
  Bug #485 Heap overflow fixed in #484
  Enhancement_#482 update CHANGELOG/CREDITS
  Enhancement_#482 test Makefile merge error fixup
  Enhancement_#482 test Makefile cleanup
  Bug #489 free after memcpy
  Bug #488 heap overflow csum replace4 (#496)
  Bug #486 CVE-2018-17974 realloc memory if packet size increases (#492)
  Enhancement #493 - fixes for Codacy identified issues
  Bug #486 Enforce max snaplen rather than doing realloc
  Bug #486 CVE-2018-17974 realloc memory if packet size increases
  Bug #484 CVE-2018-17582 Check for corrupt PCAP files
  4.3 - revert travis updates from merge
  Simplify plugin Makefiles
  allow out-of-tree build
  ...
@jersey99
Copy link

jersey99 commented Apr 8, 2021

@fklassen FYI, I am using 4.3.3-2 and I still had to use @whitequark 's workaround (basically renaming the device)

@fklassen
Copy link
Member

fklassen commented Apr 8, 2021

@fklassen FYI, I am using 4.3.3-2 and I still had to use @whitequark 's workaround (basically renaming the device)

Opened #651 to address. Please fill in system information into this new issue.

fklassen added a commit that referenced this issue Apr 25, 2021
Bug #411 #651 - don't create tap0 if it already exists
@fklassen
Copy link
Member

Fixed in PR #660

fklassen added a commit that referenced this issue Jun 8, 2024
This ioctl error suggests that the tap interface has already been set.

Backed out #411 and #651 as they only partially address the issue and introduced new bugs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants