Gracefully handle arp_open failure

This commit is contained in:
dmiller 2026-03-10 18:32:50 +00:00
parent 7f2764927b
commit 5b78ef236e
2 changed files with 21 additions and 14 deletions

View file

@ -769,6 +769,7 @@ bool NpingTarget::determineNextHopMACAddress() {
/* Maybe the system ARP cache will be more helpful */
nping_print(DBG_3," > Checking system's ARP cache...");
a = arp_open();
if (a) {
addr_ston((sockaddr *)&targetss, &ae.arp_pa);
if (arp_get(a, &ae) == 0) {
mac_cache_set(&targetss, ae.arp_ha.addr_eth.data);
@ -779,6 +780,10 @@ bool NpingTarget::determineNextHopMACAddress() {
}
arp_close(a);
nping_print(DBG_3," > No relevant entries found in system's ARP cache.");
}
else {
nping_print(DBG_3," > Failed to open system's ARP cache.");
}
/* OK, the last choice is to send our own damn ARP request (and

View file

@ -1663,6 +1663,7 @@ bool getNextHopMAC(const char *iface, const u8 *srcmac, const struct sockaddr_st
/* Maybe the system ARP cache will be more helpful */
a = arp_open();
if (a) {
addr_ston((sockaddr *) dstss, &ae.arp_pa);
if (arp_get(a, &ae) == 0) {
mac_cache_set(dstss, ae.arp_ha.addr_eth.data);
@ -1671,6 +1672,7 @@ bool getNextHopMAC(const char *iface, const u8 *srcmac, const struct sockaddr_st
return true;
}
arp_close(a);
}
/* OK, the last choice is to send our own damn ARP request (and
retransmissions if necessary) to determine the MAC */