linux-user: Translate errno in IP_RECVERR and IPV6_RECVERR
Translate host error codes of IP_RECVERR and IPV6_RECVERR control messages to target error codes before returning to the caller. For example, this is important for architectures (e.g. hppa, alpha, sparc, mips) on which the value of ECONNREFUSED is different to the value on a x86_64 host. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/602 Signed-off-by: Helge Deller <deller@gmx.de>
Helge Deller committed
Apr 29, 2026 at 19:24 UTC
9667bf3249256788245c6ca07bc12106f3e4fa22
1 file changed
+4
-2
linux-user/syscall.c
+4
-2
@@ -2008,7 +2008,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
2008
tgt_len != sizeof(struct errhdr_t)) {
2009
goto unimplemented;
2010
}
2011
- __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
2011
+ __put_user(host_to_target_errno(errh->ee.ee_errno),
2012
+ &target_errh->ee.ee_errno);
2013
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
2014
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
2015
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
@@ -2062,7 +2063,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
2063
tgt_len != sizeof(struct errhdr6_t)) {
2064
goto unimplemented;
2065
}
2065
- __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
2066
+ __put_user(host_to_target_errno(errh->ee.ee_errno),
2067
+ &target_errh->ee.ee_errno);
2068
__put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
2069
__put_user(errh->ee.ee_type, &target_errh->ee.ee_type);
2070
__put_user(errh->ee.ee_code, &target_errh->ee.ee_code);