Skip to content

Commit

Permalink
Only flip IP addr for IPv4 packets
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 18, 2022
1 parent d498778 commit 2fc5b96
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions apps/pkt-gen/pkt-gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,10 @@ ping_body(void *data)
return NULL;
}

if (targ->g->af == AF_INET6) {
D("Warning: ping-pong with IPv6 not supported");
}

bzero(&buckets, sizeof(buckets));
clock_gettime(CLOCK_REALTIME_PRECISE, &last_print);
now = last_print;
Expand Down Expand Up @@ -1504,6 +1508,11 @@ pong_body(void *data)
if (n > 0)
D("understood ponger %llu but don't know how to do it",
(unsigned long long)n);

if (targ->g->af == AF_INET6) {
D("Warning: ping-pong with IPv6 not supported");
}

while (!targ->cancel && (n == 0 || sent < n)) {
uint32_t txhead, txavail;
//#define BUSYWAIT
Expand Down Expand Up @@ -1548,11 +1557,14 @@ pong_body(void *data)
dpkt[4] = spkt[1];
dpkt[5] = spkt[2];
/* swap source and destination IPv4 */
dpkt[13] = spkt[15];
dpkt[14] = spkt[16];
dpkt[15] = spkt[13];
dpkt[16] = spkt[14];
if (ntohs(spkt[6]) & ETHERTYPE_IP) {
dpkt[13] = spkt[15];
dpkt[14] = spkt[16];
dpkt[15] = spkt[13];
dpkt[16] = spkt[14];
}
txring->slot[txhead].len = slot->len;
//dump_payload(dst, slot->len, txring, txhead);
txhead = nm_ring_next(txring, txhead);
txavail--;
sent++;
Expand Down

0 comments on commit 2fc5b96

Please sign in to comment.