Skip to contentSkip to conversation

linux-user: Support the accept4 socketcall

PATCH RESEND Superseded André Hentschel 4 participants 7 messages Jan 6, 2014

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 linux-user: Support the accept4 socketcall

From: André Hentschel <[email protected]>

---
See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/net.h for the values. Not entirely sure how to implement recvmmsg and sendmmsg...

 linux-user/syscall.c      | 15 +++++++++++++++
 linux-user/syscall_defs.h |  3 +++
 2 files changed, 18 insertions(+)
linux-user/syscall.c +15 -0
index efd1453..475fb8c 100644
@@ -2245,6 +2245,21 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
             ret = do_accept4(sockfd, target_addr, target_addrlen, 0);
         }
         break;
+    case SOCKOP_accept4:
+        {
+            abi_ulong sockfd;
+            abi_ulong target_addr, target_addrlen;
+            abi_ulong flags;
+
+            if (get_user_ual(sockfd, vptr)
+                || get_user_ual(target_addr, vptr + n)
+                || get_user_ual(target_addrlen, vptr + 2 * n)
+                || get_user_ual(flags, vptr + 3 * n))
+                return -TARGET_EFAULT;
+
+            ret = do_accept4(sockfd, target_addr, target_addrlen, flags);
+        }
+        break;
     case SOCKOP_getsockname:
         {
             abi_ulong sockfd;
linux-user/syscall_defs.h +3 -0
index cf08db5..b36f99c 100644
@@ -27,6 +27,9 @@
 #define SOCKOP_getsockopt       15
 #define SOCKOP_sendmsg          16
 #define SOCKOP_recvmsg          17
+#define SOCKOP_accept4          18
+#define SOCKOP_recvmmsg         19
+#define SOCKOP_sendmmsg         20
 
 #define IPCOP_semop		1
 #define IPCOP_semget		2
Signature · 1 line
1.8.1.2
#1 lore raw

Hi André,

This looks ok, except that scripts/checkpatch.pl says:

WARNING: braces {} are necessary for all arms of this statement #36: FILE: linux-user/syscall.c:2254:
+ if (get_user_ual(sockfd, vptr)
[...]

total: 0 errors, 1 warnings, 30 lines checked

Fix that and I'll be happy to slap a "reviewed-by" sticker on it. Be sure to CC me on the fixed version of the patch.

Cheers,
Erik

Signature · 3 lines
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
#2 lore raw
In reply to André Hentschel
Quoted 7 lines · André Hentschel

From: André Hentschel <[email protected]>

[...]

linux-user/syscall_defs.h line 32

Quoted 11 lines
linux-user/syscall_defs.h +3 -0
index cf08db5..b36f99c 100644
@@ -27,6 +27,9 @@
 #define SOCKOP_getsockopt 15
 #define SOCKOP_sendmsg 16
 #define SOCKOP_recvmsg 17
+#define SOCKOP_accept4 18
+#define SOCKOP_recvmmsg 19
+#define SOCKOP_sendmmsg 20

Don't add these both defines here as they are not used in this patch.

Regards,
Laurent

#3 lore raw
Quoted 15 lines · Laurent Vivier

linux-user/syscall_defs.h line 32

Quoted 13 lines · André Hentschel
linux-user/syscall_defs.h +3 -0
index cf08db5..b36f99c 100644
@@ -27,6 +27,9 @@
 #define SOCKOP_getsockopt 15
 #define SOCKOP_sendmsg 16
 #define SOCKOP_recvmsg 17
+#define SOCKOP_accept4 18
+#define SOCKOP_recvmmsg 19
+#define SOCKOP_sendmmsg 20

Don't add these both defines here as they are not used in this patch.

It doesn't seem that unreasonable to add them. We add things to the main syscall number #define list even if we aren't actually implementing them, for example.

thanks
-- PMM

#4 lore raw
Quoted 21 lines · Peter Maydell
Quoted 15 lines · Laurent Vivier

linux-user/syscall_defs.h line 32

Quoted 13 lines · André Hentschel
linux-user/syscall_defs.h +3 -0
index cf08db5..b36f99c 100644
@@ -27,6 +27,9 @@
 #define SOCKOP_getsockopt 15
 #define SOCKOP_sendmsg 16
 #define SOCKOP_recvmsg 17
+#define SOCKOP_accept4 18
+#define SOCKOP_recvmmsg 19
+#define SOCKOP_sendmmsg 20

Don't add these both defines here as they are not used in this patch.

Quoted 3 lines

It doesn't seem that unreasonable to add them. We add things to the main syscall number #define list even if we aren't actually implementing them, for example.

IMHO, you should not : if you implement these syscalls and then revert this patch (because it is broken, for instance), you will break the build. The defines must come with the implementation.

Regards,
Laurent

#5 lore raw
Quoted 7 lines

This looks ok, except that scripts/checkpatch.pl says:

WARNING: braces {} are necessary for all arms of this statement #36: FILE: linux-user/syscall.c:2254:
+ if (get_user_ual(sockfd, vptr)
[...]

Quoted 8 lines

total: 0 errors, 1 warnings, 30 lines checked

Fix that and I'll be happy to slap a "reviewed-by" sticker on it. Be sure to CC me on the fixed version of the patch.

Cheers,
Erik

This warning seems wrong:
- the if statement has no braces and only one arm
- the if statement looks like the others around it, i just try to keep the same style

Am 06.01.2014 11:21, schrieb Laurent Vivier:

Quoted 21 lines
Quoted 21 lines · Peter Maydell
Quoted 15 lines · Laurent Vivier

linux-user/syscall_defs.h line 32

Quoted 13 lines · André Hentschel
linux-user/syscall_defs.h +3 -0
index cf08db5..b36f99c 100644
@@ -27,6 +27,9 @@
 #define SOCKOP_getsockopt 15
 #define SOCKOP_sendmsg 16
 #define SOCKOP_recvmsg 17
+#define SOCKOP_accept4 18
+#define SOCKOP_recvmmsg 19
+#define SOCKOP_sendmmsg 20

Don't add these both defines here as they are not used in this patch.

Quoted 5 lines
Quoted 3 lines

It doesn't seem that unreasonable to add them. We add things to the main syscall number #define list even if we aren't actually implementing them, for example.

IMHO, you should not : if you implement these syscalls and then revert this patch (because it is broken, for instance), you will break the build. The defines must come with the implementation.

good point for removing them and add them separatly.

#6 lore raw
Quoted 3 lines · André Hentschel

This warning seems wrong:
- the if statement has no braces and only one arm
- the if statement looks like the others around it, i just try to keep the same style

The warning is saying that you need braces. "all arms" for an if() with only one arm means "on that one arm". See the CODING_STYLE file's section on 'block structure'.

QEMU includes a fair amount of legacy code which doesn't follow our coding standards. Our general policy on this is that new code follows the standards, and when a patch touches old code it updates it (at least sufficiently to get checkpatch to be happy). We don't generally do large-scale "update whole file to new standard" patches as this breaks git blame and can cause unnecessary patch conflicts.

thanks
-- PMM