mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
samples/bpf: set max locked memory to ulimited
Signed-off-by: William Tu <u9012063@gmail.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
176275a261
commit
eb88d58559
2 changed files with 6 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include "bpf_load.h"
|
#include "bpf_load.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
struct pair {
|
struct pair {
|
||||||
__u64 packets;
|
__u64 packets;
|
||||||
|
@ -13,11 +14,13 @@ struct pair {
|
||||||
|
|
||||||
int main(int ac, char **argv)
|
int main(int ac, char **argv)
|
||||||
{
|
{
|
||||||
|
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
|
||||||
char filename[256];
|
char filename[256];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int i, sock;
|
int i, sock;
|
||||||
|
|
||||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||||
|
setrlimit(RLIMIT_MEMLOCK, &r);
|
||||||
|
|
||||||
if (load_bpf_file(filename)) {
|
if (load_bpf_file(filename)) {
|
||||||
printf("%s", bpf_log_buf);
|
printf("%s", bpf_log_buf);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "bpf_load.h"
|
#include "bpf_load.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
struct flow_keys {
|
struct flow_keys {
|
||||||
__be32 src;
|
__be32 src;
|
||||||
|
@ -23,11 +24,13 @@ struct pair {
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
|
||||||
char filename[256];
|
char filename[256];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int i, sock;
|
int i, sock;
|
||||||
|
|
||||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||||
|
setrlimit(RLIMIT_MEMLOCK, &r);
|
||||||
|
|
||||||
if (load_bpf_file(filename)) {
|
if (load_bpf_file(filename)) {
|
||||||
printf("%s", bpf_log_buf);
|
printf("%s", bpf_log_buf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue