[hipl-commit] [trunk] Rev 4507: hipd: add the -m switch for kernel modules.

  • From: Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Fri, 14 May 2010 15:37:40 +0300

Committer: Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx>
Date: 14/05/2010 at 15:37:40
Revision: 4507
Revision-id: mircea.gherzan@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  hipd: add the -m switch for kernel modules.
  
  The default behaviour is still one of loading the required
  modules on startup and unloading them on exit. The switch
  disables this interaction: hipd assumes everything is up
  and running on the kernel side.  Main use-case of this
  switch: OpenWRT.

Modified:
  M  hipd/hipd.c
  M  hipd/init.c
  M  hipd/init.h

=== modified file 'hipd/hipd.c'
--- hipd/hipd.c 2010-05-12 16:09:38 +0000
+++ hipd/hipd.c 2010-05-14 12:31:23 +0000
@@ -173,6 +173,7 @@
     fprintf(stderr, "  -f set debug type format to short\n");
     fprintf(stderr, "  -d set the initial (pre-config) debug level to ALL 
(default is MEDIUM)\n");
     fprintf(stderr, "  -p disable privilege separation\n");
+    fprintf(stderr, "  -m disable the loading/unloading of kernel modules\n");
     fprintf(stderr, "\n");
 }
 
@@ -219,7 +220,7 @@
 {
     int c;
 
-    while ((c = getopt(argc, argv, ":bi:kNchafVdp")) != -1) {
+    while ((c = getopt(argc, argv, ":bi:kNchafVdpm")) != -1) {
         switch (c) {
         case 'b':
             /* run in the "background" */
@@ -256,6 +257,10 @@
             /* do _not_ use low capabilies ("privilege separation") */
             *flags &= ~HIPD_START_LOWCAP;
             break;
+        case 'm':
+            /* do _not_ load/unload kernel modules/drivers */
+            *flags &= ~HIPD_START_LOAD_KMOD;
+            break;
         case 'V':
             hip_print_version("hipd");
             return -1;
@@ -707,6 +712,11 @@
      * disturb further base exchanges. Use -N flag to disable this. */
     sflags         |= HIPD_START_FLUSH_IPSEC;
 
+    /* The default behaviour is to allow hipd to load the required modules
+     * and unload them when exiting.
+     */
+    sflags         |= HIPD_START_LOAD_KMOD;
+
     /* set the initial verbosity level */
     hip_set_logdebug(LOGDEBUG_MEDIUM);
 

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-05-12 16:09:38 +0000
+++ hipd/init.c 2010-05-14 12:31:23 +0000
@@ -800,7 +800,9 @@
 
     hip_dht_queue_uninit();
 
-    hip_remove_kernel_modules();
+    if (sflags & HIPD_START_LOAD_KMOD) {
+        hip_remove_kernel_modules();
+    }
 }
 
 /**
@@ -971,10 +973,12 @@
 
     hip_set_os_dep_variables();
 
-    err = hip_probe_kernel_modules();
-    if (err) {
-        HIP_ERROR("Unable to load the required kernel modules!\n");
-        goto out_err;
+    if (sflags & HIPD_START_LOAD_KMOD) {
+        err = hip_probe_kernel_modules();
+        if (err) {
+            HIP_ERROR("Unable to load the required kernel modules!\n");
+            goto out_err;
+        }
     }
 
     /* Register signal handlers */

=== modified file 'hipd/init.h'
--- hipd/init.h 2010-05-12 13:57:56 +0000
+++ hipd/init.h 2010-05-14 12:31:23 +0000
@@ -30,6 +30,7 @@
 #define HIPD_START_KILL_OLD                 (1 << 3)
 #define HIPD_START_FIX_ALIGNMENT            (1 << 4)
 #define HIPD_START_LOWCAP                   (1 << 5)
+#define HIPD_START_LOAD_KMOD                (1 << 6)
 
 /*
  * HIP daemon initialization functions.

Other related posts:

  • » [hipl-commit] [trunk] Rev 4507: hipd: add the -m switch for kernel modules. - Mircea Gherzan