git: if_tun: Use pointer to ifnet in tun_softc struct

Sepherosa Ziehau sepherosa at gmail.com
Thu Jul 19 02:00:44 PDT 2018


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.


On Thu, Jul 19, 2018 at 4:15 PM, Aaron LI <aly at crater.dragonflybsd.org> wrote:
>
> commit 6f90efb8f9ac6785b04c25efb90c432dcdb142af
> Author: Aaron LI <aly at aaronly.me>
> Date:   Sat Jul 7 23:16:19 2018 +0800
>
>     if_tun: Use pointer to ifnet in tun_softc struct
>
>     Use a pointer to the ifnet struct in the tun_softc struct, instead of
>     embedding a full ifnet struct in it.  (similar to FreeBSD's)
>
>     Use if_alloc() to allocate the ifnet struct.
>
> Summary of changes:
>  sys/net/tun/if_tun.c    | 20 ++++++++++++--------
>  sys/net/tun/if_tunvar.h |  2 +-
>  2 files changed, 13 insertions(+), 9 deletions(-)
>
> http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/6f90efb8f9ac6785b04c25efb90c432dcdb142af
>
>
> --
> DragonFly BSD source repository



-- 
Tomorrow Will Never Die



More information about the Commits mailing list