Skip to content

Commit

Permalink
libxdp: fix prog_fd checks for fd >= 0
Browse files Browse the repository at this point in the history
Make sure all checks for whether prog_fd is set checks for >= 0 instead of
just checking the fd as a boolean.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
  • Loading branch information
tohojo committed Dec 9, 2022
1 parent 8afda7a commit dc69919
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/libxdp/libxdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ xdp_program__is_attached(const struct xdp_program *xdp_prog, int ifindex)
int xdp_program__set_chain_call_enabled(struct xdp_program *prog,
unsigned int action, bool enabled)
{
if (!prog || prog->prog_fd || action >= XDP_DISPATCHER_RETVAL)
if (!prog || prog->prog_fd >= 0 || action >= XDP_DISPATCHER_RETVAL)
return -EINVAL;

if (enabled)
Expand Down Expand Up @@ -555,7 +555,7 @@ unsigned int xdp_program__run_prio(const struct xdp_program *prog)

int xdp_program__set_run_prio(struct xdp_program *prog, unsigned int run_prio)
{
if (!prog || prog->prog_fd)
if (!prog || prog->prog_fd >= 0)
return -EINVAL;

prog->run_prio = run_prio;
Expand Down

0 comments on commit dc69919

Please sign in to comment.