On Sun, Feb 16, 2014 at 2:20 AM, Hiroo Ono (小野寛生) < hiroo.ono+freebsd_at_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=kern/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) => VNET_VNET(curvnet, if_index) > => (*VNET_VNET_PTR((curvnet), if_index)) > => (*_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 = 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. -- CraigReceived on Tue Feb 18 2014 - 00:28:28 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:47 UTC