[PATCH] linux-user: do not print IP socket options by default

Łukasz Stelmach posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250827095412.2348821-1-l.stelmach@samsung.com
linux-user/strace.c | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
[PATCH] linux-user: do not print IP socket options by default
Posted by Łukasz Stelmach 1 month ago
IP protocols should not be printed unless the socket is an IPv4 or
IPv6 one. Current arrangement erroneously prints IPPROTO_IP for Unix
domain sockets.

Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
---
 linux-user/strace.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git linux-user/strace.c linux-user/strace.c
index 3b744ccd4a..786354627a 100644
--- linux-user/strace.c
+++ linux-user/strace.c
@@ -586,23 +586,27 @@ print_socket_protocol(int domain, int type, int protocol)
         return;
     }
 
-    switch (protocol) {
-    case IPPROTO_IP:
-        qemu_log("IPPROTO_IP");
-        break;
-    case IPPROTO_TCP:
-        qemu_log("IPPROTO_TCP");
-        break;
-    case IPPROTO_UDP:
-        qemu_log("IPPROTO_UDP");
-        break;
-    case IPPROTO_RAW:
-        qemu_log("IPPROTO_RAW");
-        break;
-    default:
-        qemu_log("%d", protocol);
-        break;
+    if (domain == AF_INET || domain == AF_INET6) {
+        switch (protocol) {
+        case IPPROTO_IP:
+            qemu_log("IPPROTO_IP");
+            break;
+        case IPPROTO_TCP:
+            qemu_log("IPPROTO_TCP");
+            break;
+        case IPPROTO_UDP:
+            qemu_log("IPPROTO_UDP");
+            break;
+        case IPPROTO_RAW:
+            qemu_log("IPPROTO_RAW");
+            break;
+        default:
+            qemu_log("%d", protocol);
+            break;
+        }
+        return;
     }
+    qemu_log("%d", protocol);
 }
 
 
-- 
2.39.5


Re: [PATCH] linux-user: do not print IP socket options by default
Posted by Philippe Mathieu-Daudé 1 month ago
On 27/8/25 11:54, Łukasz Stelmach wrote:
> IP protocols should not be printed unless the socket is an IPv4 or
> IPv6 one. Current arrangement erroneously prints IPPROTO_IP for Unix
> domain sockets.
> 
> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
> ---
>   linux-user/strace.c | 36 ++++++++++++++++++++----------------
>   1 file changed, 20 insertions(+), 16 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Re: [PATCH] linux-user: do not print IP socket options by default
Posted by Richard Henderson 1 month ago
On 8/27/25 19:54, Łukasz Stelmach wrote:
> IP protocols should not be printed unless the socket is an IPv4 or
> IPv6 one. Current arrangement erroneously prints IPPROTO_IP for Unix
> domain sockets.
> 
> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
> ---
>   linux-user/strace.c | 36 ++++++++++++++++++++----------------
>   1 file changed, 20 insertions(+), 16 deletions(-)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

and queued.


r~