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
---
v3: -Adapted to single-array changes earlier in this series
v6: -Made loop in ignore_arp() a little more palatable,
but not entirely as suggested by David.
v7: -Curly brackets in ignore_arp(), as suggested by Stefano.
-I did not modify the for_each_addr(), macro, as Stefano suggested,
since it also would require us to add an extra parameter indicating
the array length.
---
arp.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/arp.c b/arp.c
index a7fd82f..a3fdeb6 100644
--- a/arp.c
+++ b/arp.c
@@ -42,6 +42,7 @@ static bool ignore_arp(const struct ctx *c,
const struct arphdr *ah, const struct arpmsg *am)
{
const struct guest_addr *a;
+ union inany_addr addr;
if (ah->ar_hrd != htons(ARPHRD_ETHER) ||
ah->ar_pro != htons(ETH_P_IP) ||
@@ -55,11 +56,12 @@ 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. */
- a = fwd_get_addr(c, AF_INET, 0, 0);
- if (a && !memcmp(am->tip, inany_v4(&a->addr), sizeof(am->tip)))
- return true;
-
+ /* Don't resolve any of the guest's addresses */
+ inany_from_af(&addr, AF_INET, am->tip);
+ for_each_addr(a, c->addrs, c->addr_count, AF_INET) {
+ if (inany_equals(&addr, &a->addr))
+ return true;
+ }
return false;
}
--
2.52.0