[Patch v2 2/4] veth: implement io_alloc()

Cong Wang xiyou.wangcong at gmail.com
Tue Apr 1 14:03:55 EDT 2014


On Tue, Apr 1, 2014 at 4:54 AM, Thomas Graf <tgraf at suug.ch> wrote:
>
> The case that I wanted to have covered is:
>
> 1. create veth X
> 2. peer Y gets created automatically

refcount of X and Y is 1.

> 3. acquire new ref on Y and push it into a cache or something

refcount of Y becomes to 2.

> 4. original user releases ref on X

refcount of X will be 0, so it will be freed.

> 5. at this point X will get freed if Y doesn't hold a ref

Yeaj, Bbut why Y would be freed since its refcount is still 1 after we put it
in veth_free()?

static void veth_free(struct rtnl_link *link)
{
        struct rtnl_link *peer = rtnl_link_veth_get_peer(link);
        if (peer) {
                link->l_info = NULL;
                peer->l_info = NULL;
                rtnl_link_put(peer);       <====== Here we put Y
        }
}



More information about the libnl mailing list