Re: sock_create vs socket_create_kern

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

 



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