diff options
author | Laurent Vivier <lvivier@redhat.com> | 2025-09-02 09:52:30 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2025-09-03 20:42:26 +0200 |
commit | 1fc944ce18699e87fa9924762d1d93814b659f73 (patch) | |
tree | 209e3662793b76d6784ad885fd01b54c7bd0384b | |
parent | 6bada9a1b5edbbf77f9eeed278b7429dfabebabd (diff) | |
download | passt-1fc944ce18699e87fa9924762d1d93814b659f73.tar passt-1fc944ce18699e87fa9924762d1d93814b659f73.tar.gz passt-1fc944ce18699e87fa9924762d1d93814b659f73.tar.bz2 passt-1fc944ce18699e87fa9924762d1d93814b659f73.tar.lz passt-1fc944ce18699e87fa9924762d1d93814b659f73.tar.xz passt-1fc944ce18699e87fa9924762d1d93814b659f73.tar.zst passt-1fc944ce18699e87fa9924762d1d93814b659f73.zip |
arp: Convert to iov_tail
Use packet_data() and extract headers using IOV_REMOVE_HEADER()
rather than packet_get().
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | arp.c | 12 | ||||
-rw-r--r-- | packet.c | 1 |
2 files changed, 9 insertions, 4 deletions
@@ -74,14 +74,20 @@ int arp(const struct ctx *c, const struct pool *p) struct arphdr ah; struct arpmsg am; } __attribute__((__packed__)) resp; + struct arphdr ah_storage; + struct ethhdr eh_storage; + struct arpmsg am_storage; const struct ethhdr *eh; const struct arphdr *ah; const struct arpmsg *am; + struct iov_tail data; - eh = packet_get(p, 0, 0, sizeof(*eh), NULL); - ah = packet_get(p, 0, sizeof(*eh), sizeof(*ah), NULL); - am = packet_get(p, 0, sizeof(*eh) + sizeof(*ah), sizeof(*am), NULL); + if (!packet_data(p, 0, &data)) + return -1; + eh = IOV_REMOVE_HEADER(&data, eh_storage); + ah = IOV_REMOVE_HEADER(&data, ah_storage); + am = IOV_REMOVE_HEADER(&data, am_storage); if (!eh || !ah || !am) return -1; @@ -201,7 +201,6 @@ void *packet_get_do(const struct pool *p, const size_t idx, * Return: false if packet index is invalid, true otherwise. * If something wrong with @data, don't return at all (assert). */ -/* cppcheck-suppress unusedFunction */ bool packet_data_do(const struct pool *p, size_t idx, struct iov_tail *data, const char *func, int line) |