mirror of
https://github.com/systemd/systemd.git
synced 2024-11-08 11:27:32 +03:00
sd-ipv4ll: remove duplicate packet verification
Most packets are filtered out by the BPF, so only check for the parts that may actually differ.
This commit is contained in:
parent
25d6213b43
commit
028e0b2056
@ -172,26 +172,15 @@ static void ipv4ll_set_next_wakeup(sd_ipv4ll *ll, int sec, int random_sec) {
|
|||||||
ll->next_wakeup_valid = 1;
|
ll->next_wakeup_valid = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ipv4ll_arp_conflict (sd_ipv4ll *ll, struct ether_arp *arp) {
|
static bool ipv4ll_arp_conflict(sd_ipv4ll *ll, struct ether_arp *arp) {
|
||||||
assert(ll);
|
assert(ll);
|
||||||
assert(arp);
|
assert(arp);
|
||||||
|
|
||||||
|
/* see the BPF */
|
||||||
if (memcmp(arp->arp_spa, &ll->address, sizeof(ll->address)) == 0)
|
if (memcmp(arp->arp_spa, &ll->address, sizeof(ll->address)) == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
/* the TPA matched instead of the SPA, this is not a conflict */
|
||||||
}
|
|
||||||
|
|
||||||
static bool ipv4ll_arp_probe_conflict (sd_ipv4ll *ll, struct ether_arp *arp) {
|
|
||||||
assert(ll);
|
|
||||||
assert(arp);
|
|
||||||
|
|
||||||
if (ipv4ll_arp_conflict(ll, arp))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (memcmp(arp->arp_tpa, &ll->address, sizeof(ll->address)) == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,11 +357,10 @@ static int ipv4ll_on_packet(sd_event_source *s, int fd,
|
|||||||
case IPV4LL_STATE_WAITING_PROBE:
|
case IPV4LL_STATE_WAITING_PROBE:
|
||||||
case IPV4LL_STATE_PROBING:
|
case IPV4LL_STATE_PROBING:
|
||||||
case IPV4LL_STATE_WAITING_ANNOUNCE:
|
case IPV4LL_STATE_WAITING_ANNOUNCE:
|
||||||
if (ipv4ll_arp_probe_conflict(ll, &packet)) {
|
/* BPF ensures this packet indicates a conflict */
|
||||||
r = ipv4ll_on_conflict(ll);
|
r = ipv4ll_on_conflict(ll);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user