]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ipv4ll: do not reset conflict counter on restart
authorAJ Bagwell <anthony.bagwell@hivehome.com>
Tue, 10 Dec 2019 16:27:31 +0000 (16:27 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 11 Dec 2019 04:26:31 +0000 (13:26 +0900)
Don't reset the conflict counter when trying a new pseudo random
address, so that after trying 10 addresses the londer timeout is used in
accordance with the RFC

Fixes #14299.

src/libsystemd-network/sd-ipv4acd.c
src/libsystemd-network/sd-ipv4ll.c
src/libsystemd-network/test-acd.c
src/network/networkd-address.c
src/systemd/sd-ipv4acd.h

index 5a0b6e45dc53636e592d3c576af8d281f3e8efce..d957202a689db62372258587b224454df994fa7c 100644 (file)
@@ -441,7 +441,7 @@ int sd_ipv4acd_is_running(sd_ipv4acd *acd) {
         return acd->state != IPV4ACD_STATE_INIT;
 }
 
-int sd_ipv4acd_start(sd_ipv4acd *acd) {
+int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts) {
         int r;
 
         assert_return(acd, -EINVAL);
@@ -458,7 +458,9 @@ int sd_ipv4acd_start(sd_ipv4acd *acd) {
         safe_close(acd->fd);
         acd->fd = r;
         acd->defend_window = 0;
-        acd->n_conflict = 0;
+
+        if (reset_conflicts)
+                acd->n_conflict = 0;
 
         r = sd_event_add_io(acd->event, &acd->receive_message_event_source, acd->fd, EPOLLIN, ipv4acd_on_packet, acd);
         if (r < 0)
index fa9b4f60397676a0dc2aeead8ca9679361aae543..aa1ece41d25cb5e7b9fdc332ee1c018aa712cb6b 100644 (file)
@@ -241,7 +241,7 @@ static int ipv4ll_start_internal(sd_ipv4ll *ll, bool reset_generation) {
                 picked_address = true;
         }
 
-        r = sd_ipv4acd_start(ll->acd);
+        r = sd_ipv4acd_start(ll->acd, reset_generation);
         if (r < 0) {
 
                 /* We couldn't start? If so, let's forget the picked address again, the user might make a change and
index 302eea2c30fa7fb09e5516d2174a73618f3f4ed6..27a1a2140024c6acf5c0c7ec65ae7d93ca96ce24 100644 (file)
@@ -47,7 +47,7 @@ static int client_run(int ifindex, const struct in_addr *pa, const struct ether_
 
         log_info("starting IPv4ACD client");
 
-        assert_se(sd_ipv4acd_start(acd) >= 0);
+        assert_se(sd_ipv4acd_start(acd, true) >= 0);
 
         assert_se(sd_event_loop(e) >= 0);
 
index 23a970a13f629cf2be291fe10630d1a5a2b39e09..886a8c0665e5717b605495eb6c0ff21bb3f928a3 100644 (file)
@@ -670,7 +670,7 @@ int address_configure(
                         log_debug("Starting IPv4ACD client. Probing address %s", strna(pretty));
                 }
 
-                r = sd_ipv4acd_start(address->acd);
+                r = sd_ipv4acd_start(address->acd, true);
                 if (r < 0)
                         log_link_warning_errno(link, r, "Failed to start IPv4ACD client, ignoring: %m");
         }
index 039ed3c7f2e5ac3d462a0c6b3a71bded3b6a17a4..ebf723fc221e08492687a9bb9164a9ca90e29e25 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <net/ethernet.h>
 #include <netinet/in.h>
+#include <stdbool.h>
 
 #include "sd-event.h"
 
@@ -44,7 +45,7 @@ int sd_ipv4acd_set_mac(sd_ipv4acd *acd, const struct ether_addr *addr);
 int sd_ipv4acd_set_ifindex(sd_ipv4acd *acd, int interface_index);
 int sd_ipv4acd_set_address(sd_ipv4acd *acd, const struct in_addr *address);
 int sd_ipv4acd_is_running(sd_ipv4acd *acd);
-int sd_ipv4acd_start(sd_ipv4acd *acd);
+int sd_ipv4acd_start(sd_ipv4acd *acd, bool reset_conflicts);
 int sd_ipv4acd_stop(sd_ipv4acd *acd);
 sd_ipv4acd *sd_ipv4acd_ref(sd_ipv4acd *acd);
 sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *acd);