diff options
author | Peilin Ye <peilin.ye@bytedance.com> | 2022-05-24 19:52:21 -0700 |
---|---|---|
committer | David Ahern <dsahern@kernel.org> | 2022-05-30 09:54:01 -0600 |
commit | cd845a85681bf2851b38041587fa75605beebbe9 (patch) | |
tree | 8ed598adc8a74fb96459d8e8264dfe7ce89552e9 | |
parent | b38831bc23c40b3fa8ad518478173fa007d0cbbf (diff) | |
download | iproute2-cd845a85681bf2851b38041587fa75605beebbe9.tar.gz |
ss: Do not call user_ent_hash_build() more than once
Call user_ent_hash_build() once after the getopt_long() loop if -p, -z
or -Z is used.
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r-- | misc/ss.c | 12 |
1 files changed, 3 insertions, 9 deletions
@@ -596,13 +596,6 @@ static void user_ent_hash_build(void) char *pid_context; char *sock_context; const char *no_ctx = "unavailable"; - static int user_ent_hash_build_init; - - /* If show_users & show_proc_ctx set only do this once */ - if (user_ent_hash_build_init != 0) - return; - - user_ent_hash_build_init = 1; strlcpy(name, root, sizeof(name)); @@ -5515,7 +5508,6 @@ int main(int argc, char *argv[]) break; case 'p': show_users++; - user_ent_hash_build(); break; case 'b': show_options = 1; @@ -5650,7 +5642,6 @@ int main(int argc, char *argv[]) exit(1); } show_proc_ctx++; - user_ent_hash_build(); break; case 'N': if (netns_switch(optarg)) @@ -5685,6 +5676,9 @@ int main(int argc, char *argv[]) } } + if (show_users || show_proc_ctx || show_sock_ctx) + user_ent_hash_build(); + argc -= optind; argv += optind; |