]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: fix display of raw sockets
authorNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Wed, 15 Jul 2015 12:50:42 +0000 (05:50 -0700)
committerStephen Hemminger <shemming@brocade.com>
Mon, 20 Jul 2015 21:57:47 +0000 (14:57 -0700)
After commit 8250bc9ff4e5 ("ss: Unify inet sockets output") raw sockets
are displayed as udp because dgram_show_line() is used for both and
thus IPPROTO_UDP is used for both so proto_name() returns "udp".
Fix this by checking dg_proto which is set according to the caller of
dgram_show_line().

Reported-by: Miha Marolt <miham@beyondsemi.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
misc/ss.c

index 03f92fa692708a21ea3aa305de18a281b50e5ec1..6abd1d1206b34981d47d17f3093105f1a1a02ee4 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1552,6 +1552,8 @@ out:
 static char *proto_name(int protocol)
 {
        switch (protocol) {
+       case 0:
+               return "raw";
        case IPPROTO_UDP:
                return "udp";
        case IPPROTO_TCP:
@@ -2416,7 +2418,7 @@ static int dgram_show_line(char *line, const struct filter *f, int family)
        if (n < 9)
                opt[0] = 0;
 
-       inet_stats_print(&s, IPPROTO_UDP);
+       inet_stats_print(&s, dg_proto == UDP_PROTO ? IPPROTO_UDP : 0);
 
        if (show_details && opt[0])
                printf(" opt:\"%s\"", opt);