[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1327939545.2297.11.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC>
Date: Mon, 30 Jan 2012 17:05:45 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: Stephen Hemminger <shemminger@...tta.com>
Cc: netdev <netdev@...r.kernel.org>,
Pavel Emelyanov <xemul@...allels.com>
Subject: [PATCH iproute2] ss: should support CONFIG_INET_UDP_DIAG=n kernels
ss -x currently fails if CONFIG_INET_UDP_DIAG=n or old kernels
Also close file descriptors while we are at it.
Signed-off-by: Eric Dumazet <eric.dumazet@...il.com>
Cc: Pavel Emelyanov <xemul@...allels.com>
---
misc/ss.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index 7a15d69..eb42fd6 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2092,8 +2092,10 @@ static int unix_show_netlink(struct filter *f, FILE *dump_fp)
.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,
@@ -2121,6 +2123,7 @@ static int unix_show_netlink(struct filter *f, FILE *dump_fp)
}
if (status == 0) {
fprintf(stderr, "EOF on netlink\n");
+ close(fd);
return 0;
}
@@ -2135,22 +2138,28 @@ static int unix_show_netlink(struct filter *f, FILE *dump_fp)
h->nlmsg_seq != 123456)
goto skip_it;
- if (h->nlmsg_type == NLMSG_DONE)
+ if (h->nlmsg_type == NLMSG_DONE) {
+ close(fd);
return 0;
+ }
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) {
fprintf(stderr, "ERROR truncated\n");
} else {
errno = -err->error;
- perror("TCPDIAG answers");
+ if (errno != ENOENT)
+ fprintf(stderr, "UDIAG answers %d\n", errno);
}
- return 0;
+ close(fd);
+ return -1;
}
if (!dump_fp) {
err = unix_show_sock(h, f);
- if (err < 0)
+ if (err < 0) {
+ close(fd);
return err;
+ }
}
skip_it:
@@ -2165,6 +2174,7 @@ skip_it:
exit(1);
}
}
+ close(fd);
return 0;
}
@@ -2241,7 +2251,7 @@ int unix_show(struct filter *f)
cnt = 0;
}
}
-
+ fclose(fp);
if (list) {
unix_list_print(list, f);
unix_list_free(list);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists