Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'af_unix-clean-up-headers'

Kuniyuki Iwashima says:

====================
af_unix: Clean up headers.

AF_UNIX files include many unnecessary headers (netdevice.h and
rtnetlink.h, etc), and this series cleans them up.

Note that there are still some headers included indirectly and
modifying them triggers rebuild, which seems mostly inevitable. [0]

$ python3 include_graph.py net/unix/garbage.c linux/rtnetlink.h linux/netdevice.h
...
include/net/af_unix.h
| include/linux/net.h
| | include/linux/once.h
| | include/linux/sockptr.h
| | include/uapi/linux/net.h
| include/net/sock.h
| | include/linux/netdevice.h <---
...
| | include/net/dst.h
| | | include/linux/rtnetlink.h <---

[0]: https://gist.github.com/q2ven/9c5897f11a493145829029c0bfb364d0
====================

Link: https://patch.msgid.link/20250318034934.86708-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+150 -140
+7 -77
include/net/af_unix.h
··· 2 2 #ifndef __LINUX_NET_AFUNIX_H 3 3 #define __LINUX_NET_AFUNIX_H 4 4 5 - #include <linux/socket.h> 6 - #include <linux/un.h> 5 + #include <linux/atomic.h> 7 6 #include <linux/mutex.h> 7 + #include <linux/net.h> 8 + #include <linux/path.h> 8 9 #include <linux/refcount.h> 10 + #include <linux/spinlock.h> 11 + #include <linux/wait.h> 9 12 #include <net/sock.h> 13 + #include <uapi/linux/un.h> 10 14 11 15 #if IS_ENABLED(CONFIG_UNIX) 12 16 struct unix_sock *unix_get_socket(struct file *filp); ··· 21 17 } 22 18 #endif 23 19 24 - extern unsigned int unix_tot_inflight; 25 - void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver); 26 - void unix_del_edges(struct scm_fp_list *fpl); 27 - void unix_update_edges(struct unix_sock *receiver); 28 - int unix_prepare_fpl(struct scm_fp_list *fpl); 29 - void unix_destroy_fpl(struct scm_fp_list *fpl); 30 - void unix_gc(void); 31 - void wait_for_unix_gc(struct scm_fp_list *fpl); 32 - 33 - struct unix_vertex { 34 - struct list_head edges; 35 - struct list_head entry; 36 - struct list_head scc_entry; 37 - unsigned long out_degree; 38 - unsigned long index; 39 - unsigned long scc_index; 40 - }; 41 - 42 - struct unix_edge { 43 - struct unix_sock *predecessor; 44 - struct unix_sock *successor; 45 - struct list_head vertex_entry; 46 - struct list_head stack_entry; 47 - }; 48 - 49 - struct sock *unix_peer_get(struct sock *sk); 50 - 51 - #define UNIX_HASH_MOD (256 - 1) 52 - #define UNIX_HASH_SIZE (256 * 2) 53 - #define UNIX_HASH_BITS 8 54 - 55 20 struct unix_address { 56 21 refcount_t refcnt; 57 22 int len; 58 23 struct sockaddr_un name[]; 59 24 }; 60 25 61 - struct unix_skb_parms { 62 - struct pid *pid; /* Skb credentials */ 63 - kuid_t uid; 64 - kgid_t gid; 65 - struct scm_fp_list *fp; /* Passed files */ 66 - #ifdef CONFIG_SECURITY_NETWORK 67 - u32 secid; /* Security ID */ 68 - #endif 69 - u32 consumed; 70 - } __randomize_layout; 71 - 72 26 struct scm_stat { 73 27 atomic_t nr_fds; 74 28 unsigned long nr_unix_fds; 75 29 }; 76 - 77 - #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) 78 30 79 31 /* The AF_UNIX socket */ 80 32 struct unix_sock { ··· 44 84 struct unix_vertex *vertex; 45 85 spinlock_t lock; 46 86 struct socket_wq peer_wq; 87 + #define peer_wait peer_wq.wait 47 88 wait_queue_entry_t peer_wake; 48 89 struct scm_stat scm_stat; 49 90 #if IS_ENABLED(CONFIG_AF_UNIX_OOB) ··· 55 94 #define unix_sk(ptr) container_of_const(ptr, struct unix_sock, sk) 56 95 #define unix_peer(sk) (unix_sk(sk)->peer) 57 96 58 - #define unix_state_lock(s) spin_lock(&unix_sk(s)->lock) 59 - #define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock) 60 - 61 - #define peer_wait peer_wq.wait 62 - 63 - long unix_inq_len(struct sock *sk); 64 - long unix_outq_len(struct sock *sk); 65 - 66 - int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, 67 - int flags); 68 - int __unix_stream_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, 69 - int flags); 70 - #ifdef CONFIG_SYSCTL 71 - int unix_sysctl_register(struct net *net); 72 - void unix_sysctl_unregister(struct net *net); 73 - #else 74 - static inline int unix_sysctl_register(struct net *net) { return 0; } 75 - static inline void unix_sysctl_unregister(struct net *net) {} 76 - #endif 77 - 78 - #ifdef CONFIG_BPF_SYSCALL 79 - extern struct proto unix_dgram_proto; 80 - extern struct proto unix_stream_proto; 81 - 82 - int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 83 - int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 84 - void __init unix_bpf_build_proto(void); 85 - #else 86 - static inline void __init unix_bpf_build_proto(void) 87 - {} 88 - #endif 89 97 #endif
+30 -39
net/unix/af_unix.c
··· 77 77 78 78 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 79 79 80 - #include <linux/module.h> 81 - #include <linux/kernel.h> 82 - #include <linux/signal.h> 83 - #include <linux/sched/signal.h> 84 - #include <linux/errno.h> 85 - #include <linux/string.h> 86 - #include <linux/stat.h> 87 - #include <linux/dcache.h> 88 - #include <linux/namei.h> 89 - #include <linux/socket.h> 90 - #include <linux/un.h> 91 - #include <linux/fcntl.h> 92 - #include <linux/filter.h> 93 - #include <linux/termios.h> 94 - #include <linux/sockios.h> 95 - #include <linux/net.h> 96 - #include <linux/in.h> 97 - #include <linux/fs.h> 98 - #include <linux/slab.h> 99 - #include <linux/uaccess.h> 100 - #include <linux/skbuff.h> 101 - #include <linux/netdevice.h> 102 - #include <net/net_namespace.h> 103 - #include <net/sock.h> 104 - #include <net/tcp_states.h> 105 - #include <net/af_unix.h> 106 - #include <linux/proc_fs.h> 107 - #include <linux/seq_file.h> 108 - #include <net/scm.h> 109 - #include <linux/init.h> 110 - #include <linux/poll.h> 111 - #include <linux/rtnetlink.h> 112 - #include <linux/mount.h> 113 - #include <net/checksum.h> 114 - #include <linux/security.h> 115 - #include <linux/splice.h> 116 - #include <linux/freezer.h> 117 - #include <linux/file.h> 118 - #include <linux/btf_ids.h> 119 80 #include <linux/bpf-cgroup.h> 81 + #include <linux/btf_ids.h> 82 + #include <linux/dcache.h> 83 + #include <linux/errno.h> 84 + #include <linux/fcntl.h> 85 + #include <linux/file.h> 86 + #include <linux/filter.h> 87 + #include <linux/fs.h> 88 + #include <linux/init.h> 89 + #include <linux/kernel.h> 90 + #include <linux/mount.h> 91 + #include <linux/namei.h> 92 + #include <linux/poll.h> 93 + #include <linux/proc_fs.h> 94 + #include <linux/sched/signal.h> 95 + #include <linux/security.h> 96 + #include <linux/seq_file.h> 97 + #include <linux/skbuff.h> 98 + #include <linux/slab.h> 99 + #include <linux/socket.h> 100 + #include <linux/splice.h> 101 + #include <linux/string.h> 102 + #include <linux/uaccess.h> 103 + #include <net/af_unix.h> 104 + #include <net/net_namespace.h> 105 + #include <net/scm.h> 106 + #include <net/tcp_states.h> 107 + #include <uapi/linux/sockios.h> 108 + #include <uapi/linux/termios.h> 109 + 110 + #include "af_unix.h" 120 111 121 112 static atomic_long_t unix_nr_socks; 122 113 static struct hlist_head bsd_socket_buckets[UNIX_HASH_SIZE / 2];
+75
net/unix/af_unix.h
··· 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 + #define unix_state_lock(s) spin_lock(&unix_sk(s)->lock) 12 + #define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock) 13 + 14 + struct sock *unix_peer_get(struct sock *sk); 15 + 16 + struct unix_skb_parms { 17 + struct pid *pid; /* skb credentials */ 18 + kuid_t uid; 19 + kgid_t gid; 20 + struct scm_fp_list *fp; /* Passed files */ 21 + #ifdef CONFIG_SECURITY_NETWORK 22 + u32 secid; /* Security ID */ 23 + #endif 24 + u32 consumed; 25 + } __randomize_layout; 26 + 27 + #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) 28 + 29 + /* GC for SCM_RIGHTS */ 30 + extern unsigned int unix_tot_inflight; 31 + void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver); 32 + void unix_del_edges(struct scm_fp_list *fpl); 33 + void unix_update_edges(struct unix_sock *receiver); 34 + int unix_prepare_fpl(struct scm_fp_list *fpl); 35 + void unix_destroy_fpl(struct scm_fp_list *fpl); 36 + void unix_gc(void); 37 + void wait_for_unix_gc(struct scm_fp_list *fpl); 38 + 39 + /* SOCK_DIAG */ 40 + long unix_inq_len(struct sock *sk); 41 + long unix_outq_len(struct sock *sk); 42 + 43 + /* sysctl */ 44 + #ifdef CONFIG_SYSCTL 45 + int unix_sysctl_register(struct net *net); 46 + void unix_sysctl_unregister(struct net *net); 47 + #else 48 + static inline int unix_sysctl_register(struct net *net) 49 + { 50 + return 0; 51 + } 52 + 53 + static inline void unix_sysctl_unregister(struct net *net) 54 + { 55 + } 56 + #endif 57 + 58 + /* BPF SOCKMAP */ 59 + int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); 60 + int __unix_stream_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); 61 + 62 + #ifdef CONFIG_BPF_SYSCALL 63 + extern struct proto unix_dgram_proto; 64 + extern struct proto unix_stream_proto; 65 + 66 + int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 67 + int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 68 + void __init unix_bpf_build_proto(void); 69 + #else 70 + static inline void __init unix_bpf_build_proto(void) 71 + { 72 + } 73 + #endif 74 + 75 + #endif
+10 -8
net/unix/diag.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 - #include <linux/types.h> 3 - #include <linux/spinlock.h> 4 - #include <linux/sock_diag.h> 5 - #include <linux/unix_diag.h> 6 - #include <linux/skbuff.h> 2 + 3 + #include <linux/dcache.h> 7 4 #include <linux/module.h> 8 - #include <linux/uidgid.h> 9 - #include <net/netlink.h> 5 + #include <linux/skbuff.h> 6 + #include <linux/sock_diag.h> 7 + #include <linux/types.h> 8 + #include <linux/user_namespace.h> 10 9 #include <net/af_unix.h> 10 + #include <net/netlink.h> 11 11 #include <net/tcp_states.h> 12 - #include <net/sock.h> 12 + #include <uapi/linux/unix_diag.h> 13 + 14 + #include "af_unix.h" 13 15 14 16 static int sk_diag_dump_name(struct sock *sk, struct sk_buff *nlskb) 15 17 {
+21 -12
net/unix/garbage.c
··· 63 63 * wrt receive and holding up unrelated socket operations. 64 64 */ 65 65 66 - #include <linux/kernel.h> 67 - #include <linux/string.h> 68 - #include <linux/socket.h> 69 - #include <linux/un.h> 70 - #include <linux/net.h> 71 66 #include <linux/fs.h> 67 + #include <linux/list.h> 72 68 #include <linux/skbuff.h> 73 - #include <linux/netdevice.h> 74 - #include <linux/file.h> 75 - #include <linux/proc_fs.h> 76 - #include <linux/mutex.h> 77 - #include <linux/wait.h> 78 - 79 - #include <net/sock.h> 69 + #include <linux/socket.h> 70 + #include <linux/workqueue.h> 80 71 #include <net/af_unix.h> 81 72 #include <net/scm.h> 82 73 #include <net/tcp_states.h> 74 + 75 + #include "af_unix.h" 76 + 77 + struct unix_vertex { 78 + struct list_head edges; 79 + struct list_head entry; 80 + struct list_head scc_entry; 81 + unsigned long out_degree; 82 + unsigned long index; 83 + unsigned long scc_index; 84 + }; 85 + 86 + struct unix_edge { 87 + struct unix_sock *predecessor; 88 + struct unix_sock *successor; 89 + struct list_head vertex_entry; 90 + struct list_head stack_entry; 91 + }; 83 92 84 93 struct unix_sock *unix_get_socket(struct file *filp) 85 94 {
+4 -2
net/unix/sysctl_net_unix.c
··· 5 5 * Authors: Mike Shaver. 6 6 */ 7 7 8 - #include <linux/mm.h> 9 8 #include <linux/slab.h> 9 + #include <linux/string.h> 10 10 #include <linux/sysctl.h> 11 - 12 11 #include <net/af_unix.h> 12 + #include <net/net_namespace.h> 13 + 14 + #include "af_unix.h" 13 15 14 16 static struct ctl_table unix_table[] = { 15 17 {
+3 -2
net/unix/unix_bpf.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 /* Copyright (c) 2021 Cong Wang <cong.wang@bytedance.com> */ 3 3 4 - #include <linux/skmsg.h> 5 4 #include <linux/bpf.h> 6 - #include <net/sock.h> 5 + #include <linux/skmsg.h> 7 6 #include <net/af_unix.h> 7 + 8 + #include "af_unix.h" 8 9 9 10 #define unix_sk_has_data(__sk, __psock) \ 10 11 ({ !skb_queue_empty(&__sk->sk_receive_queue) || \