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.
---
arp.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/arp.c b/arp.c
index 18ff5de..6614804 100644
--- a/arp.c
+++ b/arp.c
@@ -41,7 +41,8 @@
static bool ignore_arp(const struct ctx *c,
const struct arphdr *ah, const struct arpmsg *am)
{
- const struct guest_addr *a = fwd_get_addr(c, AF_INET, 0, 0);
+ const struct guest_addr *a;
+ union inany_addr addr;
if (ah->ar_hrd != htons(ARPHRD_ETHER) ||
ah->ar_pro != htons(ETH_P_IP) ||
@@ -55,9 +56,11 @@ 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 (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, AF_INET)
+ if (inany_equals(&addr, &a->addr))
+ return true;
return false;
}
--
2.52.0