af_unix.h 1.9 KB

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