From owner-freebsd-current@FreeBSD.ORG Tue Feb 18 01:28:28 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D7E2720F for ; Tue, 18 Feb 2014 01:28:28 +0000 (UTC) Received: from mail-la0-x22a.google.com (mail-la0-x22a.google.com [IPv6:2a00:1450:4010:c03::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4B9A716A9 for ; Tue, 18 Feb 2014 01:28:28 +0000 (UTC) Received: by mail-la0-f42.google.com with SMTP id hr13so11970664lab.29 for ; Mon, 17 Feb 2014 17:28:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=6H0I114bNvlKw7zK/TUrIpbe0fp+znCglw12KhFTXvE=; b=F1NWwYLPGL8hEx3dJgyXuUXTcO3ofQtsIVGmZDpdzwdJNo+i5OxPaPVnxHFBdbW7cs KC1ctjETJ7Tuo1LPnIWHB/ZkRct1lxOjFbxpq9H8Xjo8YGtQ0PTbfldJVe8LHb4R0DHN ZuUyeIYqdsHsgYBi34JcVkgBwW21RBVX5tKSKEl9NZCo/JCweGbjiSQMX8fH6tmCg6GV 7ct88jB2fBTjT/v6lGqKv5GNToYWPoKjzgLtjXgIFr412RycqzX66xr6so3P8G+59Tu5 9AXTuILTtNsMYx9suuTwGiQ4hnV7Y/PKq70ROzSa1PRgSKJWF8K599FJTzJydUzn53vh YlMQ== MIME-Version: 1.0 X-Received: by 10.112.132.131 with SMTP id ou3mr18566144lbb.29.1392686906325; Mon, 17 Feb 2014 17:28:26 -0800 (PST) Sender: crodr001@gmail.com Received: by 10.112.30.211 with HTTP; Mon, 17 Feb 2014 17:28:26 -0800 (PST) In-Reply-To: References: <20130812.124834.1287983109881683567.shigeru@iij.ad.jp> <20130813.125709.1168850046133874829.shigeru@iij.ad.jp> Date: Mon, 17 Feb 2014 17:28:26 -0800 X-Google-Sender-Auth: LE8ubSvlYjlD77WVm5N6ZPTaRQQ Message-ID: Subject: Re: quick hack to support "option VIMAGE" on USB Ethernet From: Craig Rodrigues To: hiroo.ono+freebsd@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.17 Cc: freebsd-current Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Feb 2014 01:28:28 -0000 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