summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-03-30 07:33:03 +0900
committerLennart Poettering <lennart@poettering.net>2019-04-02 10:27:30 +0200
commit52cf2b13a091c759ed3d2bcab90e1b054c710704 (patch)
tree947ae46d59da6e28b4712b698c0b70be9d297419
parentd9550542a8219d04b9fff279e084e0bd3ec9c337 (diff)
downloadsystemd-52cf2b13a091c759ed3d2bcab90e1b054c710704.tar.gz
ipv4ll: do not reset seed generation counter on restart
Fixes #12145.
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index e451dff744..a59a952326 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -218,28 +218,21 @@ static int ipv4ll_pick_address(sd_ipv4ll *ll) {
return sd_ipv4ll_set_address(ll, &(struct in_addr) { addr });
}
-int sd_ipv4ll_restart(sd_ipv4ll *ll) {
- ll->address = 0;
-
- return sd_ipv4ll_start(ll);
-}
-
#define MAC_HASH_KEY SD_ID128_MAKE(df,04,22,98,3f,ad,14,52,f9,87,2e,d1,9c,70,e2,f2)
-int sd_ipv4ll_start(sd_ipv4ll *ll) {
+static int ipv4ll_start_internal(sd_ipv4ll *ll, bool reset_generation) {
int r;
bool picked_address = false;
assert_return(ll, -EINVAL);
assert_return(!ether_addr_is_null(&ll->mac), -EINVAL);
- assert_return(sd_ipv4ll_is_running(ll) == 0, -EBUSY);
/* If no random seed is set, generate some from the MAC address */
if (!ll->seed_set)
ll->seed.value = htole64(siphash24(ll->mac.ether_addr_octet, ETH_ALEN, MAC_HASH_KEY.bytes));
- /* Restart the generation counter. */
- ll->seed.generation = 0;
+ if (reset_generation)
+ ll->seed.generation = 0;
if (ll->address == 0) {
r = ipv4ll_pick_address(ll);
@@ -263,6 +256,19 @@ int sd_ipv4ll_start(sd_ipv4ll *ll) {
return 0;
}
+int sd_ipv4ll_start(sd_ipv4ll *ll) {
+ assert_return(ll, -EINVAL);
+ assert_return(sd_ipv4ll_is_running(ll) == 0, -EBUSY);
+
+ return ipv4ll_start_internal(ll, true);
+}
+
+int sd_ipv4ll_restart(sd_ipv4ll *ll) {
+ ll->address = 0;
+
+ return ipv4ll_start_internal(ll, false);
+}
+
static void ipv4ll_client_notify(sd_ipv4ll *ll, int event) {
assert(ll);
@@ -298,11 +304,7 @@ void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata) {
ll->claimed_address = 0;
} else {
- r = ipv4ll_pick_address(ll);
- if (r < 0)
- goto error;
-
- r = sd_ipv4acd_start(ll->acd);
+ r = sd_ipv4ll_restart(ll);
if (r < 0)
goto error;
}