[hipl-commit] [tiny] Rev 3599: Removed dependency between heartbeat and update.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 2 Mar 2010 16:27:48 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Tue Mar 02 15:26:57 2010 +0100
Revision: 3599
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Removed dependency between heartbeat and update.
  
  Moved update related functionality into the update module.

Modified:
  M  hipd/heartbeat.c
  M  hipd/heartbeat.h
  M  hipd/hiprelay.c
  M  hipd/maintenance.c
  M  hipd/registration.c
  M  modules/update/hipd/update.c

=== modified file 'hipd/heartbeat.c'
--- hipd/heartbeat.c    2010-02-26 13:55:48 +0000
+++ hipd/heartbeat.c    2010-03-02 14:26:57 +0000
@@ -6,56 +6,6 @@
 #include "heartbeat.h"
 #include "maintenance.h"
 
-/* TODO Remove this include, when modularization is finished */
-#include "modules/update/hipd/update.h"
-
-int hip_handle_update_heartbeat_trigger(hip_ha_t *ha, void *unused)
-{
-    struct hip_locator_info_addr_item *locators;
-    hip_common_t *locator_msg = NULL;
-    int err                   = 0;
-
-    if (!(ha->hastate == HIP_HASTATE_HITOK &&
-          ha->state == HIP_STATE_ESTABLISHED &&
-          ha->disable_sas == 0)) {
-        goto out_err;
-    }
-
-    ha->update_trigger_on_heartbeat_counter++;
-    _HIP_DEBUG("Trigger count %d/%d\n", 
ha->update_trigger_on_heartbeat_counter,
-               HIP_ADDRESS_CHANGE_HB_COUNT_TRIGGER * hip_icmp_interval);
-
-    if (ha->update_trigger_on_heartbeat_counter <
-        HIP_ADDRESS_CHANGE_HB_COUNT_TRIGGER * hip_icmp_interval) {
-        goto out_err;
-    }
-
-    /* Time to try a handover because heart beats have been failing.
-     * Let's also reset to counter to avoid UPDATE looping in case e.g.
-     * there is just no connectivity at all. */
-    ha->update_trigger_on_heartbeat_counter = 0;
-
-    HIP_DEBUG("Hearbeat counter with ha expired, trigger UPDATE\n");
-
-    HIP_IFEL(!(locator_msg = hip_msg_alloc()), -ENOMEM,
-             "Out of memory while allocation memory for the packet\n");
-    HIP_IFE(hip_create_locators(locator_msg, &locators), -1);
-
-    HIP_IFEL(hip_send_locators_to_one_peer(NULL, ha, &ha->our_addr,
-                                           &ha->peer_addr, locators,
-                                           HIP_UPDATE_LOCATOR),
-             -1, "Failed to trigger update\n");
-
-    ha->update_trigger_on_heartbeat_counter = 0;
-
-out_err:
-    if (locator_msg) {
-        free(locator_msg);
-    }
-
-    return err;
-}
-
 /**
  * This function goes through the HA database and sends an icmp echo to all of 
them
  *

=== modified file 'hipd/heartbeat.h'
--- hipd/heartbeat.h    2010-02-17 13:08:39 +0000
+++ hipd/heartbeat.h    2010-03-02 14:26:57 +0000
@@ -3,7 +3,6 @@
 
 #include "lib/core/state.h"
 
-int hip_handle_update_heartbeat_trigger(hip_ha_t *ha, void *unused);
 int hip_send_heartbeat(hip_ha_t *entry, void *opaq);
 int hip_icmp_recvmsg(int sockfd);
 

=== modified file 'hipd/hiprelay.c'
--- hipd/hiprelay.c     2010-02-26 13:55:48 +0000
+++ hipd/hiprelay.c     2010-03-02 14:26:57 +0000
@@ -380,6 +380,12 @@
     return ((struct lhash_st *) hiprelay_ht)->num_items;
 }
 
+/**
+ * hip_relht_maintenance
+ *
+ * @brief Clear the expired records from the relay hashtable.
+ *
+ */
 void hip_relht_maintenance()
 {
     if (hiprelay_ht == NULL) {

=== modified file 'hipd/maintenance.c'
--- hipd/maintenance.c  2010-03-02 14:04:27 +0000
+++ hipd/maintenance.c  2010-03-02 14:26:57 +0000
@@ -215,21 +215,10 @@
         }
     }
 
-    if (hip_trigger_update_on_heart_beat_failure &&
-        hip_icmp_interval > 0) {
-        hip_for_each_ha(hip_handle_update_heartbeat_trigger, NULL);
-    }
-
     hip_run_maint_functions();
 
-//#ifdef CONFIG_HIP_UDPRELAY
-    /* Clear the expired records from the relay hashtable. */
     hip_relht_maintenance();
-//#endif
-    /* Clear the expired pending service requests. This is by no means time
-     * critical operation and is not needed to be done on every maintenance
-     * cycle. Once every 10 minutes or so should be enough. Just for the
-     * record, if periodic_maintenance() is ever to be optimized. */
+
     hip_registration_maintenance();
 
 out_err:

=== modified file 'hipd/registration.c'
--- hipd/registration.c 2010-02-22 18:30:02 +0000
+++ hipd/registration.c 2010-03-02 14:26:57 +0000
@@ -78,6 +78,10 @@
  * calling @c hip_del_pending_request_by_expiration() until there are no 
expired
  * pending requests left.
  *
+ * @note This is by no means time critical operation and is not needed to be
+ * done on every maintenance cycle. Once every 10 minutes or so should be 
enough.
+ * Just for the record, if periodic_maintenance() is ever to be optimized.
+ *
  * An expired pending requests is one that has not been deleted within
  * @c HIP_PENDING_REQUEST_LIFETIME seconds.
  */

=== modified file 'modules/update/hipd/update.c'
--- modules/update/hipd/update.c        2010-03-02 14:04:27 +0000
+++ modules/update/hipd/update.c        2010-03-02 14:26:57 +0000
@@ -916,6 +916,53 @@
     return err;
 }
 
+static int hip_handle_update_heartbeat_trigger(hip_ha_t *ha, void *unused)
+{
+    struct hip_locator_info_addr_item *locators;
+    hip_common_t *locator_msg = NULL;
+    int err                   = 0;
+
+    if (!(ha->hastate == HIP_HASTATE_HITOK &&
+          ha->state == HIP_STATE_ESTABLISHED &&
+          ha->disable_sas == 0)) {
+        goto out_err;
+    }
+
+    ha->update_trigger_on_heartbeat_counter++;
+    _HIP_DEBUG("Trigger count %d/%d\n", 
ha->update_trigger_on_heartbeat_counter,
+               HIP_ADDRESS_CHANGE_HB_COUNT_TRIGGER * hip_icmp_interval);
+
+    if (ha->update_trigger_on_heartbeat_counter <
+        HIP_ADDRESS_CHANGE_HB_COUNT_TRIGGER * hip_icmp_interval) {
+        goto out_err;
+    }
+
+    /* Time to try a handover because heart beats have been failing.
+     * Let's also reset to counter to avoid UPDATE looping in case e.g.
+     * there is just no connectivity at all. */
+    ha->update_trigger_on_heartbeat_counter = 0;
+
+    HIP_DEBUG("Hearbeat counter with ha expired, trigger UPDATE\n");
+
+    HIP_IFEL(!(locator_msg = hip_msg_alloc()), -ENOMEM,
+             "Out of memory while allocation memory for the packet\n");
+    HIP_IFE(hip_create_locators(locator_msg, &locators), -1);
+
+    HIP_IFEL(hip_send_locators_to_one_peer(NULL, ha, &ha->our_addr,
+                                           &ha->peer_addr, locators,
+                                           HIP_UPDATE_LOCATOR),
+             -1, "Failed to trigger update\n");
+
+    ha->update_trigger_on_heartbeat_counter = 0;
+
+out_err:
+    if (locator_msg) {
+        free(locator_msg);
+    }
+
+    return err;
+}
+
 int hip_update_maintenance(void)
 {
     int err = 0;
@@ -938,5 +985,10 @@
         }
     }
 
+    if (hip_trigger_update_on_heart_beat_failure &&
+        hip_icmp_interval > 0) {
+        hip_for_each_ha(hip_handle_update_heartbeat_trigger, NULL);
+    }
+
     return err;
 }

Other related posts:

  • » [hipl-commit] [tiny] Rev 3599: Removed dependency between heartbeat and update. - Tim Just