On 23/02/18(Fri) 04:08, Henning Brauer wrote: > * Martin Pieuchot <m...@openbsd.org> [2018-02-21 09:37]: > > On 21/02/18(Wed) 02:37, Henning Brauer wrote: > > I'd suggest moving the pool allocation and the function in net/pf*.c > > and only have a function call under #if NPF > 0. > > worth discussing, but imo that part doesn't really have all that much > to do with pf.
It is only used by pf(4). All the code is under #if NPF > 0, so it *is* related to PF. We have been reducing the #ifdef maze through the years for maintainability reasons. I don't see the point for reintroducing them for taste. > > I'd suggest defining your own structure containing a timeout and a mbuf > > pointer instead of abusing ph_cookie. Since you're already allocating > > something it doesn't matter much and you're code won't be broken by > > a future refactoring. > > dlg pointed me to ph_cookie, I was about to use my own structure. > "ph_cookie is for exactly that" ph_cookie is not for that. ph_cookie is a left-over because the wifi stack abused `rcvif' to attach a node to management frames. The problem about using ph_cookie all over the place is that you don't know who owns it. Is it the driver like in wireless case? Is it pf(4) like in your case? Is it a subsystem like in pipex case? If you can easily avoid using ph_cookie, then please do it. Otherwise you're putting maintenance burden by writing fragile code that will subtly break when somebody will start using ph_cookie for something else.