Skip to content

Commit

Permalink
libxdp: Fix check in xdp_program__attach_single()
Browse files Browse the repository at this point in the history
The check added to xdp_program__attach_single() in an earlier patch was
wrong: the bpf object survives after loading a program. Instead, check if
the fd has already been set and use that as an indicator for whether we
should load the program before attaching.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
  • Loading branch information
tohojo committed Dec 9, 2022
1 parent 3d7c22a commit af00429
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libxdp/libxdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ static int xdp_program__attach_single(struct xdp_program *prog, int ifindex,
{
int err;

if (prog->bpf_obj) {
if (prog->prog_fd < 0) {
bpf_program__set_type(prog->bpf_prog, BPF_PROG_TYPE_XDP);
err = xdp_program__load(prog);
if (err)
Expand Down

0 comments on commit af00429

Please sign in to comment.