ss: Fix accidental state filter override

Passing a filter expression and selecting an address family using the
'-f' flag would overwrite the state filter by accident. Therefore
calling e.g. 'ss -nl -f inet '(sport = :22)' would not only print
listening sockets (as requested by '-l' flag) but connected ones, as
well.

Fix this by reusing the formerly ineffective call to filter_states_set()
to restore the state filter as it was before the call to
filter_af_set().

Signed-off-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
Phil Sutter 2016-04-13 22:07:05 +02:00 committed by Stephen Hemminger
parent 9d320e1e92
commit e56a959e55
1 changed files with 2 additions and 1 deletions

View File

@ -1556,9 +1556,10 @@ void *parse_hostcond(char *addr, bool is_port)
out:
if (fam != AF_UNSPEC) {
int states = f->states;
f->families = 0;
filter_af_set(f, fam);
filter_states_set(f, 0);
filter_states_set(f, states);
}
res = malloc(sizeof(*res));