From 20c6dbec4c40bc972cf39832b91c870a6c5d0607 Mon Sep 17 00:00:00 2001 From: Simon Sundberg Date: Fri, 23 Apr 2021 14:16:52 +0200 Subject: [PATCH] pping: Remove pinning of maps When both BPF programs are kept in the same file, no longer need to pin the maps in order to share them between the programs. Signed-off-by: Simon Sundberg --- pping/pping.c | 19 ++++--------------- pping/pping_kern.c | 2 -- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/pping/pping.c b/pping/pping.c index 41d56d7..f834676 100644 --- a/pping/pping.c +++ b/pping/pping.c @@ -210,15 +210,6 @@ static int set_rlimit(long int lim) return !setrlimit(RLIMIT_MEMLOCK, &rlim) ? 0 : -errno; } -static int bpf_obj_open(struct bpf_object **obj, const char *obj_path, - const char *map_path) -{ - DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts, - .pin_root_path = map_path); - *obj = bpf_object__open_file(obj_path, map_path ? &opts : NULL); - return libbpf_get_error(*obj); -} - static int bpf_obj_run_prog_pindir_func(struct bpf_object *obj, const char *prog_title, const char *pin_dir, @@ -488,8 +479,11 @@ static int load_attach_bpfprogs(struct bpf_object **obj, struct pping_config *config, bool *tc_attached, bool *xdp_attached) { + int err; + // Open and load ELF file - int err = bpf_obj_open(obj, config->object_path, config->pin_dir); + *obj = bpf_object__open(config->object_path); + err = libbpf_get_error(*obj); if (err) { fprintf(stderr, "Failed opening object file %s: %s\n", config->object_path, strerror(-err)); @@ -699,11 +693,6 @@ cleanup: fprintf(stderr, "Failed unpinning tc program from %s: %s\n", config.pin_dir, strerror(-err)); - - err = bpf_object__unpin_maps(obj, NULL); - if (err) - fprintf(stderr, "Failed unpinning maps: %s\n", - strerror(-err)); } return err != 0; diff --git a/pping/pping_kern.c b/pping/pping_kern.c index 179dc9e..735cec0 100644 --- a/pping/pping_kern.c +++ b/pping/pping_kern.c @@ -47,7 +47,6 @@ struct { __type(key, struct packet_id); __type(value, __u64); __uint(max_entries, 16384); - __uint(pinning, LIBBPF_PIN_BY_NAME); } packet_ts SEC(".maps"); struct { @@ -55,7 +54,6 @@ struct { __type(key, struct network_tuple); __type(value, struct flow_state); __uint(max_entries, 16384); - __uint(pinning, LIBBPF_PIN_BY_NAME); } flow_state SEC(".maps"); struct {