From patchwork Tue Mar 18 03:48:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 14020254 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com [52.95.48.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC27C14AD0D for ; Tue, 18 Mar 2025 03:50:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.95.48.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269822; cv=none; b=K54IUk2H3ozc3gQiiPArNjpi3G6drWw8bfHp0UHrSDOv+VLGbJQ0KnBlLJwN5OnnWAjEIVVKHoHiotLfZc48i8SRvu8LsiBrNoMXGZsBLcvuGXUg0PF2X/hnxFOiUzhi9h49pCe+bkw5jNgtSVxbG74UwVW1t3kPFaEvtuldl4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269822; c=relaxed/simple; bh=lCivVYCZhoVRtZs11fD1ihsv0ZyYpYTwkEmwZckhtz0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g2i4AiUf40ezthhxJbl07CYmzqI1XMDlrmy9wvQ8UIOo1i5o9icXfXtkn9wLeJtHvDSw9YRlgRk1LzUc7jNOnK0yxtLNzQa6tNIUBm6Np1moAJ3MLQr3O7SXueVtMUIMfHFNovoJmV75vCE+4P4fmZTN02CgTrKhEcLZqH/Gn1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=NjGJJ634; arc=none smtp.client-ip=52.95.48.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="NjGJJ634" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1742269822; x=1773805822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q1linzMrVLP7C94NGdIv3oWI07a1/ziMGwBU61TWlW4=; b=NjGJJ634uSaAOndn7CsVanE68L5OJlDjFP/F0ygHlCLyQK+w+3/k9U6y hhRKV4mVSs0GiqQ90BX0GVXoibiyMy/ImIG+V/XoF/HHURm6O6lA0XmXS vTAMDemXjDY3SMa18iikU/0AtXQZZSJY+jdRSvcvCLraJOru+0NkfyIWw 0=; X-IronPort-AV: E=Sophos;i="6.14,255,1736812800"; d="scan'208";a="471937724" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.2]) by smtp-border-fw-6001.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2025 03:50:16 +0000 Received: from EX19MTAUWC001.ant.amazon.com [10.0.38.20:53428] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.40.40:2525] with esmtp (Farcaster) id 15a97ad3-e7d4-44ea-a61d-ee38d583432f; Tue, 18 Mar 2025 03:50:14 +0000 (UTC) X-Farcaster-Flow-ID: 15a97ad3-e7d4-44ea-a61d-ee38d583432f Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:50:14 +0000 Received: from 6c7e67bfbae3.amazon.com (10.106.100.54) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:50:11 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman CC: Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 net-next 1/4] af_unix: Sort headers. Date: Mon, 17 Mar 2025 20:48:48 -0700 Message-ID: <20250318034934.86708-2-kuniyu@amazon.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318034934.86708-1-kuniyu@amazon.com> References: <20250318034934.86708-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D038UWC001.ant.amazon.com (10.13.139.213) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Patchwork-Delegate: kuba@kernel.org This is a prep patch to make the following changes cleaner. No functional change intended. Signed-off-by: Kuniyuki Iwashima --- include/net/af_unix.h | 4 +-- net/unix/af_unix.c | 62 +++++++++++++++++++------------------- net/unix/diag.c | 15 ++++----- net/unix/garbage.c | 17 +++++------ net/unix/sysctl_net_unix.c | 1 - net/unix/unix_bpf.c | 4 +-- 6 files changed, 51 insertions(+), 52 deletions(-) diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 63129c79b8cb..c8dfdb41916d 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -2,10 +2,10 @@ #ifndef __LINUX_NET_AFUNIX_H #define __LINUX_NET_AFUNIX_H -#include -#include #include #include +#include +#include #include #if IS_ENABLED(CONFIG_UNIX) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 7f8f3859cdb3..1ff0ac99f3f3 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -77,46 +77,46 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include -#include -#include -#include -#include -#include -#include +#include +#include #include -#include -#include -#include +#include #include +#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include #include +#include #include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static atomic_long_t unix_nr_socks; static struct hlist_head bsd_socket_buckets[UNIX_HASH_SIZE / 2]; diff --git a/net/unix/diag.c b/net/unix/diag.c index 9138af8b465e..ba715507556a 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only -#include -#include -#include -#include -#include + #include +#include +#include +#include +#include #include -#include +#include #include -#include +#include #include +#include static int sk_diag_dump_name(struct sock *sk, struct sk_buff *nlskb) { diff --git a/net/unix/garbage.c b/net/unix/garbage.c index 9848b7b78701..6a641d4b5542 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c @@ -63,22 +63,21 @@ * wrt receive and holding up unrelated socket operations. */ +#include +#include #include -#include -#include -#include +#include #include -#include -#include #include -#include #include -#include +#include +#include +#include +#include #include - -#include #include #include +#include #include struct unix_sock *unix_get_socket(struct file *filp) diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 357b3e5f3847..55118ae897d6 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -8,7 +8,6 @@ #include #include #include - #include static struct ctl_table unix_table[] = { diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c index bca2d86ba97d..86598a959eaa 100644 --- a/net/unix/unix_bpf.c +++ b/net/unix/unix_bpf.c @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2021 Cong Wang */ -#include #include -#include +#include #include +#include #define unix_sk_has_data(__sk, __psock) \ ({ !skb_queue_empty(&__sk->sk_receive_queue) || \ From patchwork Tue Mar 18 03:48:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 14020255 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp-fw-80007.amazon.com (smtp-fw-80007.amazon.com [99.78.197.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71A1A15B554 for ; Tue, 18 Mar 2025 03:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=99.78.197.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269843; cv=none; b=o+n65wPzZThGMEuk1XvVJlQXbIcfULjtXl27ROUXCb/td2e2Qm3MyqG2/5UkWdkjXh6uZIhL95RgXtjfER5+TML9WUYc0RnZWnTTneLyYnWFiRhzm9NEmz5ffpyBWv1mNRVMAnQ5L5C+lzP7BEwDDdIReuUZdyqHRVb7IysFpj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269843; c=relaxed/simple; bh=9/YczA+5fdPmoKSSJaQ/C7CkILXFP6KFFQij3phiTNw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IpuGYegBsuCME4Y/geLsHft8cbh5WMH0cQtWu32MWsL3HL9AXIYZd84hZpJMYArIQ+xq8HTCy30dh2QZQHM3Hfp89RogRd+LJLTzvedsXCEBpnK4gQOO0/78NWu7W/8lLef0hyUVyNtNTQ6sNrWPw3qDMRvUDjGOt8+o2Sqsucs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=D+/u4n8d; arc=none smtp.client-ip=99.78.197.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="D+/u4n8d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1742269842; x=1773805842; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CQVBWGEyQJrSVYtaKncanOCytSsNrmEHkLoRjsX3sUw=; b=D+/u4n8dIRU3nUBEnSWTPOH7pSYV3BWG8vvoH0APQmiYmGElf/Dn+ifr Q6X32PYMs9hVhIxFFgMxw9yTkT/hfVwrODi3woxnm7zBePJxJyOgE9gEs ims9CZOS5fdZDhATI8WtcneqQ2yFpisp2Ysdn+NopEw00FTuM/aeKajMf M=; X-IronPort-AV: E=Sophos;i="6.14,255,1736812800"; d="scan'208";a="387548331" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80007.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2025 03:50:40 +0000 Received: from EX19MTAUWB001.ant.amazon.com [10.0.38.20:21480] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.22.127:2525] with esmtp (Farcaster) id c974e175-0df1-49b2-8311-f43287835b80; Tue, 18 Mar 2025 03:50:39 +0000 (UTC) X-Farcaster-Flow-ID: c974e175-0df1-49b2-8311-f43287835b80 Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:50:39 +0000 Received: from 6c7e67bfbae3.amazon.com (10.106.100.54) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:50:36 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman CC: Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 net-next 2/4] af_unix: Move internal definitions to net/unix/. Date: Mon, 17 Mar 2025 20:48:49 -0700 Message-ID: <20250318034934.86708-3-kuniyu@amazon.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318034934.86708-1-kuniyu@amazon.com> References: <20250318034934.86708-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D031UWC001.ant.amazon.com (10.13.139.241) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Patchwork-Delegate: kuba@kernel.org net/af_unix.h is included by core and some LSMs, but most definitions need not be. Let's move struct unix_{vertex,edge} to net/unix/garbage.c and other definitions to net/unix/af_unix.h. Signed-off-by: Kuniyuki Iwashima --- include/net/af_unix.h | 76 +------------------------------------- net/unix/af_unix.c | 2 + net/unix/af_unix.h | 75 +++++++++++++++++++++++++++++++++++++ net/unix/diag.c | 2 + net/unix/garbage.c | 18 +++++++++ net/unix/sysctl_net_unix.c | 2 + net/unix/unix_bpf.c | 2 + 7 files changed, 102 insertions(+), 75 deletions(-) create mode 100644 net/unix/af_unix.h diff --git a/include/net/af_unix.h b/include/net/af_unix.h index c8dfdb41916d..b5d70baba52b 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -17,61 +17,17 @@ static inline struct unix_sock *unix_get_socket(struct file *filp) } #endif -extern unsigned int unix_tot_inflight; -void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver); -void unix_del_edges(struct scm_fp_list *fpl); -void unix_update_edges(struct unix_sock *receiver); -int unix_prepare_fpl(struct scm_fp_list *fpl); -void unix_destroy_fpl(struct scm_fp_list *fpl); -void unix_gc(void); -void wait_for_unix_gc(struct scm_fp_list *fpl); - -struct unix_vertex { - struct list_head edges; - struct list_head entry; - struct list_head scc_entry; - unsigned long out_degree; - unsigned long index; - unsigned long scc_index; -}; - -struct unix_edge { - struct unix_sock *predecessor; - struct unix_sock *successor; - struct list_head vertex_entry; - struct list_head stack_entry; -}; - -struct sock *unix_peer_get(struct sock *sk); - -#define UNIX_HASH_MOD (256 - 1) -#define UNIX_HASH_SIZE (256 * 2) -#define UNIX_HASH_BITS 8 - struct unix_address { refcount_t refcnt; int len; struct sockaddr_un name[]; }; -struct unix_skb_parms { - struct pid *pid; /* Skb credentials */ - kuid_t uid; - kgid_t gid; - struct scm_fp_list *fp; /* Passed files */ -#ifdef CONFIG_SECURITY_NETWORK - u32 secid; /* Security ID */ -#endif - u32 consumed; -} __randomize_layout; - struct scm_stat { atomic_t nr_fds; unsigned long nr_unix_fds; }; -#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) - /* The AF_UNIX socket */ struct unix_sock { /* WARNING: sk has to be the first member */ @@ -84,6 +40,7 @@ struct unix_sock { struct unix_vertex *vertex; spinlock_t lock; struct socket_wq peer_wq; +#define peer_wait peer_wq.wait wait_queue_entry_t peer_wake; struct scm_stat scm_stat; #if IS_ENABLED(CONFIG_AF_UNIX_OOB) @@ -94,35 +51,4 @@ struct unix_sock { #define unix_sk(ptr) container_of_const(ptr, struct unix_sock, sk) #define unix_peer(sk) (unix_sk(sk)->peer) -#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock) -#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock) - -#define peer_wait peer_wq.wait - -long unix_inq_len(struct sock *sk); -long unix_outq_len(struct sock *sk); - -int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, - int flags); -int __unix_stream_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, - int flags); -#ifdef CONFIG_SYSCTL -int unix_sysctl_register(struct net *net); -void unix_sysctl_unregister(struct net *net); -#else -static inline int unix_sysctl_register(struct net *net) { return 0; } -static inline void unix_sysctl_unregister(struct net *net) {} -#endif - -#ifdef CONFIG_BPF_SYSCALL -extern struct proto unix_dgram_proto; -extern struct proto unix_stream_proto; - -int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); -int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); -void __init unix_bpf_build_proto(void); -#else -static inline void __init unix_bpf_build_proto(void) -{} -#endif #endif diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 1ff0ac99f3f3..6390e04fe916 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -118,6 +118,8 @@ #include #include +#include "af_unix.h" + static atomic_long_t unix_nr_socks; static struct hlist_head bsd_socket_buckets[UNIX_HASH_SIZE / 2]; static spinlock_t bsd_socket_locks[UNIX_HASH_SIZE / 2]; diff --git a/net/unix/af_unix.h b/net/unix/af_unix.h new file mode 100644 index 000000000000..ed4aedc42813 --- /dev/null +++ b/net/unix/af_unix.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __AF_UNIX_H +#define __AF_UNIX_H + +#include + +#define UNIX_HASH_MOD (256 - 1) +#define UNIX_HASH_SIZE (256 * 2) +#define UNIX_HASH_BITS 8 + +#define unix_state_lock(s) spin_lock(&unix_sk(s)->lock) +#define unix_state_unlock(s) spin_unlock(&unix_sk(s)->lock) + +struct sock *unix_peer_get(struct sock *sk); + +struct unix_skb_parms { + struct pid *pid; /* skb credentials */ + kuid_t uid; + kgid_t gid; + struct scm_fp_list *fp; /* Passed files */ +#ifdef CONFIG_SECURITY_NETWORK + u32 secid; /* Security ID */ +#endif + u32 consumed; +} __randomize_layout; + +#define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) + +/* GC for SCM_RIGHTS */ +extern unsigned int unix_tot_inflight; +void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver); +void unix_del_edges(struct scm_fp_list *fpl); +void unix_update_edges(struct unix_sock *receiver); +int unix_prepare_fpl(struct scm_fp_list *fpl); +void unix_destroy_fpl(struct scm_fp_list *fpl); +void unix_gc(void); +void wait_for_unix_gc(struct scm_fp_list *fpl); + +/* SOCK_DIAG */ +long unix_inq_len(struct sock *sk); +long unix_outq_len(struct sock *sk); + +/* sysctl */ +#ifdef CONFIG_SYSCTL +int unix_sysctl_register(struct net *net); +void unix_sysctl_unregister(struct net *net); +#else +static inline int unix_sysctl_register(struct net *net) +{ + return 0; +} + +static inline void unix_sysctl_unregister(struct net *net) +{ +} +#endif + +/* BPF SOCKMAP */ +int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); +int __unix_stream_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); + +#ifdef CONFIG_BPF_SYSCALL +extern struct proto unix_dgram_proto; +extern struct proto unix_stream_proto; + +int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); +int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); +void __init unix_bpf_build_proto(void); +#else +static inline void __init unix_bpf_build_proto(void) +{ +} +#endif + +#endif diff --git a/net/unix/diag.c b/net/unix/diag.c index ba715507556a..c7e8c7d008f6 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -12,6 +12,8 @@ #include #include +#include "af_unix.h" + static int sk_diag_dump_name(struct sock *sk, struct sk_buff *nlskb) { /* might or might not have a hash table lock */ diff --git a/net/unix/garbage.c b/net/unix/garbage.c index 6a641d4b5542..8c8c7360349d 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c @@ -80,6 +80,24 @@ #include #include +#include "af_unix.h" + +struct unix_vertex { + struct list_head edges; + struct list_head entry; + struct list_head scc_entry; + unsigned long out_degree; + unsigned long index; + unsigned long scc_index; +}; + +struct unix_edge { + struct unix_sock *predecessor; + struct unix_sock *successor; + struct list_head vertex_entry; + struct list_head stack_entry; +}; + struct unix_sock *unix_get_socket(struct file *filp) { struct inode *inode = file_inode(filp); diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 55118ae897d6..236b7faa9254 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -10,6 +10,8 @@ #include #include +#include "af_unix.h" + static struct ctl_table unix_table[] = { { .procname = "max_dgram_qlen", diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c index 86598a959eaa..979dd4c4261a 100644 --- a/net/unix/unix_bpf.c +++ b/net/unix/unix_bpf.c @@ -6,6 +6,8 @@ #include #include +#include "af_unix.h" + #define unix_sk_has_data(__sk, __psock) \ ({ !skb_queue_empty(&__sk->sk_receive_queue) || \ !skb_queue_empty(&__psock->ingress_skb) || \ From patchwork Tue Mar 18 03:48:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 14020256 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ACB22114 for ; Tue, 18 Mar 2025 03:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.95.49.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269873; cv=none; b=T2vBIIR00/uqAo7BaTZkK05fAUnIG14U4aoHdXAbg977JQSd/Fb3A0OMSTcmvJhEH8UGn92AuqcAN5pUKxgxJ8+hUleuZU3y5Ja/SkbD0Z3RKvTA6f/I7ID6YoPInCg06exoApIm2kY7OWSd7yn1OpjC70/l1ZkeB8Ve08eRfsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269873; c=relaxed/simple; bh=WTKnP05XLwFyKkRF/orQ6TX2IpgxFtOzBstEktUuEo0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sAYAihuOMivEiS5wqgL+fitYvegi82aNB8HdBVQUIYD+wgCnnbvaqKBxn7M9uzXy7XGqpi85lYxS7SJlR/ZYPmA0EIXYOhRpiliFPcJTRal4EiULT33KdXosY1DIwj1k3DblYMfzJWdM1vo1U5FK80T46nHocj4RxnqVaVEQ7yA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=M7myYGC9; arc=none smtp.client-ip=52.95.49.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="M7myYGC9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1742269871; x=1773805871; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CdELdiQWbkOh27E7Cfs/FfK7uvvMSKexMvGjY8Qhtt8=; b=M7myYGC98jHlr2K9g1z22IugCkh37Val8xwRMfqFp7WDKEbhLzQk7eqC fb7qHR/j0Ot0FRui+VDW6Fuggh1CgLVfjEfas/P3N6KipAE7wTnQ/kIh5 4VN1qY642GrsGJH5xx0+mB5MSokQGtBgJbK25XUDYwn++xcWWs8f7UHbM s=; X-IronPort-AV: E=Sophos;i="6.14,255,1736812800"; d="scan'208";a="481240168" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2025 03:51:07 +0000 Received: from EX19MTAUWA001.ant.amazon.com [10.0.21.151:20665] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.52.235:2525] with esmtp (Farcaster) id 9095c6df-7d9e-444e-9a2d-592418a0944a; Tue, 18 Mar 2025 03:51:06 +0000 (UTC) X-Farcaster-Flow-ID: 9095c6df-7d9e-444e-9a2d-592418a0944a Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWA001.ant.amazon.com (10.250.64.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:51:04 +0000 Received: from 6c7e67bfbae3.amazon.com (10.106.100.54) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:51:01 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman CC: Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 net-next 3/4] af_unix: Explicitly include headers for non-pointer struct fields. Date: Mon, 17 Mar 2025 20:48:50 -0700 Message-ID: <20250318034934.86708-4-kuniyu@amazon.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318034934.86708-1-kuniyu@amazon.com> References: <20250318034934.86708-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D035UWB004.ant.amazon.com (10.13.138.104) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Patchwork-Delegate: kuba@kernel.org include/net/af_unix.h indirectly includes some definitions for structs. Let's include such headers explicitly. linux/atomic.h : scm_stat.nr_fds linux/net.h : unix_sock.peer_wq linux/path.h : unix_sock.path linux/spinlock.h : unix_sock.lock linux/wait.h : unix_sock.peer_wake uapi/linux/un.h : unix_address.name[] linux/socket.h is removed as the structs there are not used directly, and linux/un.h is clarified with uapi as un.h only exists under include/uapi. While at it, duplicate headers are removed from .c files. Signed-off-by: Kuniyuki Iwashima --- include/net/af_unix.h | 8 ++++++-- net/unix/af_unix.c | 3 --- net/unix/diag.c | 3 --- net/unix/garbage.c | 5 ----- net/unix/unix_bpf.c | 1 - 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/net/af_unix.h b/include/net/af_unix.h index b5d70baba52b..b588069ece7e 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -2,11 +2,15 @@ #ifndef __LINUX_NET_AFUNIX_H #define __LINUX_NET_AFUNIX_H +#include #include +#include +#include #include -#include -#include +#include +#include #include +#include #if IS_ENABLED(CONFIG_UNIX) struct unix_sock *unix_get_socket(struct file *filp); diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 6390e04fe916..c081440cf576 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -92,7 +92,6 @@ #include #include #include -#include #include #include #include @@ -110,12 +109,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include "af_unix.h" diff --git a/net/unix/diag.c b/net/unix/diag.c index c7e8c7d008f6..8b2247e05596 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -3,13 +3,10 @@ #include #include #include -#include #include -#include #include #include #include -#include #include #include "af_unix.h" diff --git a/net/unix/garbage.c b/net/unix/garbage.c index 8c8c7360349d..cd75502c47f1 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c @@ -66,18 +66,13 @@ #include #include #include -#include -#include #include #include #include #include #include -#include -#include #include #include -#include #include #include "af_unix.h" diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c index 979dd4c4261a..e0d30d6d22ac 100644 --- a/net/unix/unix_bpf.c +++ b/net/unix/unix_bpf.c @@ -4,7 +4,6 @@ #include #include #include -#include #include "af_unix.h" From patchwork Tue Mar 18 03:48:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuniyuki Iwashima X-Patchwork-Id: 14020257 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7774E2114 for ; Tue, 18 Mar 2025 03:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.95.49.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269894; cv=none; b=abktT/+EaJ0hp0Ah/HZmjDLgZMDJAr/yrOPa1Uz9+0pLuRGOGyn2EyV2DMKDaS8VqETkPJZ3vxhQGAMP+Eqe4L6OWGZascd6n2RAVtoKfvAdROqJht0Jl4oxSeI/HnUk3lCTX0C97c1qQ/z+UhfCh9SmKSbeIm3wO28XUz8HHYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742269894; c=relaxed/simple; bh=dH1vFL5tTM2cFmZzOmHd4O/Idu7xOuNcANf0oPXR3qY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mKQfTtu9yrh+1J+HIflbKbE4vEZm6hLYGvz5RXKfVMhTuq0mVbe2/RxG/qWvBDOtHgvcdNnlXvWG7Ew8DXXMYVJJAjGK9nv8Y2+wqtZFoI+7cdJiaXjV22z6wl45VPshtWpG27ltmzy+uLt1SFpt+zlWXNVgT5K+havXpyAqw1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.jp; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=EmSi7XN8; arc=none smtp.client-ip=52.95.49.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="EmSi7XN8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1742269893; x=1773805893; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ibExYCl7BiZkDrdJSJxoMg3jdRAxYXq7FibqYggH8NI=; b=EmSi7XN8h9XU7KQRz0v4ALfe03AeGIBS61EnyN6a2VWZE4aXL9jwG7sV n4RAKqyGAO3sfDh6JfBXocVzaq+06qC+7y9DJHd42eN/J4eJXB3qIloAk m4AM5SQ6o/Yr6ACBGnQ9yeNPaU845uTLGCQ3E0ZWImaPswRCPfjeHxq0J 0=; X-IronPort-AV: E=Sophos;i="6.14,255,1736812800"; d="scan'208";a="481240229" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2025 03:51:31 +0000 Received: from EX19MTAUWC001.ant.amazon.com [10.0.38.20:59034] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.5.243:2525] with esmtp (Farcaster) id ecb416b6-b2ef-443a-abbc-c130eb1051e7; Tue, 18 Mar 2025 03:51:29 +0000 (UTC) X-Farcaster-Flow-ID: ecb416b6-b2ef-443a-abbc-c130eb1051e7 Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:51:29 +0000 Received: from 6c7e67bfbae3.amazon.com (10.106.100.54) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1544.14; Tue, 18 Mar 2025 03:51:26 +0000 From: Kuniyuki Iwashima To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman CC: Kuniyuki Iwashima , Kuniyuki Iwashima , Subject: [PATCH v1 net-next 4/4] af_unix: Clean up #include under net/unix/. Date: Mon, 17 Mar 2025 20:48:51 -0700 Message-ID: <20250318034934.86708-5-kuniyu@amazon.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250318034934.86708-1-kuniyu@amazon.com> References: <20250318034934.86708-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D041UWB004.ant.amazon.com (10.13.139.143) To EX19D004ANA001.ant.amazon.com (10.37.240.138) X-Patchwork-Delegate: kuba@kernel.org net/unix/*.c include many unnecessary header files (rtnetlink.h, netdevice.h, etc). Let's clean them up. af_unix.c: +uapi/linux/sockios.h : Only exist under include/uapi +uapi/linux/termios.h : Only exist under include/uapi -linux/freezer.h : No longer use freezable_schedule_timeout() -linux/in.h : No ipv4_is_XXX() etc -linux/module.h : No longer support CONFIG_UNIX=m -linux/netdevice.h : No dev used -linux/rtnetlink.h : Not part of rtnetlink API -linux/signal.h : signal_pending() is defined in sched/signal.h -linux/stat.h : No struct stat used -net/checksum.h : CHECKSUM_UNNECESSARY is defined in skbuff.h diag.c: +linux/dcache.h : struct dentry in sk_diag_dump_vfs() +linux/user_namespace.h : struct user_namespace in sk_diag_dump_uid() +uapi/linux/unix_diag.h : Only exist under include/uapi/ garbage.c: +linux/list.h : struct unix_{vertex,edge}, etc +linux/workqueue.h : DECLARE_WORK(unix_gc_work, ...) -linux/file.h : No fget() etc -linux/kernel.h : No cond_resched() etc -linux/netdevice.h : No dev used -linux/proc_fs.h : No procfs provided -linux/string.h : No memcpy(), kmemdup(), etc sysctl_net_unix.c: +linux/string.h : kmemdup() +net/net_namespace.h : struct net, net_eq() -linux/mm.h : slab.h is enough Signed-off-by: Kuniyuki Iwashima --- net/unix/af_unix.c | 12 ++---------- net/unix/diag.c | 4 +++- net/unix/garbage.c | 7 ++----- net/unix/sysctl_net_unix.c | 3 ++- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index c081440cf576..f78a2492826f 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -84,36 +84,28 @@ #include #include #include -#include #include -#include #include #include -#include #include #include -#include #include #include -#include #include #include #include -#include #include #include #include -#include #include -#include #include -#include #include #include -#include #include #include #include +#include +#include #include "af_unix.h" diff --git a/net/unix/diag.c b/net/unix/diag.c index 8b2247e05596..79b182d0e62a 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c @@ -1,13 +1,15 @@ // SPDX-License-Identifier: GPL-2.0-only +#include #include #include #include #include -#include +#include #include #include #include +#include #include "af_unix.h" diff --git a/net/unix/garbage.c b/net/unix/garbage.c index cd75502c47f1..01e2b9452c75 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c @@ -63,14 +63,11 @@ * wrt receive and holding up unrelated socket operations. */ -#include #include -#include -#include -#include +#include #include #include -#include +#include #include #include #include diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c index 236b7faa9254..e02ed6e3955c 100644 --- a/net/unix/sysctl_net_unix.c +++ b/net/unix/sysctl_net_unix.c @@ -5,10 +5,11 @@ * Authors: Mike Shaver. */ -#include #include +#include #include #include +#include #include "af_unix.h"