kernel: bump 4.9 to 4.9.196
[openwrt/openwrt.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 --- a/net/Kconfig
18 +++ b/net/Kconfig
19 @@ -95,6 +95,9 @@ source "net/netlabel/Kconfig"
20
21 endif # if INET
22
23 +config SOCK_DIAG
24 + bool
25 +
26 config NETWORK_SECMARK
27 bool "Security Marking"
28 help
29 --- a/net/core/Makefile
30 +++ b/net/core/Makefile
31 @@ -9,8 +9,9 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.
32
33 obj-y += dev.o ethtool.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
38 +obj-$(CONFIG_SOCK_DIAG) += sock_diag.o
39 obj-$(CONFIG_XFRM) += flow.o
40 obj-y += net-sysfs.o
41 obj-$(CONFIG_PROC_FS) += net-procfs.o
42 --- a/net/core/sock.c
43 +++ b/net/core/sock.c
44 @@ -1463,9 +1463,11 @@ void sk_destruct(struct sock *sk)
45
46 static void __sk_free(struct sock *sk)
47 {
48 +#ifdef CONFIG_SOCK_DIAG
49 if (unlikely(sk->sk_net_refcnt && sock_diag_has_destroy_listeners(sk)))
50 sock_diag_broadcast_destroy(sk);
51 else
52 +#endif
53 sk_destruct(sk);
54 }
55
56 --- a/net/ipv4/Kconfig
57 +++ b/net/ipv4/Kconfig
58 @@ -408,6 +408,7 @@ config INET_XFRM_MODE_BEET
59
60 config INET_DIAG
61 tristate "INET: socket monitoring interface"
62 + select SOCK_DIAG
63 default y
64 ---help---
65 Support for INET (TCP, DCCP, etc) socket monitoring interface used by
66 --- a/net/netlink/Kconfig
67 +++ b/net/netlink/Kconfig
68 @@ -4,6 +4,7 @@
69
70 config NETLINK_DIAG
71 tristate "NETLINK: socket monitoring interface"
72 + select SOCK_DIAG
73 default n
74 ---help---
75 Support for NETLINK socket monitoring interface used by the ss tool.
76 --- a/net/packet/Kconfig
77 +++ b/net/packet/Kconfig
78 @@ -18,6 +18,7 @@ config PACKET
79 config PACKET_DIAG
80 tristate "Packet: sockets monitoring interface"
81 depends on PACKET
82 + select SOCK_DIAG
83 default n
84 ---help---
85 Support for PF_PACKET sockets monitoring interface used by the ss tool.
86 --- a/net/unix/Kconfig
87 +++ b/net/unix/Kconfig
88 @@ -22,6 +22,7 @@ config UNIX
89 config UNIX_DIAG
90 tristate "UNIX: socket monitoring interface"
91 depends on UNIX
92 + select SOCK_DIAG
93 default n
94 ---help---
95 Support for UNIX socket monitoring interface used by the ss tool.