From: Eric Dumazet Date: Tue, 10 Apr 2012 16:00:16 +0000 (-0700) Subject: Fix ss if INET_DIAG not enabled in kernel X-Git-Tag: v3.4.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=930a75f9257a3e00fcfede94de5a4516fe34bd22;p=thirdparty%2Fiproute2.git Fix ss if INET_DIAG not enabled in kernel If kernel doesn't have INET_DIAG and using newish version of iproute nothing would be displayed. --- diff --git a/misc/ss.c b/misc/ss.c index 7beac8ddb..401791892 100644 --- 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);