virarptable: Properly calculate rtattr length

Use convenience macro which does almost the same thing we were doing,
but also pads out the payload length to a multiple of NLMSG_ALIGNTO (4)
bytes.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Martin Kletzander 2024-08-16 13:56:51 +02:00
parent 271940223c
commit e7530769e8

View File

@ -102,8 +102,7 @@ virArpTableGet(void)
return table; return table;
VIR_WARNINGS_NO_CAST_ALIGN VIR_WARNINGS_NO_CAST_ALIGN
parse_rtattr(tb, NDA_MAX, NDA_RTA(r), parse_rtattr(tb, NDA_MAX, NDA_RTA(r), NLMSG_PAYLOAD(nh, sizeof(*r)));
nh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
VIR_WARNINGS_RESET VIR_WARNINGS_RESET
if (tb[NDA_DST] == NULL || tb[NDA_LLADDR] == NULL) if (tb[NDA_DST] == NULL || tb[NDA_LLADDR] == NULL)