> On 25 Jun 2020, at 11:55, Martin Pieuchot <[email protected]> wrote:
> 
> On 24/06/20(Wed) 17:10, Vitaliy Makkoveev wrote:
>> While `mbuf' enqueued to `pipexinq' or `pipexoutq' it has the reference
>> to corresponding pipex(4) session as `ph_cookie'. `ph_cookie' is
>> accessed by pipexintr() and it's always defferent context from context
>> where we destroy session. `ph_cookie' is protected only while we destroy
>> session by pipex_timer() but this protection is not effective. While we
>> destroy session related to pppx(4) `ph_cookie' is not potected. While we
>> destroy session related to pppac(4) by `PIPEXSMODE' ioctl() or by
>> closing pppac(4) device node `ph_cookie' is also not protected.
>> 
>> I'am going to use reference counters to protect `ph_cookie' but some
>> additional steps required to be done.
> 
> Please no.  Store an ifidx in session instead of a pointer.  Such
> index are guaranteed to be unique and can be used with if_get(9).

This means I should do if_get(9) before each `ifnet’ usage. Also I
should do checks and introduce error path. It's ugly.

Alternatively, I can pass `ifnet->if_index’ instead of `ifnet’ to
sessinon being linked and store obtained reference up to session
destruction. I should add one error path to pipex_link_session().
It’s ugly but a little bit.

> 
> We deliberately kept if_ref() private to keep the code base coherent.

Could you explain please why if_ref() and if_get() are incoherent? 

Reply via email to