[libvirt] [PATCH 2/2] virarptable: Return a virArpTablePtr when the nlmsghdr for loop is over

Lin Ma posted 2 patches 7 years, 5 months ago
There is a newer version of this series
[libvirt] [PATCH 2/2] virarptable: Return a virArpTablePtr when the nlmsghdr for loop is over
Posted by Lin Ma 7 years, 5 months ago
commit b00c9c39 removed the label end_of_netlink_messages and 'return
table' statement, It causes the function virArpTableGet doesn't return
a proper virArpTable pointer.

How to reproduce:
 # virsh domiflist sles12sp3
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    virtio      52:54:00:cd:02:e6

 # virsh domifaddr sles12sp3 --source arp
error: Failed to query for interfaces addresses
error: An error occurred, but the cause is unknown

It seems that the "if (nh->nlmsg_type == NLMSG_DONE)" statement won't be
meted. So this patch adds 'return table' when the iterations of nlmsghdr
for loop is over.

Signed-off-by: Lin Ma <lma@suse.com>
---
 src/util/virarptable.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virarptable.c b/src/util/virarptable.c
index 04a6f35571..217a960d5a 100644
--- a/src/util/virarptable.c
+++ b/src/util/virarptable.c
@@ -152,6 +152,8 @@ virArpTableGet(void)
         }
     }
 
+    return table;
+
  cleanup:
     virArpTableFree(table);
     return NULL;
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] virarptable: Return a virArpTablePtr when the nlmsghdr for loop is over
Posted by Chen Hanxiao 7 years, 5 months ago
At 2018-09-07 18:44:54, "Lin Ma" <lma@suse.com> wrote:
>commit b00c9c39 removed the label end_of_netlink_messages and 'return
>table' statement, It causes the function virArpTableGet doesn't return
>a proper virArpTable pointer.
>
>How to reproduce:
> # virsh domiflist sles12sp3
>Interface  Type       Source     Model       MAC
>-------------------------------------------------------
>vnet0      network    default    virtio      52:54:00:cd:02:e6
>
> # virsh domifaddr sles12sp3 --source arp
>error: Failed to query for interfaces addresses
>error: An error occurred, but the cause is unknown
>
>It seems that the "if (nh->nlmsg_type == NLMSG_DONE)" statement won't be
>meted. So this patch adds 'return table' when the iterations of nlmsghdr
>for loop is over.
>
>Signed-off-by: Lin Ma <lma@suse.com>
>---

It seemed that the cleanup series delete our return value.

Reviewed-by: Chen Hanxiao <chenhanxiao@gmail.com>

Regards,
- Chen

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list