kernel: split patches folder up into backport, pending and hack folders
[openwrt/staging/chunkeey.git] / target / linux / generic / hack-4.9 / 901-debloat_sock_diag.patch
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
5
6 Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 ---
8 net/Kconfig | 3 +++
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(-)
16
17 diff --git a/net/Kconfig b/net/Kconfig
18 index 38a0c857eb52..b4621e1f3470 100644
19 --- a/net/Kconfig
20 +++ b/net/Kconfig
21 @@ -95,6 +95,9 @@ source "net/netlabel/Kconfig"
22
23 endif # if INET
24
25 +config SOCK_DIAG
26 + bool
27 +
28 config NETWORK_SECMARK
29 bool "Security Marking"
30 help
31 diff --git a/net/core/Makefile b/net/core/Makefile
32 index d6508c2ddca5..bee4adde14d8 100644
33 --- a/net/core/Makefile
34 +++ b/net/core/Makefile
35 @@ -9,8 +9,9 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
36
37 obj-y += dev.o ethtool.o dev_addr_lists.o dst.o netevent.o \
38 neighbour.o rtnetlink.o utils.o link_watch.o filter.o \
39 - sock_diag.o dev_ioctl.o tso.o sock_reuseport.o
40 + dev_ioctl.o tso.o sock_reuseport.o
41
42 +obj-$(CONFIG_SOCK_DIAG) += sock_diag.o
43 obj-$(CONFIG_XFRM) += flow.o
44 obj-y += net-sysfs.o
45 obj-$(CONFIG_PROC_FS) += net-procfs.o
46 diff --git a/net/core/sock.c b/net/core/sock.c
47 index 1989b3dd6d17..d4ca8db4166a 100644
48 --- a/net/core/sock.c
49 +++ b/net/core/sock.c
50 @@ -1457,9 +1457,11 @@ void sk_destruct(struct sock *sk)
51
52 static void __sk_free(struct sock *sk)
53 {
54 +#ifdef CONFIG_SOCK_DIAG
55 if (unlikely(sock_diag_has_destroy_listeners(sk) && sk->sk_net_refcnt))
56 sock_diag_broadcast_destroy(sk);
57 else
58 +#endif
59 sk_destruct(sk);
60 }
61
62 diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
63 index b54b3ca939db..74ecf598622c 100644
64 --- a/net/ipv4/Kconfig
65 +++ b/net/ipv4/Kconfig
66 @@ -408,6 +408,7 @@ config INET_XFRM_MODE_BEET
67
68 config INET_DIAG
69 tristate "INET: socket monitoring interface"
70 + select SOCK_DIAG
71 default y
72 ---help---
73 Support for INET (TCP, DCCP, etc) socket monitoring interface used by
74 diff --git a/net/netlink/Kconfig b/net/netlink/Kconfig
75 index 5d6e8c05b3d4..8a2696d66c20 100644
76 --- a/net/netlink/Kconfig
77 +++ b/net/netlink/Kconfig
78 @@ -4,6 +4,7 @@
79
80 config NETLINK_DIAG
81 tristate "NETLINK: socket monitoring interface"
82 + select SOCK_DIAG
83 default n
84 ---help---
85 Support for NETLINK socket monitoring interface used by the ss tool.
86 diff --git a/net/packet/Kconfig b/net/packet/Kconfig
87 index cc55b35f80e5..9a83c86f5480 100644
88 --- a/net/packet/Kconfig
89 +++ b/net/packet/Kconfig
90 @@ -18,6 +18,7 @@ config PACKET
91 config PACKET_DIAG
92 tristate "Packet: sockets monitoring interface"
93 depends on PACKET
94 + select SOCK_DIAG
95 default n
96 ---help---
97 Support for PF_PACKET sockets monitoring interface used by the ss tool.
98 diff --git a/net/unix/Kconfig b/net/unix/Kconfig
99 index 8b31ab85d050..6548cf3ea7f1 100644
100 --- a/net/unix/Kconfig
101 +++ b/net/unix/Kconfig
102 @@ -22,6 +22,7 @@ config UNIX
103 config UNIX_DIAG
104 tristate "UNIX: socket monitoring interface"
105 depends on UNIX
106 + select SOCK_DIAG
107 default n
108 ---help---
109 Support for UNIX socket monitoring interface used by the ss tool.
110 --
111 2.11.0
112