qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 1/3] linux-user: add rtnetlink(7) support


From: Laurent Vivier
Subject: Re: [Qemu-devel] [PATCH v2 1/3] linux-user: add rtnetlink(7) support
Date: Tue, 14 Jun 2016 12:03:27 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0


Le 14/06/2016 à 11:34, Peter Maydell a écrit :
> On 22 May 2016 at 17:56, Laurent Vivier <address@hidden> wrote:
>> rtnetlink is needed to use iproute package (ip addr, ip route)
>> and dhcp client.
>>
>> +static abi_long target_to_host_for_each_nlmsg(struct nlmsghdr *nlh,
>> +                                              size_t len,
>> +                                              abi_long 
>> (*target_to_host_nlmsg)
>> +                                                       (struct nlmsghdr *))
>> +{
>> +    int ret;
>> +
>> +    while (len > sizeof(struct nlmsghdr)) {
>> +        if (tswap32(nlh->nlmsg_len) < sizeof(struct nlmsghdr) ||
>> +            tswap32(nlh->nlmsg_len) > len) {
>> +            break;
>> +        }
>> +        tswap_nlmsghdr(nlh);
>> +        switch (nlh->nlmsg_type) {
>> +        case NLMSG_DONE:
>> +            return 0;
>> +        case NLMSG_NOOP:
>> +            break;
>> +        case NLMSG_ERROR:
>> +        {
>> +            struct nlmsgerr *e = NLMSG_DATA(nlh);
>> +            e->error = tswap32(e->error);
>> +            tswap_nlmsghdr(&e->msg);
>> +        }
>> +        default:
>> +            ret = target_to_host_nlmsg(nlh);
>> +            if (ret < 0) {
>> +                return ret;
>> +            }
>> +        }
> 
> Coverity points out that the NLMSG_ERROR case falls
> through into the default. Missing "break" or missing
> "/* fallthrough */" comment?

I think like in host_to_target_for_each_nlmsg() we need:

        case NLMSG_ERROR:
        {
            struct nlmsgerr *e = NLMSG_DATA(nlh);
            e->error = tswap32(e->error);
            tswap_nlmsghdr(&e->msg);
            tswap_nlmsghdr(nlh);
            return 0;
        }

I'm going to have a deeper look at this and send a patch.

Thanks,
Laurent



reply via email to

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