diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-03-16 16:48:48 +0100 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-03-16 16:48:48 +0100 |
commit | 388180e6c35798d8f1bcadcf5a7010529921304e (patch) | |
tree | faa6e59e7904e00f9e1c449becf57af1a0cb19e2 | |
parent | c5b840ffcaf3eb1e22774bd357c1bcb5cd76a690 (diff) |
ring: check return value of setsockopt
If something screws up, which is rather unlikely, but if it happens,
let the user know.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r-- | ring_rx.c | 9 | ||||
-rw-r--r-- | ring_tx.c | 9 |
2 files changed, 14 insertions, 4 deletions
@@ -21,9 +21,14 @@ void destroy_rx_ring(int sock, struct ring *ring) { + int ret; + fmemset(&ring->layout, 0, sizeof(ring->layout)); - setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->layout, - sizeof(ring->layout)); + + ret = setsockopt(sock, SOL_PACKET, PACKET_RX_RING, &ring->layout, + sizeof(ring->layout)); + if (unlikely(ret)) + panic("Cannot destroy the RX_RING!\n"); munmap(ring->mm_space, ring->mm_len); ring->mm_len = 0; @@ -31,9 +31,14 @@ void set_packet_loss_discard(int sock) void destroy_tx_ring(int sock, struct ring *ring) { + int ret; + fmemset(&ring->layout, 0, sizeof(ring->layout)); - setsockopt(sock, SOL_PACKET, PACKET_TX_RING, &ring->layout, - sizeof(ring->layout)); + + ret = setsockopt(sock, SOL_PACKET, PACKET_TX_RING, &ring->layout, + sizeof(ring->layout)); + if (unlikely(ret)) + panic("Cannot destroy the TX_RING!\n"); munmap(ring->mm_space, ring->mm_len); ring->mm_len = 0; |