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

[Bug] pps invalid value exception #632

Closed
idogoshen opened this issue Feb 23, 2021 · 3 comments
Closed

[Bug] pps invalid value exception #632

idogoshen opened this issue Feb 23, 2021 · 3 comments
Assignees
Labels

Comments

@idogoshen
Copy link
Contributor

idogoshen commented Feb 23, 2021

If pps option with non numerical value is used than tcpreplay crash on "Floating point exception"

cgs@idog-ubuntu:~/workspace/tcpreplay$ src/tcpreplay -i docker0 --pps "abc" tcp.pcap 
Warning: May need to run as root to get access to all network interfaces.
Floating point exception (core dumped)

core dump

cgs@idog-ubuntu:~/workspace/tcpreplay$ gdb src/tcpreplay core 
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from src/tcpreplay...done.
[New LWP 16760]
Core was generated by src/tcpreplay -i docker0 --pps abc tcp.pcap'.
Program terminated with signal SIGFPE, Arithmetic exception.
#0  calc_sleep_time (ctx=ctx@entry=0x5634a86aa260, pkt_ts_delta=pkt_ts_delta@entry=0x5634a86aab18, time_delta=time_delta@entry=0x5634a86aaaf8, len=len@entry=74, 
    sp=sp@entry=0x5634a86b9550, counter=counter@entry=2, sent_timestamp=0x5634a86aab08, start_us=1614078095685734, skip_length=0x7ffcca519888) at send_packets.c:1215
1215	             COUNTER next_tx_us = (pkts_sent * 1000000) * (60 * 60) / pph;
(gdb) bt
#0  calc_sleep_time (ctx=ctx@entry=0x5634a86aa260, pkt_ts_delta=pkt_ts_delta@entry=0x5634a86aab18, time_delta=time_delta@entry=0x5634a86aaaf8, len=len@entry=74, 
    sp=sp@entry=0x5634a86b9550, counter=counter@entry=2, sent_timestamp=0x5634a86aab08, start_us=1614078095685734, skip_length=0x7ffcca519888) at send_packets.c:1215
#1  0x00005634a64926b8 in send_packets (ctx=ctx@entry=0x5634a86aa260, pcap=pcap@entry=0x5634a86baf90, idx=idx@entry=0) at send_packets.c:616
#2  0x00005634a6495c46 in replay_file (idx=0, ctx=0x5634a86aa260) at replay.c:182
#3  tcpr_replay_index (ctx=ctx@entry=0x5634a86aa260) at replay.c:59
#4  0x00005634a6495130 in tcpreplay_replay (ctx=0x5634a86aa260) at tcpreplay_api.c:1136
#5  0x00005634a648fd35 in main (argc=1, argv=<optimized out>) at tcpreplay.c:139

divide by 0 in send_packet.c calc_sleep_time()
COUNTER next_tx_us = (pkts_sent * 1000000) * (60 * 60) / pph;

idogoshen added a commit to idogoshen/tcpreplay that referenced this issue Feb 23, 2021
@fklassen fklassen self-assigned this Feb 24, 2021
@fklassen fklassen added the bug label Feb 24, 2021
@fklassen
Copy link
Member

Thanks for the stack trace. I should be able to fix this from detail provided, but it would be helpful to understand the environment. Is this docker?

Please fill in a bug report.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
1.
2.
3.
4.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

System (please complete the following information):

  • OS: [e.g. macOS]
  • OS version
  • Tcpreplay Version [e.g. 4.3.2]

Additional context
Add any other context about the problem here.

@idogoshen
Copy link
Contributor Author

The environment is Ubuntu 18.04.3 LTS but the bug is not environment dependent.
The example above uses docker0 interface but it just the same with eth0, lo, etc.
Just use --pps option with non numeric value (e.g. --pps "xyz" )

I've posted optional patch - see pull request #633

Describe the bug
Using --pps option with invalid value of 0 or non numeric value causes Floating point exception (divide by 0) crash

To Reproduce
Steps to reproduce the behavior:

tcpreplay -i lo --pps "xyz" tcp.pcap
Warning: Unsupported physical layer type 0x0304 on lo.  Maybe it works, maybe it won't.  See tickets #123/318
Floating point exception

Expected behavior
tcpreplay should not crash
should validate the input and provide error feedback
e.g. "tcpreplay error: 'xyz' is not a recognizable number."

System (please complete the following information):

cgs@idog-ubuntu:~/workspace/tcpreplay$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic

Tcpreplay Version 4.2.6

cgs@idog-ubuntu:~$ /usr/bin/tcpreplay -V
Warning in interface.c:get_interface_list() line 94:
May need to run as root to get access to all network interfaces.
tcpreplay version: 4.2.6 (build git:v4.2.6) (debug)
Copyright 2013-2017 by Fred Klassen <tcpreplay at appneta dot com> - AppNeta
Copyright 2000-2012 by Aaron Turner <aturner at synfin dot net>
The entire Tcpreplay Suite is licensed under the GPLv3
Cache file supported: 04
Not compiled with libdnet.
Compiled against libpcap: 1.8.1
64 bit packet counters: enabled
Verbose printing via tcpdump: enabled
Packet editing: disabled
Fragroute engine: disabled
Injection method: PF_PACKET send()
Not compiled with netmap

cgs@idog-ubuntu:~$ /usr/bin/tcpreplay -i lo --pps xyz tcp.pcap 
Warning in interface.c:get_interface_list() line 94:
May need to run as root to get access to all network interfaces.
Warning in sendpacket.c:sendpacket_open_pf() line 936:
Unsupported physical layer type 0x0304 on lo.  Maybe it works, maybe it won't.  See tickets #123/318
Floating point exception (core dumped)

Still exists in frontline 4.3.3

cgs@idog-ubuntu:~/workspace/tcpreplay$ src/tcpreplay -V 2>&1 | grep version
tcpreplay version: 4.3.3 (build git:v4.3.3-3-g72dcf55e)

cgs@idog-ubuntu:~/workspace/tcpreplay$ src/tcpreplay -i lo --pps xyz tcp.pcap 
Warning: May need to run as root to get access to all network interfaces.
Warning: Unsupported physical layer type 0x0304 on lo.  Maybe it works, maybe it won't.  See tickets #123/318
Floating point exception (core dumped)

@fklassen
Copy link
Member

Fixed in PR #633

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

2 participants