summaryrefslogtreecommitdiff
path: root/ring_rx.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-05-31 11:18:36 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-05-31 11:20:01 +0200
commit2f39b007d5382d01fc424e22b8e1a3681c2bc8cf (patch)
treeb2d7b6bec9932c6bbfec6af8aa016cbd372adf72 /ring_rx.c
parented4e3c64dc80bb775f9ecfdd2165297e34e2fb0c (diff)
ring: implement setup of tpacket v3 ring
Implement ring setup routines and structures for TPACKET_V3. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'ring_rx.c')
-rw-r--r--ring_rx.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ring_rx.c b/ring_rx.c
index fc735cc..a3d8e4d 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -57,6 +57,10 @@ void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size,
sizeof(struct tpacket_req) !=
offsetof(struct tpacket_req3, tp_retire_blk_tov));
+ ring->layout3.tp_retire_blk_tov = 0;
+ ring->layout3.tp_sizeof_priv = 0;
+ ring->layout3.tp_feature_req_word = 0;
+
set_sockopt_tpacket_v3(sock);
} else {
set_sockopt_tpacket_v2(sock);
@@ -68,10 +72,11 @@ void setup_rx_ring_layout(int sock, struct ring *ring, unsigned int size,
void create_rx_ring(int sock, struct ring *ring, int verbose)
{
int ret;
+ bool v3 = get_sockopt_tpacket(sock) == TPACKET_V3;
retry:
- ret = setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->layout,
- sizeof(ring->layout));
+ ret = setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->raw,
+ v3 ? sizeof(ring->layout3) : sizeof(ring->layout));
if (errno == ENOMEM && ring->layout.tp_block_nr > 1) {
ring->layout.tp_block_nr >>= 1;
ring->layout.tp_frame_nr = ring->layout.tp_block_size /
@@ -79,7 +84,6 @@ retry:
ring->layout.tp_block_nr;
goto retry;
}
-
if (ret < 0)
panic("Cannot allocate RX_RING!\n");