netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ss: handle seqpacket type of unix domain socket
@ 2014-01-08 11:13 Masatake YAMATO
  2014-01-08 11:13 ` [PATCH 2/3] ss: enable query by type in unix domain related socket Masatake YAMATO
  2014-01-08 11:13 ` [PATCH 3/3] ss: add unix_seqpacket to the help message and the man page Masatake YAMATO
  0 siblings, 2 replies; 4+ messages in thread
From: Masatake YAMATO @ 2014-01-08 11:13 UTC (permalink / raw)
  To: netdev; +Cc: yamato

ss didn't distignish seqpacket type from dgram type.
With this patch ss can distignish it.

 $ misc/ss -x -a | grep seq
 u_seq  LISTEN     0      128    /run/udev/control 10966                 * 0
 u_seq  ESTAB      0      0                    * 115103                * 115104
 u_seq  ESTAB      0      0                    * 115104                * 115103

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 misc/ss.c | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index e59ca5c..bac1f9e 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -71,6 +71,7 @@ enum
 	RAW_DB,
 	UNIX_DG_DB,
 	UNIX_ST_DB,
+	UNIX_SQ_DB,
 	PACKET_DG_DB,
 	PACKET_R_DB,
 	NETLINK_DB,
@@ -78,7 +79,7 @@ enum
 };
 
 #define PACKET_DBM ((1<<PACKET_DG_DB)|(1<<PACKET_R_DB))
-#define UNIX_DBM ((1<<UNIX_DG_DB)|(1<<UNIX_ST_DB))
+#define UNIX_DBM ((1<<UNIX_DG_DB)|(1<<UNIX_ST_DB)|(1<<UNIX_SQ_DB))
 #define ALL_DB ((1<<MAX_DB)-1)
 
 enum {
@@ -2114,6 +2115,25 @@ static void unix_list_free(struct unixstat *list)
 	}
 }
 
+static const char *unix_netid_name(int type)
+{
+	const char *netid;
+
+	switch (type) {
+	case SOCK_STREAM:
+		netid = "u_str";
+		break;
+	case SOCK_SEQPACKET:
+		netid = "u_seq";
+		break;
+	case SOCK_DGRAM:
+	default:
+		netid = "u_dgr";
+		break;
+	}
+	return netid;
+}
+
 static void unix_list_print(struct unixstat *list, struct filter *f)
 {
 	struct unixstat *s;
@@ -2126,6 +2146,8 @@ static void unix_list_print(struct unixstat *list, struct filter *f)
 			continue;
 		if (s->type == SOCK_DGRAM && !(f->dbs&(1<<UNIX_DG_DB)))
 			continue;
+		if (s->type == SOCK_SEQPACKET && !(f->dbs&(1<<UNIX_SQ_DB)))
+			continue;
 
 		peer = "*";
 		if (s->peer) {
@@ -2156,7 +2178,7 @@ static void unix_list_print(struct unixstat *list, struct filter *f)
 
 		if (netid_width)
 			printf("%-*s ", netid_width,
-			       s->type == SOCK_STREAM ? "u_str" : "u_dgr");
+			       unix_netid_name(s->type));
 		if (state_width)
 			printf("%-*s ", state_width, sstate_name[s->state]);
 		printf("%-6d %-6d ", s->rq, s->wq);
@@ -2185,7 +2207,7 @@ static int unix_show_sock(struct nlmsghdr *nlh, struct filter *f)
 
 	if (netid_width)
 		printf("%-*s ", netid_width,
-				r->udiag_type == SOCK_STREAM ? "u_str" : "u_dgr");
+		       		unix_netid_name(r->udiag_type));
 	if (state_width)
 		printf("%-*s ", state_width, sstate_name[r->udiag_state]);
 
@@ -3253,6 +3275,9 @@ int main(int argc, char *argv[])
 				} else if (strcasecmp(p, "unix_dgram") == 0 ||
 					   strcmp(p, "u_dgr") == 0) {
 					current_filter.dbs |= (1<<UNIX_DG_DB);
+				} else if (strcasecmp(p, "unix_seqpacket") == 0 ||
+					   strcmp(p, "u_seq") == 0) {
+					current_filter.dbs |= (1<<UNIX_SQ_DB);
 				} else if (strcmp(p, "packet") == 0) {
 					current_filter.dbs |= PACKET_DBM;
 				} else if (strcmp(p, "packet_raw") == 0 ||
-- 
1.8.4.2

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

* [PATCH 2/3] ss: enable query by type in unix domain related socket
  2014-01-08 11:13 [PATCH 1/3] ss: handle seqpacket type of unix domain socket Masatake YAMATO
@ 2014-01-08 11:13 ` Masatake YAMATO
  2014-01-08 11:13 ` [PATCH 3/3] ss: add unix_seqpacket to the help message and the man page Masatake YAMATO
  1 sibling, 0 replies; 4+ messages in thread
From: Masatake YAMATO @ 2014-01-08 11:13 UTC (permalink / raw)
  To: netdev; +Cc: yamato

This patch enables -A unix_stream, -A unix_dgram and
-A unix_seqpacket option even if ss gets socket information
via netlink.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 misc/ss.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/misc/ss.c b/misc/ss.c
index bac1f9e..cea3f2e 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2205,6 +2205,13 @@ static int unix_show_sock(struct nlmsghdr *nlh, struct filter *f)
 	parse_rtattr(tb, UNIX_DIAG_MAX, (struct rtattr*)(r+1),
 		     nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
 
+	if (r->udiag_type == SOCK_STREAM && !(f->dbs&(1<<UNIX_ST_DB)))
+		return 0;
+	if (r->udiag_type == SOCK_DGRAM && !(f->dbs&(1<<UNIX_DG_DB)))
+		return 0;
+	if (r->udiag_type == SOCK_SEQPACKET && !(f->dbs&(1<<UNIX_SQ_DB)))
+		return 0;
+
 	if (netid_width)
 		printf("%-*s ", netid_width,
 		       		unix_netid_name(r->udiag_type));
-- 
1.8.4.2

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

* [PATCH 3/3] ss: add unix_seqpacket to the help message and the man page
  2014-01-08 11:13 [PATCH 1/3] ss: handle seqpacket type of unix domain socket Masatake YAMATO
  2014-01-08 11:13 ` [PATCH 2/3] ss: enable query by type in unix domain related socket Masatake YAMATO
@ 2014-01-08 11:13 ` Masatake YAMATO
  2014-01-10  7:07   ` Stephen Hemminger
  1 sibling, 1 reply; 4+ messages in thread
From: Masatake YAMATO @ 2014-01-08 11:13 UTC (permalink / raw)
  To: netdev; +Cc: yamato

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 man/man8/ss.8 | 2 +-
 misc/ss.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/man/man8/ss.8 b/man/man8/ss.8
index e55dd0c..807d9dc 100644
--- a/man/man8/ss.8
+++ b/man/man8/ss.8
@@ -87,7 +87,7 @@ Currently the following families are supported: unix, inet, inet6, link, netlink
 .B \-A QUERY, \-\-query=QUERY, \-\-socket=QUERY
 List of socket tables to dump, separated by commas. The following identifiers
 are understood: all, inet, tcp, udp, raw, unix, packet, netlink, unix_dgram,
-unix_stream, packet_raw, packet_dgram.
+unix_stream, unix_seqpacket, packet_raw, packet_dgram.
 .TP
 .B \-D FILE, \-\-diag=FILE
 Do not display anything, just dump raw information about TCP sockets to FILE after applying filters. If FILE is - stdout is used.
diff --git a/misc/ss.c b/misc/ss.c
index cea3f2e..675f7c5 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -3072,7 +3072,7 @@ static void _usage(FILE *dest)
 "   -f, --family=FAMILY display sockets of type FAMILY\n"
 "\n"
 "   -A, --query=QUERY, --socket=QUERY\n"
-"       QUERY := {all|inet|tcp|udp|raw|unix|packet|netlink}[,QUERY]\n"
+"       QUERY := {all|inet|tcp|udp|raw|unix|unix_dgram|unix_stream|unix_seqpacket|packet|netlink}[,QUERY]\n"
 "\n"
 "   -D, --diag=FILE     Dump raw information about TCP sockets to FILE\n"
 "   -F, --filter=FILE   read filter information from FILE\n"
-- 
1.8.4.2

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

* Re: [PATCH 3/3] ss: add unix_seqpacket to the help message and the man page
  2014-01-08 11:13 ` [PATCH 3/3] ss: add unix_seqpacket to the help message and the man page Masatake YAMATO
@ 2014-01-10  7:07   ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2014-01-10  7:07 UTC (permalink / raw)
  To: Masatake YAMATO; +Cc: netdev

On Wed,  8 Jan 2014 20:13:48 +0900
Masatake YAMATO <yamato@redhat.com> wrote:

> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> ---
>  man/man8/ss.8 | 2 +-
>  misc/ss.c     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

All 3 applied to master since they can go directly in next release
(no dependency on net-next).

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

end of thread, other threads:[~2014-01-10  7:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-08 11:13 [PATCH 1/3] ss: handle seqpacket type of unix domain socket Masatake YAMATO
2014-01-08 11:13 ` [PATCH 2/3] ss: enable query by type in unix domain related socket Masatake YAMATO
2014-01-08 11:13 ` [PATCH 3/3] ss: add unix_seqpacket to the help message and the man page Masatake YAMATO
2014-01-10  7:07   ` Stephen Hemminger

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).