Mapping socket to task

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

 



How to get task_struct of a socket owner process? i.e. how to get
task_struct* from sock*

I have tried following (on 2.6.38) but didn't work.

struct sock* sk = xxx;
(i) sk->sk_socket->file->f_cred->uid
(ii) tsk = get_pid_task(sk->sk_socket->file->f_owner->pid,
sk->sk_socket->file->f_owner->pid_type)

The goal is know which process opened the socket. (I know netstat -p
option, and /proc/<pid>/fd methods, but I want to do it in kernel
module only).

Thank you
Lal

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[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