Re: Get current network namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A namespace parameter is obtained in every function which creates the socket. This namespace field is present in the sk_buff structure which is filled up either by the process which is creating the socket or in second case from the device it is received.

HTH

Regards,
Sharwan

On Wed, Apr 8, 2009 at 3:10 AM, Haibin Wang <haibin123us@xxxxxxxxx> wrote:
Yes, that is exactly why I ask this question. If I use the default
init_net, then my could go through the new APIs that requries a struct
net, but then it doesn't really support the network namespace feature.

On Mon, Apr 6, 2009 at 9:54 PM, Michael Blizek
<michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi!
>
> On 11:34 Mon 06 Apr     , Haibin Wang wrote:
>> Hi folks,
>>
>> A question on how to get the current network namespace.
>>
>> I am porting a driver from 2.6.18 to 2.6.28. We do protocol analysis
>> by the 5 tuples: src IP, dst IP, src port, dst port and transportation
>> protocol. We have code in usr space to pass in these parameters, then
>> kernel space code do search through udp_hash and tcp_hash to locate
>> the exact socks. Since 2.6.18 doesn't support network namespace, this
>> works fine.
>>
>> But as 2.6.28 supports network namespace, search through udp_hash and
>> tcp_hash requires a sixth parameter -- network namespace as well. So
>> the question is, how to get current network namespace in this case? Is
>> it available from user space code and passed to kernel code, or there
>> is function to get it in kernel space?
>>
>> It seems I could go by by using the system init_net, but I want to be
>> new feature friendly at least.
>
> Netmark namespace means that different user space processes have a different
> view of the network (used e.g. by vservers). I do not know what will happen,
> if you pass the init_net (default namespace), if the socket is created in a
> different namespace.
>
>        -Michi
> --
> programing a layer 3+4 network protocol for mesh networks
> see http://michaelblizek.twilightparadox.com
>
>

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux