aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/bpf/bpftool/common.c8
-rw-r--r--tools/bpf/bpftool/main.h2
-rw-r--r--tools/bpf/bpftool/map.c2
-rw-r--r--tools/bpf/bpftool/prog.c2
4 files changed, 14 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 25af85304ebe..1149565be4b1 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -46,6 +46,7 @@
46#include <linux/magic.h> 46#include <linux/magic.h>
47#include <net/if.h> 47#include <net/if.h>
48#include <sys/mount.h> 48#include <sys/mount.h>
49#include <sys/resource.h>
49#include <sys/stat.h> 50#include <sys/stat.h>
50#include <sys/types.h> 51#include <sys/types.h>
51#include <sys/vfs.h> 52#include <sys/vfs.h>
@@ -99,6 +100,13 @@ static bool is_bpffs(char *path)
99 return (unsigned long)st_fs.f_type == BPF_FS_MAGIC; 100 return (unsigned long)st_fs.f_type == BPF_FS_MAGIC;
100} 101}
101 102
103void set_max_rlimit(void)
104{
105 struct rlimit rinf = { RLIM_INFINITY, RLIM_INFINITY };
106
107 setrlimit(RLIMIT_MEMLOCK, &rinf);
108}
109
102static int mnt_bpffs(const char *target, char *buff, size_t bufflen) 110static int mnt_bpffs(const char *target, char *buff, size_t bufflen)
103{ 111{
104 bool bind_done = false; 112 bool bind_done = false;
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index 28322ace2856..14857c273bf6 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -100,6 +100,8 @@ bool is_prefix(const char *pfx, const char *str);
100void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep); 100void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep);
101void usage(void) __noreturn; 101void usage(void) __noreturn;
102 102
103void set_max_rlimit(void);
104
103struct pinned_obj_table { 105struct pinned_obj_table {
104 DECLARE_HASHTABLE(table, 16); 106 DECLARE_HASHTABLE(table, 16);
105}; 107};
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index 7bf38f0e152e..101b8a881225 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -1140,6 +1140,8 @@ static int do_create(int argc, char **argv)
1140 return -1; 1140 return -1;
1141 } 1141 }
1142 1142
1143 set_max_rlimit();
1144
1143 fd = bpf_create_map_xattr(&attr); 1145 fd = bpf_create_map_xattr(&attr);
1144 if (fd < 0) { 1146 if (fd < 0) {
1145 p_err("map create failed: %s", strerror(errno)); 1147 p_err("map create failed: %s", strerror(errno));
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 5302ee282409..b9b84553bec4 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -995,6 +995,8 @@ static int do_load(int argc, char **argv)
995 goto err_close_obj; 995 goto err_close_obj;
996 } 996 }
997 997
998 set_max_rlimit();
999
998 err = bpf_object__load(obj); 1000 err = bpf_object__load(obj);
999 if (err) { 1001 if (err) {
1000 p_err("failed to load object file"); 1002 p_err("failed to load object file");