[PATCH] veth: grab a reference for rtnl_link_veth_get_peer()
Thomas Graf
tgraf at suug.ch
Tue Apr 15 07:16:49 PDT 2014
On 04/15/14 at 01:01pm, Thomas Haller wrote:
> On Mon, 2014-04-14 at 18:39 -0700, Cong Wang wrote:
> > Signed-off-by: Cong Wang <xiyou.wangcong at gmail.com>
> > ---
> > lib/route/link/veth.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/route/link/veth.c b/lib/route/link/veth.c
> > index 19c84f8..3b6a89c 100644
> > --- a/lib/route/link/veth.c
> > +++ b/lib/route/link/veth.c
> > @@ -232,6 +232,7 @@ struct rtnl_link *rtnl_link_veth_alloc(void)
> > struct rtnl_link *rtnl_link_veth_get_peer(struct rtnl_link *link)
> > {
> > IS_VETH_LINK_ASSERT(link);
> > + nl_object_get(OBJ_CAST(link->l_info));
>
> rtnl_link_get(link->l_info); ?
>
>
> > return link->l_info;
> > }
> >
>
>
> I think, with this change rtnl_link_veth_add() and
> tests/test-create-veth.c now leaks a reference.
>
>
> This is a behavioral change since libnl3.2.24, but I think it is the
> right thing to do also because it's quite new and probably not used much
> yet(?).
>
> But could you add a "capability" to indicate that rtnl_link_veth_alloc()
> now gets an additional reference? Something like the attached patch (but
> maybe with a better name :) ). So in principle callers could handle it
> properly and workaround it.
I agree. This is absolutely the right thing to do.
More information about the libnl
mailing list