netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: diag: Tell user if support for destroying TCP sockets is not enabled
@ 2016-05-16 23:53 David Ahern
  2016-05-16 23:53 ` [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY David Ahern
  2016-05-17  0:49 ` [PATCH] net: diag: Tell user if support for destroying TCP sockets is not enabled Lorenzo Colitti
  0 siblings, 2 replies; 21+ messages in thread
From: David Ahern @ 2016-05-16 23:53 UTC (permalink / raw)
  To: netdev, lorenzo; +Cc: David Ahern

Commit c1e64e298b8c added support for destroying TCP sockets but it is
wrapped in a config option. If the option is not enabled the user is given
no feedback and ss for example just exits 0 which is not a friendly UI:

$ ss -4  state established sport = :22
Netid  Recv-Q Send-Q      Local Address:Port     Peer Address:Port
tcp    0      0           10.1.1.2:ssh           192.168.2.50:47438

$ ss -4  -K state established sport = :22 dport = :47438
Netid  Recv-Q Send-Q      Local Address:Port     Peer Address:Port
(nothing else in the output and the connection lives on).

Fix by returning an error to the user if the config option is not
enabled:

$ ss -4 -K state established sport = :22 dport = :47450
Netid  Recv-Q Send-Q      Local Address:Port     Peer Address:Port
SOCK_DESTROY answers: Operation not supported

Fixes: c1e64e298b8c ("net: diag: Support destroying TCP sockets.")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
 net/ipv4/tcp_diag.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 4d610934fb39..99590423d468 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -60,6 +60,12 @@ static int tcp_diag_destroy(struct sk_buff *in_skb,
 
 	return sock_diag_destroy(sk, ECONNABORTED);
 }
+#else
+static int tcp_diag_destroy(struct sk_buff *in_skb,
+			    const struct inet_diag_req_v2 *req)
+{
+	return -EOPNOTSUPP;
+}
 #endif
 
 static const struct inet_diag_handler tcp_diag_handler = {
@@ -68,9 +74,7 @@ static const struct inet_diag_handler tcp_diag_handler = {
 	.idiag_get_info	 = tcp_diag_get_info,
 	.idiag_type	 = IPPROTO_TCP,
 	.idiag_info_size = sizeof(struct tcp_info),
-#ifdef CONFIG_INET_DIAG_DESTROY
 	.destroy	 = tcp_diag_destroy,
-#endif
 };
 
 static int __init tcp_diag_init(void)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-05-19 15:22 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-16 23:53 [PATCH] net: diag: Tell user if support for destroying TCP sockets is not enabled David Ahern
2016-05-16 23:53 ` [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY David Ahern
2016-05-17  1:01   ` Lorenzo Colitti
2016-05-17  1:14     ` David Ahern
2016-05-17  1:20       ` Lorenzo Colitti
2016-05-17  1:52         ` David Ahern
2016-05-17  2:04           ` Lorenzo Colitti
2016-05-17  2:24             ` David Ahern
2016-05-17  2:29               ` Lorenzo Colitti
2016-05-17 18:35                 ` subashab
2016-05-18 18:51                   ` Stephen Hemminger
2016-05-19  0:55                   ` Lorenzo Colitti
2016-05-19  3:02                     ` David Ahern
2016-05-19  3:47                       ` Eric Dumazet
2016-05-19  4:05                         ` David Ahern
2016-05-19  4:12                           ` Eric Dumazet
2016-05-19 14:06                             ` David Ahern
2016-05-19 15:19                               ` Eric Dumazet
2016-05-19 15:22                               ` Lorenzo Colitti
2016-05-17  0:49 ` [PATCH] net: diag: Tell user if support for destroying TCP sockets is not enabled Lorenzo Colitti
2016-05-17  1:11   ` David Ahern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).