Skip to content

Commit

Permalink
Bug #419 CHANGLOG and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Oct 31, 2018
1 parent 4b0aa18 commit e08669d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ src/config.h.in
.*.swp
*.tmproj
*.dirstamp
tcpdump.debug

# Misc files
tcpreplay.spec
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- TCP sequence number edit initial SYN packet should have zero ACK (#450)
- Upgrade libopts to 5.18.12 to address version build issues (#430)
- Add ability to change tcp SEQ/ACK numbers (#425)
- Hang using loop and netmap options (#424)
- Fails to open tap0 on Zephyr (#411)
- CVE-2018-13112 heap-buffer-overflow in get_l2len (#477 dup #408)
- -T flag breaks traffic replay timing (#419)
Expand Down
21 changes: 8 additions & 13 deletions src/send_packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ static void calc_sleep_time(tcpreplay_t *ctx, struct timeval *pkt_time,
sendpacket_t *sp, COUNTER counter, timestamp_t *sent_timestamp,
COUNTER start_us, COUNTER *skip_length);
static void tcpr_sleep(tcpreplay_t *ctx, sendpacket_t *sp _U_,
struct timespec *nap_this_time, struct timeval *now,
tcpreplay_accurate accurate);
struct timespec *nap_this_time, struct timeval *now);
static u_char *get_next_packet(tcpreplay_t *ctx, pcap_t *pcap,
struct pcap_pkthdr *pkthdr,
int file_idx,
Expand Down Expand Up @@ -227,15 +226,13 @@ fast_edit_packet_dl(struct pcap_pkthdr *pkthdr, u_char **pktdata,
dbgx(1, "(%u): final src_ip=0x%08x dst_ip=0x%08x", iteration, src_ip, dst_ip);
}

#if defined HAVE_NETMAP
static inline void wake_send_queues(sendpacket_t *sp, tcpreplay_opt_t *options)
{
#ifdef HAVE_NETMAP
if (options->netmap)
ioctl(sp->handle.fd, NIOCTXSYNC, NULL); /* flush TX buffer */
#endif
}
#endif /* HAVE_NETMAP */

static inline void
fast_edit_packet(struct pcap_pkthdr *pkthdr, u_char **pktdata,
Expand Down Expand Up @@ -629,7 +626,7 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
/*
* we know how long to sleep between sends, now do it.
*/
tcpr_sleep(ctx, sp, &ctx->nap, &now, options->accurate);
tcpr_sleep(ctx, sp, &ctx->nap, &now);
}

#ifdef ENABLE_VERBOSE
Expand Down Expand Up @@ -897,7 +894,7 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
/*
* we know how long to sleep between sends, now do it.
*/
tcpr_sleep(ctx, sp, &ctx->nap, &now, options->accurate);
tcpr_sleep(ctx, sp, &ctx->nap, &now);
}

#ifdef ENABLE_VERBOSE
Expand Down Expand Up @@ -1244,8 +1241,7 @@ static void calc_sleep_time(tcpreplay_t *ctx, struct timeval *pkt_ts_delta,
}

static void tcpr_sleep(tcpreplay_t *ctx, sendpacket_t *sp,
struct timespec *nap_this_time, struct timeval *now,
tcpreplay_accurate accurate)
struct timespec *nap_this_time, struct timeval *now)
{
tcpreplay_opt_t *options = ctx->options;
bool flush =
Expand All @@ -1267,10 +1263,9 @@ static void tcpr_sleep(tcpreplay_t *ctx, sendpacket_t *sp,
options->maxsleep.tv_nsec);
TIMESPEC_SET(nap_this_time, &options->maxsleep);
}
#ifdef HAVE_NETMAP

if (flush)
ioctl(sp->handle.fd, NIOCTXSYNC, NULL); /* flush TX buffer */
#endif /* HAVE_NETMAP */
wake_send_queues(sp, options);

dbgx(2, "Sleeping: " TIMESPEC_FORMAT,
nap_this_time->tv_sec, nap_this_time->tv_nsec);
Expand All @@ -1279,7 +1274,7 @@ static void tcpr_sleep(tcpreplay_t *ctx, sendpacket_t *sp,
* Depending on the accurate method & packet rate computation method
* We have multiple methods of sleeping, pick the right one...
*/
switch (accurate) {
switch (options->accurate) {
#ifdef HAVE_SELECT
case accurate_select:
select_sleep(sp, nap_this_time, now, flush);
Expand All @@ -1301,7 +1296,7 @@ static void tcpr_sleep(tcpreplay_t *ctx, sendpacket_t *sp,
break;

default:
errx(-1, "Unknown timer mode %d", accurate);
errx(-1, "Unknown timer mode %d", options->accurate);
}
}

Expand Down

0 comments on commit e08669d

Please sign in to comment.