qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 01/11] linux-user/strace: dump AF_NETLINK so


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [RFC PATCH 01/11] linux-user/strace: dump AF_NETLINK sockaddr content
Date: Thu, 15 Feb 2018 12:28:05 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

Hi Laurent,

On 02/15/2018 12:17 PM, Laurent Vivier wrote:
> Le 24/01/2018 à 14:01, Philippe Mathieu-Daudé a écrit :
>> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
>> ---
>> please double check __pad and ntohl()
>>
>>  linux-user/syscall_defs.h |  7 +++++++
>>  linux-user/strace.c       | 34 ++++++++++++++++++++++++++++++++++
>>  2 files changed, 41 insertions(+)
>>
>> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
>> index bec3680b94..550e7d2939 100644
>> --- a/linux-user/syscall_defs.h
>> +++ b/linux-user/syscall_defs.h
>> @@ -151,6 +151,13 @@ struct target_sockaddr_un {
>>      uint8_t sun_path[108];
>>  };
>>  
>> +struct target_sockaddr_nl {
>> +    uint16_t nl_family;     /* AF_NETLINK */
>> +    int16_t __pad;
> 
> netlink.h uses an unsigned type here.

This is padding, do you prefer char pad[2]?

> 
>> +    uint32_t nl_pid;
>> +    uint32_t nl_groups;
>> +};
>> +
>>  struct target_in_addr {
>>      uint32_t s_addr; /* big endian */
>>  };
>> diff --git a/linux-user/strace.c b/linux-user/strace.c
>> index bd897a3f20..7eb5e2ab48 100644
>> --- a/linux-user/strace.c
>> +++ b/linux-user/strace.c
>> @@ -8,6 +8,7 @@
>>  #include <arpa/inet.h>
>>  #include <netinet/tcp.h>
>>  #include <linux/if_packet.h>
>> +#include <linux/netlink.h>
>>  #include <sched.h>
>>  #include "qemu.h"
>>  
>> @@ -397,6 +398,12 @@ print_sockaddr(abi_ulong addr, abi_long addrlen)
>>              gemu_log("}");
>>              break;
>>          }
>> +        case AF_NETLINK: {
>> +            struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa;
>> +            gemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}",
>> +                     ntohl(nl->nl_pid), ntohl(nl->nl_groups));
> 
> Both sides of the netlink pipe are local and have the same endianness,
> so I don't think we need the ntohl() here. Moreover, I didn't find any
> endianness change in the kernel for them.

I had the same feeling but didn't check the kernel :\ since I was unsure
I used ntohl(), I'll remove it and respin. Thanks to verify!

Regards,

Phil.

> 
> Thanks,
> Laurent
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]