]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: Dont show netlink and packet sockets by default
authorVadim Kochan <vadim4j@gmail.com>
Sat, 20 Dec 2014 23:40:55 +0000 (15:40 -0800)
committerStephen Hemminger <shemming@brocade.com>
Sat, 20 Dec 2014 23:43:56 +0000 (15:43 -0800)
Checking by SS_CLOSE state was remowed in:

    (45a4770bc0) ss: Remove checking SS_CLOSE state for packet and netlink

which is not really correct because now by default all sockets are seen
when do 'ss'.

Here is most correct fix which considers specified family.

To see netlink sockets:
    ss -A netlink

To see packet sockets:
    ss -A packet

And ss by default will show only connected/established sockets as it
was before all the time.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
misc/ss.c

index 15fa2bc526ceb48b30770c0712d049e28fe0483e..fa73fac3b92e7e2706755c199b06962e8d36c75e 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -2743,6 +2743,9 @@ static int packet_show(struct filter *f)
        int uid;
        int ino;
        unsigned long long sk;
+       if (preferred_family != AF_PACKET && !(f->states & (1 << SS_CLOSE)))
+               return 0;
 
        if (packet_show_netlink(f) == 0)
                return 0;
@@ -2972,6 +2975,9 @@ static int netlink_show(struct filter *f)
        int rq, wq, rc;
        unsigned long long sk, cb;
 
+       if (preferred_family != AF_NETLINK && !(f->states & (1 << SS_CLOSE)))
+               return 0;
+
        if (!getenv("PROC_NET_NETLINK") && !getenv("PROC_ROOT") &&
                netlink_show_netlink(f) == 0)
                return 0;