From: Jason Ish Date: Thu, 9 Feb 2023 17:16:18 +0000 (-0600) Subject: source-xdp: only allow busy poll if headers support it X-Git-Tag: suricata-7.0.0-rc2~525 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdd889899fdbf2349b8a50097e6acd0a557d5a04;p=thirdparty%2Fsuricata.git 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 --- diff --git a/src/source-af-xdp.c b/src/source-af-xdp.c index 108cfba791..287a15a997 100644 --- a/src/source-af-xdp.c +++ b/src/source-af-xdp.c @@ -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)