summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChen Yahui <goodluckwillcomesoon@gmail.com>2022-09-16 21:07:57 +0800
committerBeno�t Ganne <bganne@cisco.com>2022-09-28 08:06:01 +0000
commitce668aa3f6b79ca505d1282ee4ba2b3c26fb126c (patch)
treef10a83f222fe04091ded3805fde438b60f3af900 /src
parent76a1d0580a4b05d7908e0b05bf6ceb974703f96d (diff)
af_xdp: change RLIMIT_MEMLOCK before load bpf program
default RLIMIT_MEMLOCK is 64. if we use multi af_xdp interfaces or load complex bpf program, libbpf will return permission error. root cause is default 64 is not large enough. So we change it before load bpf program. Type: fix Change-Id: Ia6aed19c9256c498cf1155586a54a32b3f444105 Signed-off-by: Chen Yahui <goodluckwillcomesoon@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/af_xdp/device.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/plugins/af_xdp/device.c b/src/plugins/af_xdp/device.c
index a571155a707..cccbf69cfdc 100644
--- a/src/plugins/af_xdp/device.c
+++ b/src/plugins/af_xdp/device.c
@@ -21,6 +21,7 @@
#include <linux/ethtool.h>
#include <linux/if_link.h>
#include <linux/sockios.h>
+#include <linux/limits.h>
#include <bpf/libbpf.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
@@ -197,6 +198,12 @@ static int
af_xdp_load_program (af_xdp_create_if_args_t * args, af_xdp_device_t * ad)
{
int fd;
+ struct rlimit r = { RLIM_INFINITY, RLIM_INFINITY };
+
+ if (setrlimit (RLIMIT_MEMLOCK, &r))
+ af_xdp_log (VLIB_LOG_LEVEL_WARNING, ad,
+ "setrlimit(%s) failed: %s (errno %d)", ad->linux_ifname,
+ strerror (errno), errno);
ad->linux_ifindex = if_nametoindex (ad->linux_ifname);
if (!ad->linux_ifindex)