summaryrefslogtreecommitdiff
path: root/trafgen.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-05-09 15:46:38 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-05-09 15:46:38 +0200
commit9a40de458b3884d9f526172110392501f075bd87 (patch)
treeff621d506b408a74a0ccea32e5f3f97b5ad0a210 /trafgen.c
parent61a233a283171832a1ac5d580cf9487f9b7aec0a (diff)
ring: Merge common ring_{rx,tx} initialization into own function
Instead of having to perform the individual steps to initialize a ring and open coding them in multiple places, provide convenience functions to do all at once. This has the nice side effect of allowing to make most of these *_{rx,tx}_ring() functions static in their respective module. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen.c')
-rw-r--r--trafgen.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/trafgen.c b/trafgen.c
index 419988e..307d596 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -592,25 +592,16 @@ static void xmit_fastpath_or_die(struct ctx *ctx, int cpu, unsigned long orig_nu
uint8_t *out = NULL;
unsigned int it = 0;
unsigned long num = 1, i = 0;
- size_t size;
+ size_t size = ring_size(ctx->device, ctx->reserve_size);
struct ring tx_ring;
struct frame_map *hdr;
struct timeval start, end, diff;
struct packet_dyn *pktd;
unsigned long long tx_bytes = 0, tx_packets = 0;
- fmemset(&tx_ring, 0, sizeof(tx_ring));
-
- size = ring_size(ctx->device, ctx->reserve_size);
-
set_sock_prio(sock, 512);
- set_packet_loss_discard(sock);
- setup_tx_ring_layout(sock, &tx_ring, size, ctx->jumbo_support);
- create_tx_ring(sock, &tx_ring, ctx->verbose);
- mmap_tx_ring(sock, &tx_ring);
- alloc_tx_ring_frames(sock, &tx_ring);
- bind_tx_ring(sock, &tx_ring, ifindex);
+ ring_tx_setup(&tx_ring, sock, size, ifindex, ctx->jumbo_support, ctx->verbose);
drop_privileges(ctx->enforce, ctx->uid, ctx->gid);