Re: [PATCH bpf-next 3/9] samples: bpf: refactor test_cgrp2_sock2 program with libbpf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 18, 2020 at 2:58 PM Martin KaFai Lau <kafai@xxxxxx> wrote:
>
> On Tue, Nov 17, 2020 at 02:56:38PM +0000, Daniel T. Lee wrote:
> [ ... ]
>
> > +     err = bpf_link__pin(link, link_pin_path);
> > +     if (err < 0) {
> > +             printf("err : %d\n", err);
> > +             goto cleanup;
> > +     }
> > +
> > +     ret = EXIT_SUCCESS;
> > +
> > +cleanup:
> > +     if (ret != EXIT_SUCCESS)
> > +             bpf_link__destroy(link);
> This looks wrong.  cleanup should be done regardless.
>

At first, I thought destroying the link after the link__pin might unpin
the link, but I just tested it and confirmed that it actually didn't
and that the link kept pinned.

Thanks for pointing it out! I will stick to this method.

> > +
> > +     bpf_object__close(obj);
> > +     return ret;
> >  }



-- 
Best,
Daniel T. Lee



[Index of Archives]     [Linux Networking Development]     [Fedora Linux Users]     [Linux SCTP]     [DCCP]     [Gimp]     [Yosemite Campsites]

  Powered by Linux