Blame view

include/net/af_unix.h 2.17 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
  #ifndef __LINUX_NET_AFUNIX_H
  #define __LINUX_NET_AFUNIX_H
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
4

20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
5
6
  #include <linux/socket.h>
  #include <linux/un.h>
57b47a53e   Ingo Molnar   [NET]: sem2mutex ...
7
  #include <linux/mutex.h>
8c9814b97   Reshetova, Elena   net: convert unix...
8
  #include <linux/refcount.h>
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
9
  #include <net/sock.h>
415e3d3e9   Hannes Frederic Sowa   unix: correctly t...
10
11
  void unix_inflight(struct user_struct *user, struct file *fp);
  void unix_notinflight(struct user_struct *user, struct file *fp);
b60a8280b   Joe Perches   af_unix.h: Remove...
12
13
14
15
  void unix_gc(void);
  void wait_for_unix_gc(void);
  struct sock *unix_get_socket(struct file *filp);
  struct sock *unix_peer_get(struct sock *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
  
  #define UNIX_HASH_SIZE	256
7123aaa3a   Eric Dumazet   af_unix: speedup ...
18
  #define UNIX_HASH_BITS	8
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19

9305cfa44   Pavel Emelyanov   [AF_UNIX]: Make u...
20
  extern unsigned int unix_tot_inflight;
fa7ff56f7   Pavel Emelyanov   af_unix: Export s...
21
  extern spinlock_t unix_table_lock;
7123aaa3a   Eric Dumazet   af_unix: speedup ...
22
  extern struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
  struct unix_address {
8c9814b97   Reshetova, Elena   net: convert unix...
25
  	refcount_t	refcnt;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
26
  	int		len;
95c961747   Eric Dumazet   net: cleanup unsi...
27
  	unsigned int	hash;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28
29
30
31
  	struct sockaddr_un name[0];
  };
  
  struct unix_skb_parms {
7361c36c5   Eric W. Biederman   af_unix: Allow cr...
32
  	struct pid		*pid;		/* Skb credentials	*/
6b0ee8c03   Eric W. Biederman   scm: Stop passing...
33
34
  	kuid_t			uid;
  	kgid_t			gid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
  	struct scm_fp_list	*fp;		/* Passed files		*/
877ce7c1b   Catherine Zhang   [AF_UNIX]: Datagr...
36
  #ifdef CONFIG_SECURITY_NETWORK
dc49c1f94   Catherine Zhang   [AF_UNIX]: Kernel...
37
  	u32			secid;		/* Security ID		*/
877ce7c1b   Catherine Zhang   [AF_UNIX]: Datagr...
38
  #endif
e370a7236   Eric Dumazet   af_unix: improve ...
39
  	u32			consumed;
3859a271a   Kees Cook   randstruct: Mark ...
40
  } __randomize_layout;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41

438154823   Eric Dumazet   net: sock_def_rea...
42
  #define UNIXCB(skb) 	(*(struct unix_skb_parms *)&((skb)->cb))
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43

1c92b4e50   David S. Miller   [AF_UNIX]: Make s...
44
45
46
  #define unix_state_lock(s)	spin_lock(&unix_sk(s)->lock)
  #define unix_state_unlock(s)	spin_unlock(&unix_sk(s)->lock)
  #define unix_state_lock_nested(s) \
a09785a24   Ingo Molnar   [PATCH] lockdep: ...
47
48
  				spin_lock_nested(&unix_sk(s)->lock, \
  				SINGLE_DEPTH_NESTING)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
51
52
53
  /* The AF_UNIX socket */
  struct unix_sock {
  	/* WARNING: sk has to be the first member */
  	struct sock		sk;
438154823   Eric Dumazet   net: sock_def_rea...
54
  	struct unix_address     *addr;
40ffe67d2   Al Viro   switch unix_sock ...
55
  	struct path		path;
6e1ce3c34   Linus Torvalds   af_unix: split 'u...
56
  	struct mutex		iolock, bindlock;
438154823   Eric Dumazet   net: sock_def_rea...
57
  	struct sock		*peer;
1fd05ba5a   Miklos Szeredi   [AF_UNIX]: Rewrit...
58
  	struct list_head	link;
438154823   Eric Dumazet   net: sock_def_rea...
59
60
  	atomic_long_t		inflight;
  	spinlock_t		lock;
60bc851ae   Eric Dumazet   af_unix: fix a fa...
61
62
63
  	unsigned long		gc_flags;
  #define UNIX_GC_CANDIDATE	0
  #define UNIX_GC_MAYBE_CYCLE	1
438154823   Eric Dumazet   net: sock_def_rea...
64
  	struct socket_wq	peer_wq;
ac6424b98   Ingo Molnar   sched/wait: Renam...
65
  	wait_queue_entry_t		peer_wake;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
66
  };
4613012db   Aaron Conole   af_unix: Convert ...
67

c72eda060   Paul Moore   af_unix: constify...
68
  static inline struct unix_sock *unix_sk(const struct sock *sk)
4613012db   Aaron Conole   af_unix: Convert ...
69
70
71
  {
  	return (struct unix_sock *)sk;
  }
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
72

438154823   Eric Dumazet   net: sock_def_rea...
73
  #define peer_wait peer_wq.wait
885ee74d5   Pavel Emelyanov   af_unix: Move CIN...
74
75
  long unix_inq_len(struct sock *sk);
  long unix_outq_len(struct sock *sk);
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
76
  #ifdef CONFIG_SYSCTL
b60a8280b   Joe Perches   af_unix.h: Remove...
77
78
  int unix_sysctl_register(struct net *net);
  void unix_sysctl_unregister(struct net *net);
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
79
  #else
97577e382   Pavel Emelyanov   [UNIX]: Extend un...
80
81
  static inline int unix_sysctl_register(struct net *net) { return 0; }
  static inline void unix_sysctl_unregister(struct net *net) {}
20380731b   Arnaldo Carvalho de Melo   [NET]: Fix sparse...
82
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
83
  #endif