Re: sock_create vs socket_create_kern

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

 



On Mon, Mar 2, 2009 at 4:05 PM, Michael Blizek
<michi1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hi!
>
> On 13:49 Mon 02 Mar     , Daniel Baluta wrote:
>> Hello ,
>>
>> What is the difference between those two functions?
>>
>> I've looked through the source code and i found this:
>>
>>
>>  int sock_create(int family, int type, int protocol, struct socket **res)
>> {
>>          return __sock_create(current->nsproxy->net_ns, family, type,
>> protocol, res, 0);
>> }
>>
>> int sock_create_kern(int family, int type, int protocol, struct socket **res)
>> {
>>          return __sock_create(&init_net, family, type, protocol, res, 1);
>> }
>>
>> Any ideas?
>
> Let's see...
>
> - current refers to the task_struct as defined in include/linux/sched.h
> - current->nsproxy->net_ns points to the network namespace "struct net" of
>  the running process as defined in include/net/net_namespace.h
> - the last parameter of "__sock_create" is "int kern"
>
> My guess is that you use the first one if you in a system call and you are
> creating a socket for the process - and the second one if you are anywhere in
> the kernel and want to create a socket, because you have some client or server
> running in kernel mode (e.g. nfs). I think interrupts have to be enabled when
> calling any of these functions.
>
>        -Michi

This makes sense.

Thanks,
Daniel.

--
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