[Patch v2 2/4] veth: implement io_alloc()
Cong Wang
xiyou.wangcong at gmail.com
Mon Mar 31 19:49:43 EDT 2014
On Mon, Mar 31, 2014 at 12:11 PM, Cong Wang <xiyou.wangcong at gmail.com> wrote:
> On Mon, Mar 31, 2014 at 4:04 AM, Thomas Graf <tgraf at suug.ch> wrote:
>> On 03/28/14 at 06:08pm, Cong Wang wrote:
>>> + return -NLE_NOMEM;
>>> + }
>>> +
>>> + peer->l_info = link;
>>
>> You need to acquire a refcnt to link to make sure link is
>> not freed while you hold that reference.
>>
>> nl_object_get(OBJ_CAST(link));
>> peer->l_info = link;
>>
>> And then release it again in io_free
>>
>
> Yeah, will do.
Hmm, thinking a bit more, I think we probably we don't need
a hold a reference here, because no matter we free link from
either link or its peer, it will free the ->l_info struct together.
IOW, they share the same life time thus their refcounts are
always same.
I tried to grab a reference here, but it's hard to make it working
correctly.
What do you think?
More information about the libnl
mailing list