git: if_tun: Use pointer to ifnet in tun_softc struct
Sepherosa Ziehau
sepherosa at gmail.com
Thu Jul 19 18:09:07 PDT 2018
Just panic if_com_alloc[type]() fails.
On Thu, Jul 19, 2018 at 5:20 PM, Aaron LI <aly at aaronly.me> wrote:
> On Thu, 19 Jul 2018 17:00:44 +0800
> Sepherosa Ziehau <sepherosa at gmail.com> wrote:
>
>> How about move the following logic into if_alloc():
>>
>> + ifp = sc->tun_ifp = if_alloc(IFT_PPP);
>> + if (ifp == NULL)
>> + /* XXX: should return an error */
>> + panic("%s%d: failed to if_alloc() interface", TUN,
>> minor(dev));
>>
>> i.e. if_alloc never fails.
>
> But the if_alloc() can return NULL if if_com_alloc[type]() fails, so does
> if_alloc() need some work?
>
> On the other hand, the code ported from FreeBSD all uses if_alloc() but
> checks its return value. By making if_alloc() never fail will simplify its
> use.
>
> What do you think on improving the if_alloc()-related code?
>
>
> Cheers,
> --
> Aaron
--
Tomorrow Will Never Die
More information about the Commits
mailing list