1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __AF_UNIX_H 3 #define __AF_UNIX_H 4 5 #include <linux/uidgid.h> 6 7 #define UNIX_HASH_MOD (256 - 1) 8 #define UNIX_HASH_SIZE (256 * 2) 9 #define UNIX_HASH_BITS 8 10 11 struct sock *unix_peer_get(struct sock *sk); 12 13 struct unix_skb_parms { 14 struct pid *pid; /* skb credentials */ 15 kuid_t uid; 16 kgid_t gid; 17 struct scm_fp_list *fp; /* Passed files */ 18 #ifdef CONFIG_SECURITY_NETWORK 19 u32 secid; /* Security ID */ 20 #endif 21 u32 consumed; 22 } __randomize_layout; 23 24 #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) 25 26 /* GC for SCM_RIGHTS */ 27 void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver); 28 void unix_del_edges(struct scm_fp_list *fpl); 29 void unix_update_edges(struct unix_sock *receiver); 30 int unix_prepare_fpl(struct scm_fp_list *fpl); 31 void unix_destroy_fpl(struct scm_fp_list *fpl); 32 void unix_schedule_gc(struct user_struct *user); 33 34 /* SOCK_DIAG */ 35 long unix_inq_len(struct sock *sk); 36 long unix_outq_len(struct sock *sk); 37 38 /* sysctl */ 39 #ifdef CONFIG_SYSCTL 40 int unix_sysctl_register(struct net *net); 41 void unix_sysctl_unregister(struct net *net); 42 #else 43 static inline int unix_sysctl_register(struct net *net) 44 { 45 return 0; 46 } 47 48 static inline void unix_sysctl_unregister(struct net *net) 49 { 50 } 51 #endif 52 53 /* BPF SOCKMAP */ 54 int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); 55 int __unix_stream_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); 56 57 #ifdef CONFIG_BPF_SYSCALL 58 extern struct proto unix_dgram_proto; 59 extern struct proto unix_stream_proto; 60 61 int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 62 int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 63 void __init unix_bpf_build_proto(void); 64 #else 65 static inline void __init unix_bpf_build_proto(void) 66 { 67 } 68 #endif 69 70 #endif 71