901-debloat_sock_diag.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From 3b6115d6b57a263bdc8c9b1df273bd4a7955eead Mon Sep 17 00:00:00 2001
  2. From: Felix Fietkau <[email protected]>
  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. Signed-off-by: Felix Fietkau <[email protected]>
  6. ---
  7. net/Kconfig | 3 +++
  8. net/core/Makefile | 3 ++-
  9. net/core/sock.c | 2 ++
  10. net/ipv4/Kconfig | 1 +
  11. net/netlink/Kconfig | 1 +
  12. net/packet/Kconfig | 1 +
  13. net/unix/Kconfig | 1 +
  14. 7 files changed, 11 insertions(+), 1 deletion(-)
  15. --- a/net/Kconfig
  16. +++ b/net/Kconfig
  17. @@ -95,6 +95,9 @@ source "net/netlabel/Kconfig"
  18. endif # if INET
  19. +config SOCK_DIAG
  20. + bool
  21. +
  22. config NETWORK_SECMARK
  23. bool "Security Marking"
  24. help
  25. --- a/net/core/Makefile
  26. +++ b/net/core/Makefile
  27. @@ -9,8 +9,9 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.
  28. obj-y += dev.o ethtool.o dev_addr_lists.o dst.o netevent.o \
  29. neighbour.o rtnetlink.o utils.o link_watch.o filter.o \
  30. - sock_diag.o dev_ioctl.o tso.o sock_reuseport.o
  31. + dev_ioctl.o tso.o sock_reuseport.o
  32. +obj-$(CONFIG_SOCK_DIAG) += sock_diag.o
  33. obj-$(CONFIG_XFRM) += flow.o
  34. obj-y += net-sysfs.o
  35. obj-$(CONFIG_PROC_FS) += net-procfs.o
  36. --- a/net/core/sock.c
  37. +++ b/net/core/sock.c
  38. @@ -1457,9 +1457,11 @@ void sk_destruct(struct sock *sk)
  39. static void __sk_free(struct sock *sk)
  40. {
  41. +#ifdef CONFIG_SOCK_DIAG
  42. if (unlikely(sk->sk_net_refcnt && sock_diag_has_destroy_listeners(sk)))
  43. sock_diag_broadcast_destroy(sk);
  44. else
  45. +#endif
  46. sk_destruct(sk);
  47. }
  48. --- a/net/ipv4/Kconfig
  49. +++ b/net/ipv4/Kconfig
  50. @@ -408,6 +408,7 @@ config INET_XFRM_MODE_BEET
  51. config INET_DIAG
  52. tristate "INET: socket monitoring interface"
  53. + select SOCK_DIAG
  54. default y
  55. ---help---
  56. Support for INET (TCP, DCCP, etc) socket monitoring interface used by
  57. --- a/net/netlink/Kconfig
  58. +++ b/net/netlink/Kconfig
  59. @@ -4,6 +4,7 @@
  60. config NETLINK_DIAG
  61. tristate "NETLINK: socket monitoring interface"
  62. + select SOCK_DIAG
  63. default n
  64. ---help---
  65. Support for NETLINK socket monitoring interface used by the ss tool.
  66. --- a/net/packet/Kconfig
  67. +++ b/net/packet/Kconfig
  68. @@ -18,6 +18,7 @@ config PACKET
  69. config PACKET_DIAG
  70. tristate "Packet: sockets monitoring interface"
  71. depends on PACKET
  72. + select SOCK_DIAG
  73. default n
  74. ---help---
  75. Support for PF_PACKET sockets monitoring interface used by the ss tool.
  76. --- a/net/unix/Kconfig
  77. +++ b/net/unix/Kconfig
  78. @@ -22,6 +22,7 @@ config UNIX
  79. config UNIX_DIAG
  80. tristate "UNIX: socket monitoring interface"
  81. depends on UNIX
  82. + select SOCK_DIAG
  83. default n
  84. ---help---
  85. Support for UNIX socket monitoring interface used by the ss tool.