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

* [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  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 ` David Ahern
  2016-05-17  1:01   ` Lorenzo Colitti
  2016-05-17  0:49 ` [PATCH] net: diag: Tell user if support for destroying TCP sockets is not enabled Lorenzo Colitti
  1 sibling, 1 reply; 21+ messages in thread
From: David Ahern @ 2016-05-16 23:53 UTC (permalink / raw)
  To: netdev, lorenzo; +Cc: David Ahern

Silent failures are not friendly to the user. If a command is
not supported tell the user about it.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
 misc/ss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc/ss.c b/misc/ss.c
index 23fff19d9199..bd7214c85938 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2264,7 +2264,7 @@ static int show_one_inet_sock(const struct sockaddr_nl *addr,
 	if (!(diag_arg->f->families & (1 << r->idiag_family)))
 		return 0;
 	if (diag_arg->f->kill && kill_inet_sock(h, arg) != 0) {
-		if (errno == EOPNOTSUPP || errno == ENOENT) {
+		if (errno == ENOENT) {
 			/* Socket can't be closed, or is already closed. */
 			return 0;
 		} else {
-- 
2.1.4

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

* Re: [PATCH] net: diag: Tell user if support for destroying TCP sockets is not enabled
  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  0:49 ` Lorenzo Colitti
  2016-05-17  1:11   ` David Ahern
  1 sibling, 1 reply; 21+ messages in thread
From: Lorenzo Colitti @ 2016-05-17  0:49 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev@vger.kernel.org

On Tue, May 17, 2016 at 8:53 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
> +#else
> +static int tcp_diag_destroy(struct sk_buff *in_skb,
> +                           const struct inet_diag_req_v2 *req)
> +{
> +       return -EOPNOTSUPP;
> +}
>  #endif

I don't understand why you need this. inet_diag_cmd_exact already
returns EOPNOTSUPP if tcp_diag_handler.destroy is NULL:

        else if (cmd == SOCK_DIAG_BY_FAMILY)
                err = handler->dump_one(in_skb, nlh, req);
        else if (cmd == SOCK_DESTROY && handler->destroy)
                err = handler->destroy(in_skb, req);
        else
                err = -EOPNOTSUPP;

Is this not working for some reason?

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  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
  0 siblings, 1 reply; 21+ messages in thread
From: Lorenzo Colitti @ 2016-05-17  1:01 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev@vger.kernel.org

On Tue, May 17, 2016 at 8:53 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
> @@ -2264,7 +2264,7 @@ static int show_one_inet_sock(const struct sockaddr_nl *addr,
>         if (!(diag_arg->f->families & (1 << r->idiag_family)))
>                 return 0;
>         if (diag_arg->f->kill && kill_inet_sock(h, arg) != 0) {
> -               if (errno == EOPNOTSUPP || errno == ENOENT) {
> +               if (errno == ENOENT) {
>                         /* Socket can't be closed, or is already closed. */
>                         return 0;
>                 } else {

I don't think you can do this without breaking the functionality of -K.

The else branch will cause show_one_inet_sock to return -1, which will
cause rtnl_dump_filter to abort and not close any other sockets that
the user requested killing. That's incorrect, because getting
EOPNOTSUPP on one socket doesn't necessarily mean we'll get EOPNOTSUPP
on any future sockets in the same dump.

For example, EOPNOTSUPP can just mean "this socket can't be closed
because it's a timewait or NEW_SYN_RECV socket". In hindsight it might
have been better to return EBADFD in those cases, but that still
doesn't solve the UI problem. If the user does something like "ss -K
dport = :443", the user would expect the command to kill all TCP
sockets and not just abort if there happens to be a UDP socket to port
443 (which can't be closed because UDP doesn't currently implement
SOCK_DESTROY).

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

* Re: [PATCH] net: diag: Tell user if support for destroying TCP sockets is not enabled
  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
  0 siblings, 0 replies; 21+ messages in thread
From: David Ahern @ 2016-05-17  1:11 UTC (permalink / raw)
  To: Lorenzo Colitti; +Cc: netdev@vger.kernel.org

On 5/16/16 6:49 PM, Lorenzo Colitti wrote:
> On Tue, May 17, 2016 at 8:53 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
>> +#else
>> +static int tcp_diag_destroy(struct sk_buff *in_skb,
>> +                           const struct inet_diag_req_v2 *req)
>> +{
>> +       return -EOPNOTSUPP;
>> +}
>>  #endif
>
> I don't understand why you need this. inet_diag_cmd_exact already
> returns EOPNOTSUPP if tcp_diag_handler.destroy is NULL:
>
>         else if (cmd == SOCK_DIAG_BY_FAMILY)
>                 err = handler->dump_one(in_skb, nlh, req);
>         else if (cmd == SOCK_DESTROY && handler->destroy)
>                 err = handler->destroy(in_skb, req);
>         else
>                 err = -EOPNOTSUPP;
>
> Is this not working for some reason?
>

hmmm.... kernel patch is not needed. Suppression was happening in ss.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-17  1:01   ` Lorenzo Colitti
@ 2016-05-17  1:14     ` David Ahern
  2016-05-17  1:20       ` Lorenzo Colitti
  0 siblings, 1 reply; 21+ messages in thread
From: David Ahern @ 2016-05-17  1:14 UTC (permalink / raw)
  To: Lorenzo Colitti; +Cc: netdev@vger.kernel.org

On 5/16/16 7:01 PM, Lorenzo Colitti wrote:
> On Tue, May 17, 2016 at 8:53 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
>> @@ -2264,7 +2264,7 @@ static int show_one_inet_sock(const struct sockaddr_nl *addr,
>>         if (!(diag_arg->f->families & (1 << r->idiag_family)))
>>                 return 0;
>>         if (diag_arg->f->kill && kill_inet_sock(h, arg) != 0) {
>> -               if (errno == EOPNOTSUPP || errno == ENOENT) {
>> +               if (errno == ENOENT) {
>>                         /* Socket can't be closed, or is already closed. */
>>                         return 0;
>>                 } else {
>
> I don't think you can do this without breaking the functionality of -K.
>
> The else branch will cause show_one_inet_sock to return -1, which will
> cause rtnl_dump_filter to abort and not close any other sockets that
> the user requested killing. That's incorrect, because getting
> EOPNOTSUPP on one socket doesn't necessarily mean we'll get EOPNOTSUPP
> on any future sockets in the same dump.
>
> For example, EOPNOTSUPP can just mean "this socket can't be closed
> because it's a timewait or NEW_SYN_RECV socket". In hindsight it might
> have been better to return EBADFD in those cases, but that still
> doesn't solve the UI problem. If the user does something like "ss -K
> dport = :443", the user would expect the command to kill all TCP
> sockets and not just abort if there happens to be a UDP socket to port
> 443 (which can't be closed because UDP doesn't currently implement
> SOCK_DESTROY).
>

Silently doing nothing is just as bad - or worse. I was running in 
circles trying to figure out why nothing was happening and ss was 
exiting 0.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-17  1:14     ` David Ahern
@ 2016-05-17  1:20       ` Lorenzo Colitti
  2016-05-17  1:52         ` David Ahern
  0 siblings, 1 reply; 21+ messages in thread
From: Lorenzo Colitti @ 2016-05-17  1:20 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev@vger.kernel.org

On Tue, May 17, 2016 at 10:14 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
>>
>> For example, EOPNOTSUPP can just mean "this socket can't be closed
>> because it's a timewait or NEW_SYN_RECV socket". In hindsight it might
>> have been better to return EBADFD in those cases, but that still
>> doesn't solve the UI problem. If the user does something like "ss -K
>> dport = :443", the user would expect the command to kill all TCP
>> sockets and not just abort if there happens to be a UDP socket to port
>> 443 (which can't be closed because UDP doesn't currently implement
>> SOCK_DESTROY).
>
>
> Silently doing nothing is just as bad - or worse. I was running in circles trying to figure out why nothing was happening and ss was exiting 0.


At least that's documented to be the case in the man page.

On the other hand, if your patch is applied, there will be no way to
close more than one socket if one of them returns EOPNOTSUPP. On a
busy server where things go into TIME_WAIT all the time, you might
never be able to close all sockets.

If you want to inform the user, then you could do so via the return
value of ss - e.g., return 0 if at least one socket was printed and
closed, or 1 otherwise.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-17  1:20       ` Lorenzo Colitti
@ 2016-05-17  1:52         ` David Ahern
  2016-05-17  2:04           ` Lorenzo Colitti
  0 siblings, 1 reply; 21+ messages in thread
From: David Ahern @ 2016-05-17  1:52 UTC (permalink / raw)
  To: Lorenzo Colitti; +Cc: netdev@vger.kernel.org

On 5/16/16 7:20 PM, Lorenzo Colitti wrote:
> On Tue, May 17, 2016 at 10:14 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
>>>
>>> For example, EOPNOTSUPP can just mean "this socket can't be closed
>>> because it's a timewait or NEW_SYN_RECV socket". In hindsight it might
>>> have been better to return EBADFD in those cases, but that still
>>> doesn't solve the UI problem. If the user does something like "ss -K
>>> dport = :443", the user would expect the command to kill all TCP
>>> sockets and not just abort if there happens to be a UDP socket to port
>>> 443 (which can't be closed because UDP doesn't currently implement
>>> SOCK_DESTROY).
>>
>>
>> Silently doing nothing is just as bad - or worse. I was running in circles trying to figure out why nothing was happening and ss was exiting 0.
>
>
> At least that's documented to be the case in the man page.
>
> On the other hand, if your patch is applied, there will be no way to
> close more than one socket if one of them returns EOPNOTSUPP. On a
> busy server where things go into TIME_WAIT all the time, you might
> never be able to close all sockets.
>
> If you want to inform the user, then you could do so via the return
> value of ss - e.g., return 0 if at least one socket was printed and
> closed, or 1 otherwise.
>

code is not setup to handle that. Only option seems to be at least dump 
an error message, but the message can not relate any of the specifics 
about the filter. So something like this though it dumps the message per 
socket matched by the filter. Could throttle it to once.

diff --git a/misc/ss.c b/misc/ss.c
index 23fff19d9199..1925c6fd9c36 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2264,8 +2264,12 @@ static int show_one_inet_sock(const struct 
sockaddr_nl *addr,
         if (!(diag_arg->f->families & (1 << r->idiag_family)))
                 return 0;
         if (diag_arg->f->kill && kill_inet_sock(h, arg) != 0) {
-               if (errno == EOPNOTSUPP || errno == ENOENT) {
-                       /* Socket can't be closed, or is already closed. */
+               if (errno == ENOENT) {
+                       /* socket is already closed. */
+                       return 0;
+               /* Socket can't be closed OR config is not enabled */
+               } else if (errno == EOPNOTSUPP) {
+                       perror("SOCK_DESTROY answers");
                         return 0;
                 } else {
                         perror("SOCK_DESTROY answers");

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-17  1:52         ` David Ahern
@ 2016-05-17  2:04           ` Lorenzo Colitti
  2016-05-17  2:24             ` David Ahern
  0 siblings, 1 reply; 21+ messages in thread
From: Lorenzo Colitti @ 2016-05-17  2:04 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev@vger.kernel.org, David Ahern

On Tue, May 17, 2016 at 10:52 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
> code is not setup to handle that. Only option seems to be at least dump an
> error message, but the message can not relate any of the specifics about the
> filter. So something like this though it dumps the message per socket
> matched by the filter. Could throttle it to once.
> [...]
>         if (diag_arg->f->kill && kill_inet_sock(h, arg) != 0) {
> -               if (errno == EOPNOTSUPP || errno == ENOENT) {
> -                       /* Socket can't be closed, or is already closed. */
> +               if (errno == ENOENT) {
> +                       /* socket is already closed. */
> +                       return 0;
> +               /* Socket can't be closed OR config is not enabled */
> +               } else if (errno == EOPNOTSUPP) {
> +                       perror("SOCK_DESTROY answers");

The reason the code was written like that is that I didn't want to
print one error message for every socket that can't be closed - such
as TIME_WAIT sockets or UDP sockets.

Given that the filter can specify a number of sockets, some of which
can and some of which can't be closed, and that whether a given socket
can be closed is only known at the time we attempt to close it, there
is a choice between two bad outcomes:

1. Users try to use "ss -K" with a kernel that doesn't support it, and
get confused about why it does nothing and doesn't print an error
message.
2. Users use "ss -K" with a kernel that does support it, and get
irritated by seeing one error message per TCP_TIME_WAIT socket, UDP
socket, etc.

Personally I think it's more important to avoid #2 than #1, because #1
is one time (only if you're compiling your own kernel), but #2 is
forever. Also, I think it's consistent with other behaviours in ss -
for example, if the kernel doesn't support SOCK_DIAG for UDP, you just
get nothing back if you run "ss -u".

That said, I'm not the maintainer of this code. Stephen, any thoughts?

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-17  2:04           ` Lorenzo Colitti
@ 2016-05-17  2:24             ` David Ahern
  2016-05-17  2:29               ` Lorenzo Colitti
  0 siblings, 1 reply; 21+ messages in thread
From: David Ahern @ 2016-05-17  2:24 UTC (permalink / raw)
  To: Lorenzo Colitti, Stephen Hemminger; +Cc: netdev@vger.kernel.org

On 5/16/16 8:04 PM, Lorenzo Colitti wrote:
> Given that the filter can specify a number of sockets, some of which
> can and some of which can't be closed, and that whether a given socket
> can be closed is only known at the time we attempt to close it, there
> is a choice between two bad outcomes:
>
> 1. Users try to use "ss -K" with a kernel that doesn't support it, and
> get confused about why it does nothing and doesn't print an error
> message.
> 2. Users use "ss -K" with a kernel that does support it, and get
> irritated by seeing one error message per TCP_TIME_WAIT socket, UDP
> socket, etc.

As I mentioned we can print the unsupported once or per socket matched 
and with the socket params. e.g.,

+               } else if (errno == EOPNOTSUPP) {
+                       printf("Operation not supported for:\n");
+                       inet_show_sock(h, diag_arg->f, diag_arg->protocol);

Actively suppressing all error messages is just wrong. I get the 
flooding issue so I'm fine with just printing it once.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-17  2:24             ` David Ahern
@ 2016-05-17  2:29               ` Lorenzo Colitti
  2016-05-17 18:35                 ` subashab
  0 siblings, 1 reply; 21+ messages in thread
From: Lorenzo Colitti @ 2016-05-17  2:29 UTC (permalink / raw)
  To: David Ahern; +Cc: Stephen Hemminger, netdev@vger.kernel.org

On Tue, May 17, 2016 at 11:24 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
> As I mentioned we can print the unsupported once or per socket matched and
> with the socket params. e.g.,
>
> +               } else if (errno == EOPNOTSUPP) {
> +                       printf("Operation not supported for:\n");
> +                       inet_show_sock(h, diag_arg->f, diag_arg->protocol);
>
> Actively suppressing all error messages is just wrong. I get the flooding
> issue so I'm fine with just printing it once.

I disagree, but then I'm the one who wrote it in the first place, so
you wouldn't expect me to agree. :-) Let's see what Stephen says.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  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
  0 siblings, 2 replies; 21+ messages in thread
From: subashab @ 2016-05-17 18:35 UTC (permalink / raw)
  To: Lorenzo Colitti; +Cc: David Ahern, Stephen Hemminger, netdev, netdev-owner

On 2016-05-16 20:29, Lorenzo Colitti wrote:
> On Tue, May 17, 2016 at 11:24 AM, David Ahern <dsa@cumulusnetworks.com> 
> wrote:
>> As I mentioned we can print the unsupported once or per socket matched 
>> and
>> with the socket params. e.g.,
>> 
>> +               } else if (errno == EOPNOTSUPP) {
>> +                       printf("Operation not supported for:\n");
>> +                       inet_show_sock(h, diag_arg->f, 
>> diag_arg->protocol);
>> 
>> Actively suppressing all error messages is just wrong. I get the 
>> flooding
>> issue so I'm fine with just printing it once.
> 
> I disagree, but then I'm the one who wrote it in the first place, so
> you wouldn't expect me to agree. :-) Let's see what Stephen says.

Hi Lorenzo

Would it be acceptable to have a separate column which displays the 
result of the sock destroy operation per socket.
State    ... Killed
ESTAB         Y
TIME_WAIT     N

If it is not supported from kernel, maybe print U (unsupported) for 
this.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-17 18:35                 ` subashab
@ 2016-05-18 18:51                   ` Stephen Hemminger
  2016-05-19  0:55                   ` Lorenzo Colitti
  1 sibling, 0 replies; 21+ messages in thread
From: Stephen Hemminger @ 2016-05-18 18:51 UTC (permalink / raw)
  To: subashab; +Cc: Lorenzo Colitti, David Ahern, netdev, netdev-owner

On Tue, 17 May 2016 12:35:53 -0600
subashab@codeaurora.org wrote:

> On 2016-05-16 20:29, Lorenzo Colitti wrote:
> > On Tue, May 17, 2016 at 11:24 AM, David Ahern <dsa@cumulusnetworks.com> 
> > wrote:
> >> As I mentioned we can print the unsupported once or per socket matched 
> >> and
> >> with the socket params. e.g.,
> >> 
> >> +               } else if (errno == EOPNOTSUPP) {
> >> +                       printf("Operation not supported for:\n");
> >> +                       inet_show_sock(h, diag_arg->f, 
> >> diag_arg->protocol);
> >> 
> >> Actively suppressing all error messages is just wrong. I get the 
> >> flooding
> >> issue so I'm fine with just printing it once.
> > 
> > I disagree, but then I'm the one who wrote it in the first place, so
> > you wouldn't expect me to agree. :-) Let's see what Stephen says.
> 
> Hi Lorenzo
> 
> Would it be acceptable to have a separate column which displays the 
> result of the sock destroy operation per socket.
> State    ... Killed
> ESTAB         Y
> TIME_WAIT     N
> 
> If it is not supported from kernel, maybe print U (unsupported) for 
> this.

When you guys come to a conclusion, then I will review the result.
Right now neither solution looks good.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  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
  1 sibling, 1 reply; 21+ messages in thread
From: Lorenzo Colitti @ 2016-05-19  0:55 UTC (permalink / raw)
  To: Subash Abhinov Kasiviswanathan
  Cc: David Ahern, Stephen Hemminger, netdev@vger.kernel.org,
	netdev-owner, David Miller, Eric Dumazet,
	Maciej Żenczykowski, Tom Herbert

On Wed, May 18, 2016 at 3:35 AM, <subashab@codeaurora.org> wrote:
> Would it be acceptable to have a separate column which displays the result of the sock destroy operation per socket.
> State    ... Killed
> ESTAB         Y
> TIME_WAIT     N

Fine by me, but... what problem are we trying to address? People who
compile their own kernels and don't turn CONFIG_INET_DIAG_DESTROY, and
then are confused why it doesn't work? Seems like we could fix that by
turning CONFIG_INET_DIAG_DESTROY on by default. CCing the people who
commented on the original SOCK_DESTROY patch to see if they have
opinions.

> If it is not supported from kernel, maybe print U (unsupported) for this.

In current code there is no way to distinguish U from N because in
both cases the error will be EOPNOTSUPP. It's certainly possible to
change SOCK_DESTROY to return something else (e.g., EBADFD) to
indicate "kernel supports closing this type of socket, but it can't be
closed due to the state it's in". In hindsight, perhaps I should have
done that from the start.

Regardless, we still have the problem of what to do if the user says
"ss -K dport = :443" and we encounter a UDP socket connected to port
443. Options:

1. Silently skip. if the tool prints something, it means it closed it.
2. Abort with an error message.
3. Skip the socket and print an error every time this happens.
4. Skip the socket and print an error the first time this happens.

Personally I still think #1 is the best option.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-19  0:55                   ` Lorenzo Colitti
@ 2016-05-19  3:02                     ` David Ahern
  2016-05-19  3:47                       ` Eric Dumazet
  0 siblings, 1 reply; 21+ messages in thread
From: David Ahern @ 2016-05-19  3:02 UTC (permalink / raw)
  To: Lorenzo Colitti, Subash Abhinov Kasiviswanathan
  Cc: Stephen Hemminger, netdev@vger.kernel.org, netdev-owner,
	David Miller, Eric Dumazet, Maciej Żenczykowski, Tom Herbert

On 5/18/16 6:55 PM, Lorenzo Colitti wrote:
> On Wed, May 18, 2016 at 3:35 AM, <subashab@codeaurora.org> wrote:
>> Would it be acceptable to have a separate column which displays the result of the sock destroy operation per socket.
>> State    ... Killed
>> ESTAB         Y
>> TIME_WAIT     N
>
> Fine by me, but... what problem are we trying to address? People who
> compile their own kernels and don't turn CONFIG_INET_DIAG_DESTROY, and
> then are confused why it doesn't work? Seems like we could fix that by
> turning CONFIG_INET_DIAG_DESTROY on by default. CCing the people who
> commented on the original SOCK_DESTROY patch to see if they have
> opinions.

The problem is proper feedback to a user. If the kernel supports an 
action but the action is not enabled the user should get some message to 
that fact. Doing nothing and exiting 0 is just wrong.

>
>> If it is not supported from kernel, maybe print U (unsupported) for this.
>
> In current code there is no way to distinguish U from N because in
> both cases the error will be EOPNOTSUPP. It's certainly possible to
> change SOCK_DESTROY to return something else (e.g., EBADFD) to
> indicate "kernel supports closing this type of socket, but it can't be
> closed due to the state it's in". In hindsight, perhaps I should have
> done that from the start.
>
> Regardless, we still have the problem of what to do if the user says
> "ss -K dport = :443" and we encounter a UDP socket connected to port
> 443. Options:
>
> 1. Silently skip. if the tool prints something, it means it closed it.
> 2. Abort with an error message.
> 3. Skip the socket and print an error every time this happens.
> 4. Skip the socket and print an error the first time this happens.
>
> Personally I still think #1 is the best option.

5. Print an error the first time and a summary at the end.

If the filter matches N sockets and all N fail with UNSUPPORTED give the 
user a message saying that all failed due to unsupported error which 
could mean the CONFIG option is not enabled or it could mean the sockets 
can not be forced closed.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-19  3:02                     ` David Ahern
@ 2016-05-19  3:47                       ` Eric Dumazet
  2016-05-19  4:05                         ` David Ahern
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Dumazet @ 2016-05-19  3:47 UTC (permalink / raw)
  To: David Ahern
  Cc: Lorenzo Colitti, Subash Abhinov Kasiviswanathan,
	Stephen Hemminger, netdev@vger.kernel.org, netdev-owner,
	David Miller, Maciej Żenczykowski, Tom Herbert

On Wed, 2016-05-18 at 21:02 -0600, David Ahern wrote:
> On 5/18/16 6:55 PM, Lorenzo Colitti wrote:
> > On Wed, May 18, 2016 at 3:35 AM, <subashab@codeaurora.org> wrote:
> >> Would it be acceptable to have a separate column which displays the result of the sock destroy operation per socket.
> >> State    ... Killed
> >> ESTAB         Y
> >> TIME_WAIT     N
> >
> > Fine by me, but... what problem are we trying to address? People who
> > compile their own kernels and don't turn CONFIG_INET_DIAG_DESTROY, and
> > then are confused why it doesn't work? Seems like we could fix that by
> > turning CONFIG_INET_DIAG_DESTROY on by default. CCing the people who
> > commented on the original SOCK_DESTROY patch to see if they have
> > opinions.
> 
> The problem is proper feedback to a user. If the kernel supports an 
> action but the action is not enabled the user should get some message to 
> that fact. Doing nothing and exiting 0 is just wrong.

So, lets say the filter found 123456 sockets matching the filter, and
12345 could be killed

What would be exit status of ss command ?

In this case, there is no black/white answer.

It looks like you have specific needs, you should probably add an option
to ss to have a specific behavior.

But saying current behavior is 'wrong' is subjective.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-19  3:47                       ` Eric Dumazet
@ 2016-05-19  4:05                         ` David Ahern
  2016-05-19  4:12                           ` Eric Dumazet
  0 siblings, 1 reply; 21+ messages in thread
From: David Ahern @ 2016-05-19  4:05 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Lorenzo Colitti, Subash Abhinov Kasiviswanathan,
	Stephen Hemminger, netdev@vger.kernel.org, netdev-owner,
	David Miller, Maciej Żenczykowski, Tom Herbert

On 5/18/16 9:47 PM, Eric Dumazet wrote:
> On Wed, 2016-05-18 at 21:02 -0600, David Ahern wrote:
>> On 5/18/16 6:55 PM, Lorenzo Colitti wrote:
>>> On Wed, May 18, 2016 at 3:35 AM, <subashab@codeaurora.org> wrote:
>>>> Would it be acceptable to have a separate column which displays the result of the sock destroy operation per socket.
>>>> State    ... Killed
>>>> ESTAB         Y
>>>> TIME_WAIT     N
>>>
>>> Fine by me, but... what problem are we trying to address? People who
>>> compile their own kernels and don't turn CONFIG_INET_DIAG_DESTROY, and
>>> then are confused why it doesn't work? Seems like we could fix that by
>>> turning CONFIG_INET_DIAG_DESTROY on by default. CCing the people who
>>> commented on the original SOCK_DESTROY patch to see if they have
>>> opinions.
>>
>> The problem is proper feedback to a user. If the kernel supports an
>> action but the action is not enabled the user should get some message to
>> that fact. Doing nothing and exiting 0 is just wrong.
>
> So, lets say the filter found 123456 sockets matching the filter, and
> 12345 could be killed
>
> What would be exit status of ss command ?

Again, I could care less if the exit status is 0 if the user is given "A 
request failed b/c operations is not supported" message. That is feedback.

>
> In this case, there is no black/white answer.
>
> It looks like you have specific needs, you should probably add an option
> to ss to have a specific behavior.
>
> But saying current behavior is 'wrong' is subjective.

You think it is ok to send a request to the kernel, the kernel says "I 
can't do it" and the command says nothing to the user? That is current 
behavior. How on Earth is that acceptable?

I believe my last proposal is that that user gets a single "I could not 
do what you asked" message and nice little summary:

N sockets closed
M sockets failed

If M = total number of sockets then perhaps there is a bigger problem -- 
like a config option is not enabled.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-19  4:05                         ` David Ahern
@ 2016-05-19  4:12                           ` Eric Dumazet
  2016-05-19 14:06                             ` David Ahern
  0 siblings, 1 reply; 21+ messages in thread
From: Eric Dumazet @ 2016-05-19  4:12 UTC (permalink / raw)
  To: David Ahern
  Cc: Lorenzo Colitti, Subash Abhinov Kasiviswanathan,
	Stephen Hemminger, netdev@vger.kernel.org, netdev-owner,
	David Miller, Maciej Żenczykowski, Tom Herbert

On Wed, 2016-05-18 at 22:05 -0600, David Ahern wrote:

> You think it is ok to send a request to the kernel, the kernel says "I 
> can't do it" and the command says nothing to the user? That is current 
> behavior. How on Earth is that acceptable?

I don't know. Tell me what is acceptable on a 'dump many sockets' and
some of them can be killed, but not all of them.

What I do know is that you sent totally buggy patches.

If you want to 'fix' something, please send a patch that we can agree
on, ie not breaking existing scripts.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  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
  0 siblings, 2 replies; 21+ messages in thread
From: David Ahern @ 2016-05-19 14:06 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Lorenzo Colitti, Subash Abhinov Kasiviswanathan,
	Stephen Hemminger, netdev@vger.kernel.org, netdev-owner,
	David Miller, Maciej Żenczykowski, Tom Herbert

On 5/18/16 10:12 PM, Eric Dumazet wrote:
> On Wed, 2016-05-18 at 22:05 -0600, David Ahern wrote:
>
>> You think it is ok to send a request to the kernel, the kernel says "I
>> can't do it" and the command says nothing to the user? That is current
>> behavior. How on Earth is that acceptable?
>
> I don't know. Tell me what is acceptable on a 'dump many sockets' and
> some of them can be killed, but not all of them.
>
> What I do know is that you sent totally buggy patches.

buggy patches? not silently dropping a failure makes for a buggy patch?

>
> If you want to 'fix' something, please send a patch that we can agree
> on, ie not breaking existing scripts.

got it. Google does not care about users; don't un-suppress failures.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-19 14:06                             ` David Ahern
@ 2016-05-19 15:19                               ` Eric Dumazet
  2016-05-19 15:22                               ` Lorenzo Colitti
  1 sibling, 0 replies; 21+ messages in thread
From: Eric Dumazet @ 2016-05-19 15:19 UTC (permalink / raw)
  To: David Ahern
  Cc: Lorenzo Colitti, Subash Abhinov Kasiviswanathan,
	Stephen Hemminger, netdev@vger.kernel.org, netdev-owner,
	David Miller, Maciej Żenczykowski, Tom Herbert

On Thu, 2016-05-19 at 08:06 -0600, David Ahern wrote:
> On 5/18/16 10:12 PM, Eric Dumazet wrote:
> > On Wed, 2016-05-18 at 22:05 -0600, David Ahern wrote:
> >
> >> You think it is ok to send a request to the kernel, the kernel says "I
> >> can't do it" and the command says nothing to the user? That is current
> >> behavior. How on Earth is that acceptable?
> >
> > I don't know. Tell me what is acceptable on a 'dump many sockets' and
> > some of them can be killed, but not all of them.
> >
> > What I do know is that you sent totally buggy patches.
> 
> buggy patches? not silently dropping a failure makes for a buggy patch?

You sent one kernel patch that was useless, then an iproute2 patch that
was simply aborting the dump.

Really, if you want fix things, do this properly instead of simply
ranting about work done by others, even if they are working for Google.

Thank you.

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

* Re: [PATCH iproute2] ss: Tell user about -EOPNOTSUPP for SOCK_DESTROY
  2016-05-19 14:06                             ` David Ahern
  2016-05-19 15:19                               ` Eric Dumazet
@ 2016-05-19 15:22                               ` Lorenzo Colitti
  1 sibling, 0 replies; 21+ messages in thread
From: Lorenzo Colitti @ 2016-05-19 15:22 UTC (permalink / raw)
  To: David Ahern
  Cc: Eric Dumazet, Subash Abhinov Kasiviswanathan, Stephen Hemminger,
	netdev@vger.kernel.org, netdev-owner, David Miller,
	Maciej Żenczykowski, Tom Herbert

On Thu, May 19, 2016 at 11:06 PM, David Ahern <dsa@cumulusnetworks.com> wrote:
> got it. Google does not care about users; don't un-suppress failures.

The users I was trying to care about are the ones that have correctly
configured kernels. It did not seem useful to those users to litter
the dumps with error messages saying that the kernel could not close a
socket that cannot be closed.

^ permalink raw reply	[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).