On Sun, Feb 22, 2026 at 12:44:36PM -0500, Jon Maloy wrote:
As a preparation for handling multiple addresses, we update ignore_arp() to check against all addresses in the unified addrs[] array using the for_each_addr() macro.
Signed-off-by: Jon Maloy
Reviewed-by: David Gibson
The patch is correct, but it can be made slightly more elegant, see below.
--- v3: Adapted to single-array changes earlier in this series --- arp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arp.c b/arp.c index 99a6a67..8beb2dd 100644 --- a/arp.c +++ b/arp.c @@ -41,7 +41,7 @@ static bool ignore_arp(const struct ctx *c, const struct arphdr *ah, const struct arpmsg *am) { - struct inany_addr_entry *e = first_v4(c); + const struct inany_addr_entry *e;
if (ah->ar_hrd != htons(ARPHRD_ETHER) || ah->ar_pro != htons(ETH_P_IP) || @@ -55,9 +55,10 @@ static bool ignore_arp(const struct ctx *c, !memcmp(am->sip, am->tip, sizeof(am->sip))) return true;
- /* Don't resolve the guest's assigned address, either. */ - if (e && !memcmp(am->tip, inany_v4(&e->addr), sizeof(am->tip))) - return true; + /* Don't resolve any of the guest's addresses */ + for_each_addr(e, c, AF_INET) + if (!memcmp(am->tip, inany_v4(&e->addr), sizeof(am->tip))) + return true;
You can avoid the somewhat awkward for_each_addr(AF_INET) logic, by using inany_equals4() on *every* entry in the address array. The IPv6 addresses necessarily won't match.
return false; } -- 2.52.0
-- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson