Skip to content

Commit

Permalink
libxdp: Use xdp_multiprog__is_legacy() consistently
Browse files Browse the repository at this point in the history
Internal checks for the is_legacy flag was using a mix of the
xdp_multiprog__is_legacy() getter and just reading the flag directly.
Change all readers to consistently use the accessor function. Modifying the
flag is still done directly.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Feb 3, 2023
1 parent 958f406 commit 05071e5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions lib/libxdp/libxdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ int xdp_program__detach_multi(struct xdp_program **progs, size_t num_progs,
goto out;
}

if (mp->is_legacy) {
if (xdp_multiprog__is_legacy(mp)) {
err = xdp_multiprog__attach(mp, NULL, mode);
goto out;
}
Expand Down Expand Up @@ -1694,7 +1694,7 @@ static int xdp_multiprog__load(struct xdp_multiprog *mp)
char buf[100];
int err = 0;

if (!mp || !mp->main_prog || mp->is_loaded || mp->is_legacy)
if (!mp || !mp->main_prog || mp->is_loaded || xdp_multiprog__is_legacy(mp))
return -EINVAL;

pr_debug("Loading multiprog dispatcher for %d programs\n",
Expand Down Expand Up @@ -1932,7 +1932,7 @@ static int xdp_multiprog__fill_from_fd(struct xdp_multiprog *mp,

mp->main_prog = prog;

if (!mp->is_legacy) {
if (!xdp_multiprog__is_legacy(mp)) {
err = xdp_multiprog__link_pinned_progs(mp);
if (err) {
pr_warn("Unable to read pinned progs: %s\n", strerror(-err));
Expand All @@ -1942,8 +1942,8 @@ static int xdp_multiprog__fill_from_fd(struct xdp_multiprog *mp,
}

pr_debug("Found %s with id %d and %zu component progs\n",
mp->is_legacy ? "legacy program" : "multiprog",
mp->main_prog->prog_id, mp->num_links);
xdp_multiprog__is_legacy(mp) ? "legacy program" : "multiprog",
mp->main_prog->prog_id, mp->num_links);
}

if (hw_fd > 0) {
Expand Down Expand Up @@ -2551,7 +2551,7 @@ static int xdp_multiprog__pin(struct xdp_multiprog *mp)
const char *bpffs_dir;
int err = 0, lock_fd;

if (!mp || mp->is_legacy)
if (!mp || xdp_multiprog__is_legacy(mp))
return -EINVAL;

bpffs_dir = get_bpffs_dir();
Expand Down Expand Up @@ -2635,7 +2635,7 @@ static int xdp_multiprog__unpin(struct xdp_multiprog *mp)
const char *bpffs_dir;
int err = 0, lock_fd;

if (!mp || mp->is_legacy)
if (!mp || xdp_multiprog__is_legacy(mp))
return -EINVAL;

bpffs_dir = get_bpffs_dir();
Expand Down Expand Up @@ -2734,8 +2734,10 @@ static int xdp_multiprog__attach(struct xdp_multiprog *old_mp,
mp->num_links, ifindex,
mode == XDP_MODE_SKB ? " in skb mode" : "");
else
pr_debug("Detached multiprog on ifindex '%d'%s\n",
ifindex, mode == XDP_MODE_SKB ? " in skb mode" : "");
pr_debug("Detached %s on ifindex %d%s\n",
xdp_multiprog__is_legacy(old_mp) ? "program" : "multiprog",
ifindex,
mode == XDP_MODE_SKB ? " in skb mode" : "");

return 0;
err:
Expand All @@ -2760,7 +2762,7 @@ int xdp_multiprog__detach(struct xdp_multiprog *mp)
if (err)
return err;

if (!mp->is_legacy)
if (!xdp_multiprog__is_legacy(mp))
err = xdp_multiprog__unpin(mp);
}
return err;
Expand All @@ -2769,7 +2771,7 @@ int xdp_multiprog__detach(struct xdp_multiprog *mp)
struct xdp_program *xdp_multiprog__next_prog(const struct xdp_program *prog,
const struct xdp_multiprog *mp)
{
if (!mp || mp->is_legacy)
if (!mp || xdp_multiprog__is_legacy(mp))
return NULL;

if (prog)
Expand Down

0 comments on commit 05071e5

Please sign in to comment.