[PATCH] veth: grab a reference for rtnl_link_veth_get_peer()

Thomas Haller thaller at redhat.com
Tue Apr 15 04:01:18 PDT 2014


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.


Thomas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fixup-veth-grab-a-reference-for-rtnl_link_veth_get_p.patch
Type: text/x-patch
Size: 1541 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20140415/d7abbbd4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20140415/d7abbbd4/attachment.sig>


More information about the libnl mailing list