Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Feb 2014 17:28:26 -0800
From:      Craig Rodrigues <rodrigc@FreeBSD.org>
To:        hiroo.ono+freebsd@gmail.com
Cc:        freebsd-current Current <freebsd-current@freebsd.org>
Subject:   Re: quick hack to support "option VIMAGE" on USB Ethernet
Message-ID:  <CAG=rPVf4Zfa2xG8aGNzHdtTEM6oCJyqP=SqHfLG6oKV0YM8iAA@mail.gmail.com>
In-Reply-To: <CANtk6SgsMhvN_buqxhkCEAdLFOrwTRdm52_Pw=oG9ak9nHE9SA@mail.gmail.com>
References:  <20130812.124834.1287983109881683567.shigeru@iij.ad.jp> <CAG=rPVcK-pfELCeUhK=EoShvZRsJaBzfW_4w_qM_=npi9zEoMg@mail.gmail.com> <20130813.125709.1168850046133874829.shigeru@iij.ad.jp> <CAG=rPVd2atZXGAHbqNQXBg_wunoj_HP8dRcZZGjTtxCvJsEyaA@mail.gmail.com> <CANtk6SgsMhvN_buqxhkCEAdLFOrwTRdm52_Pw=oG9ak9nHE9SA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Feb 16, 2014 at 2:20 AM, Hiroo Ono (=E5=B0=8F=E9=87=8E=E5=AF=9B=E7=
=94=9F) <
hiroo.ono+freebsd@gmail.com> wrote:

> Hello,
>
> The problem of USB ethernet device with VIMAGE kernel still remains
> with 10.0-RELEASE and I think I have found the reason and a fix.
>
> I have filed a patch and backtrace as a followup to the PR
> http://www.freebsd.org/cgi/query-pr.cgi?pr=3Dkern/183835
>
> I will repeat the explanation here.
> The problem occur when ue_attach_post_task() (in
> sys/dev/usb/net/usb_ethernet.c) is called.
>
> ue_attach_post_task() calls if_alloc() (in sys/net/if.c)
> and ether_attach() (in sys/net/if_ethersubr.c), which finally refer
> V_if_index.
>
> The problem is that curvnet is NULL when ue_attach_post_task()
> is invoked, and with VIMAGE, V_if_index is defined to
>         VNET(if_index)  =3D> VNET_VNET(curvnet, if_index)
>                         =3D> (*VNET_VNET_PTR((curvnet), if_index))
>                         =3D> (*_VNET_PTR((curvnet)->vnet_data_base,
> if_index))
>         and so on.
>
> For device attach, the following code in device_probe_and_attach()
> (in kern/subr_bus.c)
>
>         CURVNET_SET_QUIET(vnet0);
>         error =3D device_attach(dev);
>         CURVNET_RESTORE();
>
> should assign curvnet to vnet0, but it is not the case for ue device.
>
> As an example of USB ethernet device, with if_axe, device_attach(dev)
> is axe_attach() (in sys/dev/usb/net/if_axe.c).
> axe_attach() calls uether_ifattach() (in sys/dev/usb/net/usb_ethernet.c)
> (other USB ethernet devices' *_attach() also call this function),
> which *queues* (not calls) ue_attach_post_task().
> As ue_attach_post_task is called from usb_process (not from
> uther_ifattach),
> it is not assured that curvnet is properly assigned.
>


Well done!  Your analysis of the problem was very good!
I committed the patch, and will MFC in about a week.

--
Craig



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG=rPVf4Zfa2xG8aGNzHdtTEM6oCJyqP=SqHfLG6oKV0YM8iAA>