diff mbox

[resend] linux-user: Support the accept4 socketcall

Message ID 52CA0D7B.5000301@dawncrow.de
State New
Headers show

Commit Message

André Zwing Jan. 6, 2014, 1:57 a.m. UTC
From: André Hentschel <nerv@dawncrow.de>
Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: André Hentschel <nerv@dawncrow.de>
---
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(+)

Comments

Erik de Castro Lopo Jan. 6, 2014, 3:37 a.m. UTC | #1
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
Laurent Vivier Jan. 6, 2014, 8:45 a.m. UTC | #2
> Le 6 janvier 2014 à 02:57, André Hentschel <nerv@dawncrow.de> a écrit :
>
>
> From: André Hentschel <nerv@dawncrow.de>
> Cc: Riku Voipio <riku.voipio@iki.fi>
> Signed-off-by: André Hentschel <nerv@dawncrow.de>
[...]
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index cf08db5..b36f99c 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -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
Peter Maydell Jan. 6, 2014, 9:14 a.m. UTC | #3
On 6 January 2014 08:45, Laurent Vivier <laurent@vivier.eu> wrote:
>
>> Le 6 janvier 2014 à 02:57, André Hentschel <nerv@dawncrow.de> a écrit :
>> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
>> index cf08db5..b36f99c 100644
>> --- a/linux-user/syscall_defs.h
>> +++ b/linux-user/syscall_defs.h
>> @@ -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
Laurent Vivier Jan. 6, 2014, 10:21 a.m. UTC | #4
> Le 6 janvier 2014 à 10:14, Peter Maydell <peter.maydell@linaro.org> a écrit :
>
>
> On 6 January 2014 08:45, Laurent Vivier <laurent@vivier.eu> wrote:
> >
> >> Le 6 janvier 2014 à 02:57, André Hentschel <nerv@dawncrow.de> a écrit :
> >> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> >> index cf08db5..b36f99c 100644
> >> --- a/linux-user/syscall_defs.h
> >> +++ b/linux-user/syscall_defs.h
> >> @@ -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.

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
André Zwing Jan. 6, 2014, 3:38 p.m. UTC | #5
> 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

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:
> 
>> Le 6 janvier 2014 à 10:14, Peter Maydell <peter.maydell@linaro.org> a écrit :
>>
>>
>> On 6 January 2014 08:45, Laurent Vivier <laurent@vivier.eu> wrote:
>> >
>> >> Le 6 janvier 2014 à 02:57, André Hentschel <nerv@dawncrow.de> a écrit :
>> >> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
>> >> index cf08db5..b36f99c 100644
>> >> --- a/linux-user/syscall_defs.h
>> >> +++ b/linux-user/syscall_defs.h
>> >> @@ -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.
> 
> 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.
Peter Maydell Jan. 6, 2014, 4:03 p.m. UTC | #6
On 6 January 2014 15:38, André Hentschel <nerv@dawncrow.de> wrote:
> 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
diff mbox

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index efd1453..475fb8c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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;
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index cf08db5..b36f99c 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -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