libsystemd-network: sd-ipv4ll: Wrapper to restart address aquisition after conflict
authorJason Reeder <jasonreeder@gmail.com>
Fri, 31 Mar 2017 19:23:10 +0000 (14:23 -0500)
committerJason Reeder <jasonreeder@gmail.com>
Fri, 31 Mar 2017 20:29:00 +0000 (15:29 -0500)
After an ipv4ll claimed address conflict occurs a new address needs
to be chosen and then the acquisition state machine needs to be
restarted.

This commit adds a function (sd_ipv4ll_restart) that clears the
previously acquired address (ll->address) and then calls the existing
sd_ipv4ll_start function to choose the new address and start the
acquisition.

Signed-off-by: Jason Reeder <jasonreeder@gmail.com>
src/libsystemd-network/sd-ipv4ll.c
src/systemd/sd-ipv4ll.h

index 1320926..88a90e5 100644 (file)
@@ -248,6 +248,12 @@ 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) {
index 1109ec5..5ba9208 100644 (file)
@@ -47,6 +47,7 @@ int sd_ipv4ll_set_ifindex(sd_ipv4ll *ll, int interface_index);
 int sd_ipv4ll_set_address(sd_ipv4ll *ll, const struct in_addr *address);
 int sd_ipv4ll_set_address_seed(sd_ipv4ll *ll, uint64_t seed);
 int sd_ipv4ll_is_running(sd_ipv4ll *ll);
+int sd_ipv4ll_restart(sd_ipv4ll *ll);
 int sd_ipv4ll_start(sd_ipv4ll *ll);
 int sd_ipv4ll_stop(sd_ipv4ll *ll);
 sd_ipv4ll *sd_ipv4ll_ref(sd_ipv4ll *ll);