source-xdp: only allow busy poll if headers support it

Wrap the enabling of busy poll in a compile time conditional checking
for the required defines to be set. While we have runtime support for
kernels less than 5.11, we also need a compile time check as the headers
may be old as well.

Issue: 5855
pull/8605/head
Jason Ish 3 years ago committed by Victor Julien
parent b734676617
commit bdd889899f

@ -379,9 +379,6 @@ static TmEcode WriteLinuxTunables(AFXDPThreadVars *ptv)
static TmEcode ConfigureBusyPolling(AFXDPThreadVars *ptv)
{
const int fd = xsk_socket__fd(ptv->xsk.xsk);
int sock_opt = 1;
if (!ptv->xsk.enable_busy_poll) {
SCReturnInt(TM_ECODE_OK);
}
@ -395,6 +392,10 @@ static TmEcode ConfigureBusyPolling(AFXDPThreadVars *ptv)
SCReturnInt(TM_ECODE_FAILED);
}
#if defined SO_PREFER_BUSY_POLL && defined SO_BUSY_POLL && defined SO_BUSY_POLL_BUDGET
const int fd = xsk_socket__fd(ptv->xsk.xsk);
int sock_opt = 1;
if (WriteLinuxTunables(ptv) != TM_ECODE_OK) {
SCReturnInt(TM_ECODE_FAILED);
}
@ -414,6 +415,11 @@ static TmEcode ConfigureBusyPolling(AFXDPThreadVars *ptv)
}
SCReturnInt(TM_ECODE_OK);
#else
SCLogWarning(
"Kernel does not support busy poll, upgrade kernel or disable \"enable-busy-poll\".");
SCReturnInt(TM_ECODE_FAILED);
#endif
}
static void AFXDPSwitchState(AFXDPThreadVars *ptv, int state)

Loading…
Cancel
Save