diff mbox series

[v2] linux-user: Fix SO_ERROR return code of getsockopt()

Message ID Y9QzNzXg0hrzHQeo@p100 (mailing list archive)
State New, archived
Headers show
Series [v2] linux-user: Fix SO_ERROR return code of getsockopt() | expand

Commit Message

Helge Deller Jan. 27, 2023, 8:25 p.m. UTC
Add translation for the host error return code of:
    getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0

This fixes the testsuite of the cockpit debian package with a
hppa-linux guest on a x86-64 host.

Signed-off-by: Helge Deller <deller@gmx.de>
---
v2: Fix indenting to make checkscript.sh happy

Comments

Richard Henderson Jan. 27, 2023, 10:55 p.m. UTC | #1
On 1/27/23 10:25, Helge Deller wrote:
> Add translation for the host error return code of:
>      getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
> 
> This fixes the testsuite of the cockpit debian package with a
> hppa-linux guest on a x86-64 host.
> 
> Signed-off-by: Helge Deller<deller@gmx.de>
> ---

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

r~
Laurent Vivier Jan. 30, 2023, 8:42 a.m. UTC | #2
Le 27/01/2023 à 21:25, Helge Deller a écrit :
> Add translation for the host error return code of:
>      getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
> 
> This fixes the testsuite of the cockpit debian package with a
> hppa-linux guest on a x86-64 host.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
> v2: Fix indenting to make checkscript.sh happy
> 
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index dac0cfe6c4..06e8612675 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2809,8 +2809,13 @@ get_timeout:
>           ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
>           if (ret < 0)
>               return ret;
> -        if (optname == SO_TYPE) {
> +        switch (optname) {
> +        case SO_TYPE:
>               val = host_to_target_sock_type(val);
> +            break;
> +        case SO_ERROR:
> +            val = host_to_target_errno(val);
> +            break;
>           }
>           if (len > lv)
>               len = lv;
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Laurent Vivier Jan. 30, 2023, 8:45 a.m. UTC | #3
Le 27/01/2023 à 21:25, Helge Deller a écrit :
> Add translation for the host error return code of:
>      getsockopt(19, SOL_SOCKET, SO_ERROR, [ECONNREFUSED], [4]) = 0
> 
> This fixes the testsuite of the cockpit debian package with a
> hppa-linux guest on a x86-64 host.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
> v2: Fix indenting to make checkscript.sh happy
> 
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index dac0cfe6c4..06e8612675 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -2809,8 +2809,13 @@ get_timeout:
>           ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
>           if (ret < 0)
>               return ret;
> -        if (optname == SO_TYPE) {
> +        switch (optname) {
> +        case SO_TYPE:
>               val = host_to_target_sock_type(val);
> +            break;
> +        case SO_ERROR:
> +            val = host_to_target_errno(val);
> +            break;
>           }
>           if (len > lv)
>               len = lv;
> 

Applied to my linux-user-for-8.0 branch.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dac0cfe6c4..06e8612675 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2809,8 +2809,13 @@  get_timeout:
         ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
         if (ret < 0)
             return ret;
-        if (optname == SO_TYPE) {
+        switch (optname) {
+        case SO_TYPE:
             val = host_to_target_sock_type(val);
+            break;
+        case SO_ERROR:
+            val = host_to_target_errno(val);
+            break;
         }
         if (len > lv)
             len = lv;