Skip to content

Commit

Permalink
pping: Close bpf_object on shutdown/error
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Sundberg <[email protected]>
  • Loading branch information
simosund committed Sep 5, 2022
1 parent 6d8faa2 commit 2ee87a1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pping/pping.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ static int load_attach_bpfprogs(struct bpf_object **obj,
fprintf(stderr,
"Failed attaching ingress BPF program on interface %s: %s\n",
config->ifname, get_libbpf_strerror(err));
return err;
goto ingress_err;
}

// Attach egress prog
Expand Down Expand Up @@ -935,6 +935,8 @@ static int load_attach_bpfprogs(struct bpf_object **obj,
if (detach_err)
fprintf(stderr, "Failed detaching ingress program from %s: %s\n",
config->ifname, get_libbpf_strerror(detach_err));
ingress_err:
bpf_object__close(*obj);
return err;
}

Expand Down Expand Up @@ -1143,5 +1145,7 @@ int main(int argc, char *argv[])
"Failed removing egress program from interface %s: %s\n",
config.ifname, get_libbpf_strerror(detach_err));

bpf_object__close(obj);

return (err != 0 && keep_running) || detach_err != 0;
}

0 comments on commit 2ee87a1

Please sign in to comment.