]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/commitdiff
Fix ss if INET_DIAG not enabled in kernel
authorEric Dumazet <eric.dumazet@gmail.com>
Tue, 10 Apr 2012 16:00:16 +0000 (09:00 -0700)
committerStephen Hemminger <shemminger@vyatta.com>
Tue, 10 Apr 2012 16:00:16 +0000 (09:00 -0700)
If kernel doesn't have INET_DIAG and using newish version of iproute
nothing would be displayed.

misc/ss.c

index 7beac8ddb24f7d6f4c8f3574ed334ecf539f03c9..401791892fef06255f9eb763de7f4c89dadc2318 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1534,8 +1534,10 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
                .msg_iovlen = f->f ? 3 : 1,
        };
 
-       if (sendmsg(fd, &msg, 0) < 0)
+       if (sendmsg(fd, &msg, 0) < 0) {
+               close(fd);
                return -1;
+       }
 
        iov[0] = (struct iovec){
                .iov_base = buf,
@@ -1589,6 +1591,10 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
                                        fprintf(stderr, "ERROR truncated\n");
                                } else {
                                        errno = -err->error;
+                                       if (errno == EOPNOTSUPP) {
+                                               close(fd);
+                                               return -1;
+                                       }
                                        perror("TCPDIAG answers");
                                }
                                close(fd);