[hipl-commit] [tiny] Rev 3671: Registered NAT keep-alives as maintenance function.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Sat, 13 Mar 2010 12:33:52 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Sat Mar 13 11:30:42 2010 +0100
Revision: 3671
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Registered NAT keep-alives as maintenance function.
  
  So the heartbeat module can unregister the NAT keep-alive function and
  register its own keep-alive function.

Modified:
  M  hipd/init.c
  M  hipd/maintenance.c
  M  hipd/nat.c
  M  modules/update/hipd/update.c

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-03-11 16:19:14 +0000
+++ hipd/init.c 2010-03-13 10:30:42 +0000
@@ -17,6 +17,7 @@
 #include "hip_socket.h"
 #include "init.h"
 #include "oppdb.h"
+#include "nat.h"
 #include "lib/core/common_defines.h"
 #include "lib/core/debug.h"
 #include "lib/core/hip_capability.h"
@@ -477,8 +478,9 @@
 
     hip_init_handle_functions();
 
-    hip_register_maint_function(&hip_relht_maintenance, 0);
-    hip_register_maint_function(&hip_registration_maintenance, 0);
+    hip_register_maint_function(&hip_nat_refresh_port,         10000);
+    hip_register_maint_function(&hip_relht_maintenance,        20000);
+    hip_register_maint_function(&hip_registration_maintenance, 30000);
 
 #ifndef CONFIG_HIP_OPENWRT
 #ifdef CONFIG_HIP_DEBUG

=== modified file 'hipd/maintenance.c'
--- hipd/maintenance.c  2010-03-10 17:48:17 +0000
+++ hipd/maintenance.c  2010-03-13 10:30:42 +0000
@@ -26,7 +26,6 @@
 float retrans_counter        = HIP_RETRANSMIT_INIT;
 float opp_fallback_counter   = HIP_OPP_FALLBACK_INIT;
 float precreate_counter      = HIP_R1_PRECREATE_INIT;
-int nat_keep_alive_counter   = HIP_NAT_KEEP_ALIVE_INTERVAL;
 float opendht_counter        = OPENDHT_REFRESH_INIT;
 float queue_counter          = QUEUE_CHECK_INIT;
 int force_exit_counter       = FORCE_EXIT_COUNTER_START;
@@ -190,17 +189,6 @@
         precreate_counter--;
     }
 
-    if (!lmod_module_exists("heartbeat") && hip_nat_status) {
-        if (nat_keep_alive_counter < 0) {
-            HIP_IFEL(hip_nat_refresh_port(),
-                     -ECOMM,
-                     "Failed to refresh NAT port state.\n");
-            nat_keep_alive_counter = HIP_NAT_KEEP_ALIVE_INTERVAL;
-        } else {
-            nat_keep_alive_counter--;
-        }
-    }
-
     hip_run_maint_functions();
 
 out_err:

=== modified file 'hipd/nat.c'
--- hipd/nat.c  2010-03-10 17:48:17 +0000
+++ hipd/nat.c  2010-03-13 10:30:42 +0000
@@ -75,6 +75,8 @@
  *        released versions of HIPL.*/
 #define HIP_UDP_PORT_RAND_MAX 65535.0
 
+static int nat_keep_alive_counter = HIP_NAT_KEEP_ALIVE_INTERVAL;
+
 /** A transmission function set for NAT traversal. */
 /** File descriptor of socket used for hip control packet NAT traversal on
  *  UDP/IPv4. Defined in hipd.c */
@@ -96,9 +98,19 @@
 {
     int err = 0;
 
-    HIP_DEBUG("Sending Keep-Alives to NAT.\n");
-    HIP_IFEL(hip_for_each_ha(hip_nat_send_keep_alive, NULL),
-             -1, "for_each_ha() err.\n");
+    if (!hip_nat_status) {
+        return 0;
+    }
+
+    if (nat_keep_alive_counter < 0) {
+        HIP_DEBUG("Sending Keep-Alives to NAT.\n");
+        HIP_IFEL(hip_for_each_ha(hip_nat_send_keep_alive, NULL),
+                 -1, "for_each_ha() err.\n");
+
+        nat_keep_alive_counter = HIP_NAT_KEEP_ALIVE_INTERVAL;
+    } else {
+        nat_keep_alive_counter--;
+    }
 
 out_err:
     return err;

=== modified file 'modules/update/hipd/update.c'
--- modules/update/hipd/update.c        2010-03-13 10:02:11 +0000
+++ modules/update/hipd/update.c        2010-03-13 10:30:42 +0000
@@ -1017,7 +1017,7 @@
                                           0),
              -1, "Error on registering UPDATE handle function.\n");
 
-    HIP_IFEL(hip_register_maint_function(&hip_update_maintenance, 0),
+    HIP_IFEL(hip_register_maint_function(&hip_update_maintenance, 40000),
              -1,
              "Error on registering UPDATE maintenance function.\n");

Other related posts:

  • » [hipl-commit] [tiny] Rev 3671: Registered NAT keep-alives as maintenance function. - Tim Just