summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-08-19 19:42:38 +0200
committerTom Gundersen <teg@jklm.no>2015-09-18 15:14:42 +0200
commit028e0b20563cbe5a7adb350e670181c77f4c9050 (patch)
tree4afc1e03f04f0cdd80479b1c5ebaa3252a493a4c
parent25d6213b4331e9cbf355f4e851fc5b4ee2ae4c0f (diff)
sd-ipv4ll: remove duplicate packet verification
Most packets are filtered out by the BPF, so only check for the parts that may actually differ.
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index 9736e4d12a..b6aad2888d 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -172,26 +172,15 @@ static void ipv4ll_set_next_wakeup(sd_ipv4ll *ll, int sec, int random_sec) {
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(arp);
+ /* see the BPF */
if (memcmp(arp->arp_spa, &ll->address, sizeof(ll->address)) == 0)
return true;
- return false;
-}
-
-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;
-
+ /* the TPA matched instead of the SPA, this is not a conflict */
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_PROBING:
case IPV4LL_STATE_WAITING_ANNOUNCE:
- if (ipv4ll_arp_probe_conflict(ll, &packet)) {
- r = ipv4ll_on_conflict(ll);
- if (r < 0)
- goto out;
- }
+ /* BPF ensures this packet indicates a conflict */
+ r = ipv4ll_on_conflict(ll);
+ if (r < 0)
+ goto out;
break;
default: