diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-05-31 12:11:09 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-05-31 12:11:09 +0200 |
commit | cacb34f95fb7937e81b1fe8add7b5dca91e3a4c5 (patch) | |
tree | 607d72816c4d810050996f37f2acef583757cd8b /ring_rx.c | |
parent | 0f765f49ac231d99f493f00c0f0986fbeff2615d (diff) |
ring: setup frame structure for v2/v3 in a generic way
Prepare TPACKET_V3 for allowing to transparently setting up the
frame structure such that we do not need to change much in the
netsniff-ng/trafgen code.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'ring_rx.c')
-rw-r--r-- | ring_rx.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -104,9 +104,21 @@ void mmap_rx_ring(int sock, struct ring *ring) mmap_ring_generic(sock, ring); } -void alloc_rx_ring_frames(struct ring *ring) +void alloc_rx_ring_frames(int sock, struct ring *ring) { - alloc_ring_frames_generic(ring); + int num; + size_t size; + bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3; + + if (v3) { + num = ring->layout3.tp_block_nr; + size = ring->layout3.tp_block_size; + } else { + num = ring->layout.tp_frame_nr; + size = ring->layout.tp_frame_size; + } + + alloc_ring_frames_generic(ring, num, size); } void bind_rx_ring(int sock, struct ring *ring, int ifindex) |