1 From 3b6115d6b57a263bdc8c9b1df273bd4a7955eead Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Sat, 8 Jul 2017 08:16:31 +0200
4 Subject: debloat: add some debloat patches, strip down procfs and make O_DIRECT support optional, saves ~15K after lzma on MIPS
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 net/core/Makefile | 3 ++-
10 net/core/sock.c | 2 ++
11 net/ipv4/Kconfig | 1 +
12 net/netlink/Kconfig | 1 +
13 net/packet/Kconfig | 1 +
14 net/unix/Kconfig | 1 +
15 7 files changed, 11 insertions(+), 1 deletion(-)
19 @@ -104,6 +104,9 @@ source "net/mptcp/Kconfig"
26 config NETWORK_SECMARK
27 bool "Security Marking"
29 --- a/net/core/Makefile
30 +++ b/net/core/Makefile
31 @@ -11,11 +11,12 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.
33 obj-y += dev.o dev_addr_lists.o dst.o netevent.o \
34 neighbour.o rtnetlink.o utils.o link_watch.o filter.o \
35 - sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \
36 + dev_ioctl.o tso.o sock_reuseport.o \
37 fib_notifier.o xdp.o flow_offload.o gro.o
39 obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o
41 +obj-$(CONFIG_SOCK_DIAG) += sock_diag.o
43 obj-$(CONFIG_PAGE_POOL) += page_pool.o
44 obj-$(CONFIG_PROC_FS) += net-procfs.o
48 #include <linux/memcontrol.h>
49 #include <linux/prefetch.h>
50 #include <linux/compat.h>
51 +#include <linux/cookie.h>
53 #include <linux/uaccess.h>
57 static DEFINE_MUTEX(proto_list_mutex);
58 static LIST_HEAD(proto_list);
59 +DEFINE_COOKIE(sock_cookie);
61 static void sock_def_write_space_wfree(struct sock *sk);
62 static void sock_def_write_space(struct sock *sk);
63 @@ -585,6 +587,18 @@ discard_and_relse:
65 EXPORT_SYMBOL(__sk_receive_skb);
67 +u64 __sock_gen_cookie(struct sock *sk)
70 + u64 res = atomic64_read(&sk->sk_cookie);
74 + res = gen_cookie_next(&sock_cookie);
75 + atomic64_cmpxchg(&sk->sk_cookie, 0, res);
79 INDIRECT_CALLABLE_DECLARE(struct dst_entry *ip6_dst_check(struct dst_entry *,
81 INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *,
82 @@ -2188,9 +2202,11 @@ static void __sk_free(struct sock *sk)
83 if (likely(sk->sk_net_refcnt))
84 sock_inuse_add(sock_net(sk), -1);
86 +#ifdef CONFIG_SOCK_DIAG
87 if (unlikely(sk->sk_net_refcnt && sock_diag_has_destroy_listeners(sk)))
88 sock_diag_broadcast_destroy(sk);
94 --- a/net/core/sock_diag.c
95 +++ b/net/core/sock_diag.c
97 #include <linux/tcp.h>
98 #include <linux/workqueue.h>
99 #include <linux/nospec.h>
100 -#include <linux/cookie.h>
101 #include <linux/inet_diag.h>
102 #include <linux/sock_diag.h>
104 @@ -21,20 +20,6 @@ static int (*inet_rcv_compat)(struct sk_
105 static DEFINE_MUTEX(sock_diag_table_mutex);
106 static struct workqueue_struct *broadcast_wq;
108 -DEFINE_COOKIE(sock_cookie);
110 -u64 __sock_gen_cookie(struct sock *sk)
113 - u64 res = atomic64_read(&sk->sk_cookie);
117 - res = gen_cookie_next(&sock_cookie);
118 - atomic64_cmpxchg(&sk->sk_cookie, 0, res);
122 int sock_diag_check_cookie(struct sock *sk, const __u32 *cookie)
125 --- a/net/ipv4/Kconfig
126 +++ b/net/ipv4/Kconfig
127 @@ -423,6 +423,7 @@ config INET_TUNNEL
130 tristate "INET: socket monitoring interface"
134 Support for INET (TCP, DCCP, etc) socket monitoring interface used by
135 --- a/net/netlink/Kconfig
136 +++ b/net/netlink/Kconfig
140 tristate "NETLINK: socket monitoring interface"
144 Support for NETLINK socket monitoring interface used by the ss tool.
145 --- a/net/packet/Kconfig
146 +++ b/net/packet/Kconfig
147 @@ -19,6 +19,7 @@ config PACKET
149 tristate "Packet: sockets monitoring interface"
154 Support for PF_PACKET sockets monitoring interface used by the ss tool.
155 --- a/net/unix/Kconfig
156 +++ b/net/unix/Kconfig
157 @@ -33,6 +33,7 @@ config AF_UNIX_OOB
159 tristate "UNIX: socket monitoring interface"
164 Support for UNIX socket monitoring interface used by the ss tool.
165 --- a/net/xdp/Kconfig
166 +++ b/net/xdp/Kconfig
167 @@ -10,6 +10,7 @@ config XDP_SOCKETS
168 config XDP_SOCKETS_DIAG
169 tristate "XDP sockets: monitoring interface"
170 depends on XDP_SOCKETS
174 Support for PF_XDP sockets monitoring interface used by the ss tool.