Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Feb 2011 13:07:19 +0100
From:      Monthadar Al Jaberi <monthadar@gmail.com>
To:        "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>
Cc:        FreeBSD virtualization mailing list <freebsd-virtualization@freebsd.org>
Subject:   Re: simulating wireless device (if_alloc panic, VirtualBox, VIMAGE)
Message-ID:  <AANLkTinuAt37kz=h9tXJBOKUZTaZBQhDx-LMqh_Pmjq2@mail.gmail.com>
In-Reply-To: <20110203111206.S80258@maildrop.int.zabbadoz.net>
References:  <AANLkTik8D_bLwcUKZdBT-kpkJdDXtPTLvAqfUe0cLoSz@mail.gmail.com> <4D484213.6050100@freebsd.org> <AANLkTikJKZLQVA5X2PQs0oT4iFsZYBw7K07kjQTc9iGD@mail.gmail.com> <4D486108.5060805@freebsd.org> <AANLkTi=mk2vfyXJBaK5mV2sBWEj0-RDZneLs%2BXq_c7sb@mail.gmail.com> <20110202164827.I80258@maildrop.int.zabbadoz.net> <4D4994CE.2090209@freebsd.org> <AANLkTimDZRefv57_nanxGUbHjP1wqeQ41iWHvpXogmvU@mail.gmail.com> <4D49AB29.7070909@freebsd.org> <AANLkTinONnLE9D=c57nQmGBFbWJgqJmeKiRViW3gga2a@mail.gmail.com> <20110203095019.N80258@maildrop.int.zabbadoz.net> <AANLkTinY0AVSsEE5PZaJOqyuinsAN6wkUL9URAqYs0X4@mail.gmail.com> <20110203105747.K80258@maildrop.int.zabbadoz.net> <AANLkTi==53twyjoHL3uc4EQJCkMWdxuc9cvTNJSVuDuy@mail.gmail.com> <20110203111206.S80258@maildrop.int.zabbadoz.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Feb 3, 2011 at 12:18 PM, Bjoern A. Zeeb
<bzeeb-lists@lists.zabbadoz.net> wrote:
> On Thu, 3 Feb 2011, Monthadar Al Jaberi wrote:
>
>> On Thu, Feb 3, 2011 at 11:59 AM, Bjoern A. Zeeb
>> <bzeeb-lists@lists.zabbadoz.net> wrote:
>>>
>>> On Thu, 3 Feb 2011, Monthadar Al Jaberi wrote:
>>>
>>>>>>> I don't understand why you saw a CRED_TO_VNET of 0
>>>>>>> I was under the impression that every process/thread in the system
>>>>>>> would
>>>>>>> be
>>>>>>> on vnet0
>>>>>>> in a vimage kernel.
>>>>>>
>>>>>> This is how my printf looks like:
>>>>>> struct thread *td =3D curthread;
>>>>>> struct vnet *v =3D TD_TO_VNET(td);
>>>>>> struct ucred *cred =3D CRED_TO_VNET(td->ucred);
>>>>>> struct vnet *td_vnet =3D td->td_vnet;
>>>>>
>>>>> here's your problem:
>>>>>
>>>>> strcut vnet *vnet =3D cred->cr_prison->pr_vnet;
>>>>
>>>> When I add CURVNET_SET(CRED_TO_VNET(curthread->td_ucred)); I get a pan=
ic
>>>> too...
>>>> But your suggestion works if I do like this:
>>>> curthread->td_vnet =3D curthread->td_ucred->cr_prison->pr_vnet;
>>>>
>>>> CRED_TO_VNET(curthread->td_ucred) returns NULL
>>>
>>> I wonder how you are building your module and if VIMAGE is properly
>>> defined. =A0If it's not that would explain a lot of things.
>>
>> I have put options VIMAGE, rebuild both world and kernel.
>>
>> I can create jails with vnet options...
>>
>> I build my module with the standard Makefile for modules:
>> ...
>> KMOD =A0 =A0=3D =A0wtap
>> ...
>> SRCS =A0 =A0=3D =A0if_wtap_module.c if_wtap.c if_medium.c hal.c
>>
>> .include <bsd.kmod.mk>
>
> Right but are you building your module along with the kernel or
> outside the tree? =A0In the latter case you may want to add soemthing
> like
>
> SRCS+=3D =A0 =A0 =A0 =A0 =A0opt_global.h
>
> .if defined(KERNBUILDDIR)
> MKDEP=3D =A0 =A0 =A0 =A0 =A0-include ${KERNBUILDDIR}/opt_global.h
> .else
> CFLAGS+=3D =A0 =A0 =A0 =A0-include opt_global.h
> MKDEP=3D =A0 =A0 =A0 =A0 =A0-include opt_global.h
>
> opt_global.h:
> =A0 =A0 =A0 =A0echo "#define VIMAGE 1" > ${.TARGET}
> .endif
>
> and/or point KERNBUILDDIR to where you built your kernels.

Thanks it works now..

>
>
>>>
>>>
>>>>>> printf("td=3D%p, td->td_vnet=3D%p, td->td_ucred=3D%p, TD_TO_VNET=3D%=
p,
>>>>>> CRED_TO_VNET=3D%p\n", td, td_vnet, td->td_ucred, v, cred);
>>>>>>
>>>>>> I made a fast search in /usr/src for "td_vnet" and found it was
>>>>>> assigned only in
>>>>>> int fork1(td, flags, pages, procp):
>>>>>> #ifdef VIMAGE
>>>>>> =A0 =A0 =A0 =A0td2->td_vnet =3D NULL;
>>>>>> =A0 =A0 =A0 =A0td2->td_vnet_lpush =3D NULL;
>>>>>> #endif
>>>>>
>>>>> Nice try. =A0Want another search? =A0Hint: there is this in vnet.h:
>>>>>
>>>>> #define curvnet curthread->td_vnet
>>>>>
>>>>> And then you'll, again, find the CURVNET_SET_* macros.
>>>>
>>>> Thank you
>>>
>>> Something you may find useful as well btw is:
>>>
>>> http://people.freebsd.org/~bz/20100530-02.vnet.9.html
>>
>> weired compiler complains about that there is no <sys/vnet.h>, I
>> include <net/vnet.h> maybe old documentation?
>
> it's net/vnet.h. =A0Documentation bug from a local transisiton time to
> the general framework. =A0Thanks for catching;) =A0net/vnet.h will
> obviously stay.
>
> --
> Bjoern A. Zeeb =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 You have to have visions!
> =A0 =A0 =A0 =A0<ks> Going to jail sucks -- <bz> All my daemons like it!
> =A0http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/jails.html



--=20
//Monthadar Al Jaberi



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinuAt37kz=h9tXJBOKUZTaZBQhDx-LMqh_Pmjq2>