All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] ss: Identify a lot of netlink protocol names
@ 2014-10-16 16:46 Vadim Kochan
  2014-10-30  5:49 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Vadim Kochan @ 2014-10-16 16:46 UTC (permalink / raw)
  To: netdev; +Cc: Vadim Kochan

There were only few Netlink protocol names:

    rtnl, fw, tcpdiag

which were printed on output.
So added the other ones.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
---
 misc/ss.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 6 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index 2420b51..576db4e 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2960,12 +2960,63 @@ static int packet_show(struct filter *f)
 	return 0;
 }
 
+static char *netlink_proto_name(int proto)
+{
+	switch (proto)
+	{
+	case NETLINK_ROUTE:
+		return "rtnl";
+	case NETLINK_USERSOCK:
+		return "user";
+	case NETLINK_FIREWALL:
+		return "fw";
+	case NETLINK_SOCK_DIAG:
+		return "tcpdiag";
+	case NETLINK_NFLOG:
+		return "nflog";
+	case NETLINK_XFRM:
+		return "xfrm";
+	case NETLINK_SELINUX:
+		return "selinux";
+	case NETLINK_ISCSI:
+		return "iscsi";
+	case NETLINK_AUDIT:
+		return "audit";
+	case NETLINK_FIB_LOOKUP:
+		return "fiblookup";
+	case NETLINK_CONNECTOR:
+		return "conn";
+	case NETLINK_NETFILTER:
+		return "nft";
+	case NETLINK_IP6_FW:
+		return "ip6fw";
+	case NETLINK_DNRTMSG:
+		return "decrt";
+	case NETLINK_KOBJECT_UEVENT:
+		return "uevent";
+	case NETLINK_GENERIC:
+		return "genl";
+	case NETLINK_SCSITRANSPORT:
+		return "scsitrans";
+	case NETLINK_ECRYPTFS:
+		return "ecryptfs";
+	case NETLINK_RDMA:
+		return "rdma";
+	case NETLINK_CRYPTO:
+		return "crypto";
+	}
+
+	return NULL;
+};
+
 static void netlink_show_one(struct filter *f,
 				int prot, int pid, unsigned groups,
 				int state, int dst_pid, unsigned dst_group,
 				int rq, int wq,
 				unsigned long long sk, unsigned long long cb)
 {
+	char *prot_name;
+
 	if (f->f) {
 		struct tcpstat tst;
 		tst.local.family = AF_NETLINK;
@@ -2983,14 +3034,12 @@ static void netlink_show_one(struct filter *f,
 	if (state_width)
 		printf("%-*s ", state_width, "UNCONN");
 	printf("%-6d %-6d ", rq, wq);
-	if (resolve_services && prot == 0)
-		printf("%*s:", addr_width, "rtnl");
-	else if (resolve_services && prot == 3)
-		printf("%*s:", addr_width, "fw");
-	else if (resolve_services && prot == 4)
-		printf("%*s:", addr_width, "tcpdiag");
+
+	if (resolve_services && (prot_name = netlink_proto_name(prot)))
+		printf("%*s:", addr_width, prot_name);
 	else
 		printf("%*d:", addr_width, prot);
+
 	if (pid == -1) {
 		printf("%-*s ", serv_width, "*");
 	} else if (resolve_services) {
-- 
2.1.0

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

* Re: [PATCH iproute2] ss: Identify a lot of netlink protocol names
  2014-10-16 16:46 [PATCH iproute2] ss: Identify a lot of netlink protocol names Vadim Kochan
@ 2014-10-30  5:49 ` Stephen Hemminger
  2014-10-30 15:26   ` vadim4j
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2014-10-30  5:49 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: netdev

On Thu, 16 Oct 2014 19:46:58 +0300
Vadim Kochan <vadim4j@gmail.com> wrote:

> There were only few Netlink protocol names:
> 
>     rtnl, fw, tcpdiag
> 
> which were printed on output.
> So added the other ones.
> 
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>

Please make this driven off of a file in /etc/iproute2/ rather than
hard coding a big switch in the code.

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

* Re: [PATCH iproute2] ss: Identify a lot of netlink protocol names
  2014-10-30  5:49 ` Stephen Hemminger
@ 2014-10-30 15:26   ` vadim4j
  0 siblings, 0 replies; 3+ messages in thread
From: vadim4j @ 2014-10-30 15:26 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

On Wed, Oct 29, 2014 at 10:49:32PM -0700, Stephen Hemminger wrote:
> On Thu, 16 Oct 2014 19:46:58 +0300
> Vadim Kochan <vadim4j@gmail.com> wrote:
> 
> > There were only few Netlink protocol names:
> > 
> >     rtnl, fw, tcpdiag
> > 
> > which were printed on output.
> > So added the other ones.
> > 
> > Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> 
> Please make this driven off of a file in /etc/iproute2/ rather than
> hard coding a big switch in the code.
> 
Yes, good idea, will do.

Regards,

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

end of thread, other threads:[~2014-10-30 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-16 16:46 [PATCH iproute2] ss: Identify a lot of netlink protocol names Vadim Kochan
2014-10-30  5:49 ` Stephen Hemminger
2014-10-30 15:26   ` vadim4j

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.