ss: Filtering fixes for unix & netlink socks
Subsystems (2)
cover ss: Filtering fixes for unix & netlink socks
Some fixes when filtering unix & netlink sockets.
Vadim Kochan (2):
ss: Add filter before printing unix stats from Netlink
ss: Skip filtered netlink sockets before detailed info
misc/ss.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Signature · 1 line
2.2.2
PATCH 1/2 ss: Add filter before printing unix stats from Netlink
From: Vadim Kochan <[email protected]>
Detailed info can be printed if filter should not pass the socket info.
Signed-off-by Vadim Kochan <[email protected]>
--- misc/ss.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
misc/ss.c +4 -1
@@ -2556,7 +2556,7 @@ static void unix_stats_print(struct sockstat *list, struct filter *f) } } -if (f->f) { +if (use_proc && f->f) {if (strcmp (peer,"*" ) ==0 )memset (s->remote.data,0 ,sizeof (char *));else
@@ -2628,6 +2628,9 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh,if (tb[UNIX_DIAG_PEER ]) stat.rport =rta_getattr_u32 (tb[UNIX_DIAG_PEER ]); +if (f->f &&run_ssfilter (f->f, &stat) ==0 ) +return 0 ; +unix_stats_print (&stat, f);if (show_mem) {
Signature · 1 line
2.2.2
PATCH 2/2 ss: Skip filtered netlink sockets before detailed info
In reply to Vadim KochanFrom: Vadim Kochan <[email protected]>
Signed-off-by Vadim Kochan <[email protected]>
--- misc/ss.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
misc/ss.c +7 -5
@@ -2938,7 +2938,7 @@ static int packet_show(struct filter *f)return 0 ; } -static void netlink_show_one(struct filter *f, +static int netlink_show_one(struct filter *f, int prot, int pid, unsigned groups, int state, int dst_pid, unsigned dst_group, int rq, int wq,
@@ -2960,7 +2960,7 @@ static void netlink_show_one(struct filter *f, st.lport = pid; st.local.data[0 ] = prot;if (run_ssfilter (f->f, &st) ==0 ) -return ; +return 1 ; }sock_state_print (&st,"nl" );
@@ -3032,7 +3032,7 @@ static void netlink_show_one(struct filter *f, }printf ("\n" ); -return ; +return 0 ; } static int netlink_show_sock(const struct sockaddr_nl *addr,
@@ -3058,9 +3058,11 @@ static int netlink_show_sock(const struct sockaddr_nl *addr, wq = skmeminfo[SK_MEMINFO_WMEM_ALLOC ]; } -netlink_show_one (f, r->ndiag_protocol, r->ndiag_portid, groups, +if (netlink_show_one (f, r->ndiag_protocol, r->ndiag_portid, groups, r->ndiag_state, r->ndiag_dst_portid, r->ndiag_dst_group, - rq, wq,0 ,0 ); + rq, wq,0 ,0 )) { +return 0 ; + }if (show_mem) {printf ("\t" );
Signature · 1 line
2.2.2
Stephen Hemminger
AppliedQuoted 9 lines · On Sun, 22 Feb 2015 22:23:09 +0200 Vadim Kochan <[email protected]> wrote:
Some fixes when filtering unix & netlink sockets.
Vadim Kochan (2):
ss: Add filter before printing unix stats from Netlink
ss: Skip filtered netlink sockets before detailed infomisc/ss.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Applied