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.

2013-08-14 4:08 GMT+09:00 Craig Rodrigues <rodr...@freebsd.org>:
> On Mon, Aug 12, 2013 at 8:57 PM, YAMAMOTO Shigeru <shig...@iij.ad.jp> wrote:
>
>>
>> My try is,
>> 1) I try to enable "option VIMAGE" at r254236@HEAD.
>> It causes panic at accessing V_if_index in ifindex_alloc_locked().
>>
>
> Can you provide the kernel backtrace for this panic?
> It would be interesting to see where we need to initialize currvnet for USB
> Ethernet.
> I thought we already handled that case in subr_bus.c
>
> --
> Craig
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to