From owner-freebsd-current@FreeBSD.ORG Sun Feb 16 10:20:47 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 C456652E; Sun, 16 Feb 2014 10:20:47 +0000 (UTC) Received: from mail-ve0-x22b.google.com (mail-ve0-x22b.google.com [IPv6:2607:f8b0:400c:c01::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6935610D5; Sun, 16 Feb 2014 10:20:47 +0000 (UTC) Received: by mail-ve0-f171.google.com with SMTP id pa12so11080030veb.16 for ; Sun, 16 Feb 2014 02:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=UWOMNdSUzVcvJzrShH40VrAkfigi7ItW6SxBonYib4o=; b=RtcrB4HK3ZwkBUYnKEU+TQ9XbxL1sZdAgdVH0lXc5NBjFu9B88InPadielvSfvOcs7 T2sg9hkRA3yh/egrajpzJ/Y47I5kWATvyvqQKzp4cnfbAiQSkkEv+mpJ7b/3HpzCW9zx 0xD5EGnYV8gBuJRRl8nSikPOC8hD+YMTbubegJA/vteWVU8XGy1Sdi3pEKnH3IvhWlL0 88bs05h4UHCu29uvcG8cGxgw3zSZBPmMuDp9k3GeKPU/Sk8L/mA5O+6UzbfAMz5dafJM D4Z9U+OsaGM1mQFtH0d4pXuxfX8JUoPFaDmHX+1Wy228YJgZe0DoFBLzbuPg0dFRh7G5 GLYA== MIME-Version: 1.0 X-Received: by 10.52.181.199 with SMTP id dy7mr546760vdc.43.1392546046501; Sun, 16 Feb 2014 02:20:46 -0800 (PST) Sender: hiroo.ono@gmail.com Received: by 10.58.210.66 with HTTP; Sun, 16 Feb 2014 02:20:46 -0800 (PST) In-Reply-To: References: <20130812.124834.1287983109881683567.shigeru@iij.ad.jp> <20130813.125709.1168850046133874829.shigeru@iij.ad.jp> Date: Sun, 16 Feb 2014 19:20:46 +0900 X-Google-Sender-Auth: jsm_KLhgj7fEtKP_2Sc1dxQzcX4 Message-ID: Subject: Re: quick hack to support "option VIMAGE" on USB Ethernet From: =?ISO-2022-JP?B?SGlyb28gT25vICgbJEI+LkxuNDJAOBsoQik=?= To: Craig Rodrigues Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-current Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: hiroo.ono+freebsd@gmail.com List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Feb 2014 10:20:47 -0000 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 : > On Mon, Aug 12, 2013 at 8:57 PM, YAMAMOTO Shigeru 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-unsubscribe@freebsd.org"