nfq: set some options on netlink socket

This patch modify nfq system to set some options on the netlink socket.
This should improve performances by handling more correctly capacity
overrun.
remotes/origin/master-1.1.x
Eric Leblond 14 years ago committed by Victor Julien
parent 0e8b041151
commit f73c60b4ff

@ -227,6 +227,7 @@ TmEcode NFQInitThread(NFQThreadVars *nfq_t, uint16_t queue_num, uint32_t queue_m
{
#ifndef OS_WIN32
struct timeval tv;
int opt;
#endif
nfq_t->queue_num = queue_num;
@ -306,6 +307,19 @@ TmEcode NFQInitThread(NFQThreadVars *nfq_t, uint16_t queue_num, uint32_t queue_m
nfq_t->nh = nfq_nfnlh(nfq_t->h);
nfq_t->fd = nfnl_fd(nfq_t->nh);
/* Set some netlink specific option on the socket to increase
performance */
opt = 1;
#ifdef NETLINK_BROADCAST_SEND_ERROR
setsockopt(nfq_t->fd, SOL_NETLINK,
NETLINK_BROADCAST_SEND_ERROR, &opt, sizeof(int));
#endif
/* Don't send error about no buffer space available but drop the
packets instead */
#ifdef NETLINK_NO_ENOBUFS
setsockopt(nfq_t->fd, SOL_NETLINK, NETLINK_NO_ENOBUFS, &opt, sizeof(int));
#endif
/* set a timeout to the socket so we can check for a signal
* in case we don't get packets for a longer period. */
tv.tv_sec = 1;

Loading…
Cancel
Save