]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: Do not call user_ent_hash_build() more than once
authorPeilin Ye <peilin.ye@bytedance.com>
Wed, 25 May 2022 02:52:21 +0000 (19:52 -0700)
committerDavid Ahern <dsahern@kernel.org>
Mon, 30 May 2022 15:54:01 +0000 (09:54 -0600)
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>
misc/ss.c

index c65795ebd461ad764a24b3b770d35ac6400b731c..f077bed70e6b8fe7853a51773d2dd915473c4794 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -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;