nat-mode-20060330
authorJim Rees <rees@umich.edu>
Thu, 30 Mar 2006 18:13:39 +0000 (18:13 +0000)
committerJim Rees <rees@umich.edu>
Thu, 30 Mar 2006 18:13:39 +0000 (18:13 +0000)
Code for "nat mode."  Currently there is no way to set it, because it would
be a bad idea to make this available to the casual user.

src/afs/afs_daemons.c
src/config/venus.h
src/venus/fs.c

index 1a9471b..c272bef 100644 (file)
@@ -51,11 +51,31 @@ afs_int32 afs_CheckServerDaemonStarted = 0;
 #endif
 afs_int32 afs_probe_interval = DEFAULT_PROBE_INTERVAL;
 afs_int32 afs_probe_all_interval = 600;
+afs_int32 afs_nat_probe_interval = 60;
 
 #define PROBE_WAIT() (1000 * (afs_probe_interval - ((afs_random() & 0x7fffffff) \
                      % (afs_probe_interval/2))))
 
 void
+afs_SetCheckServerNATmode(int isnat)
+{
+    static afs_int32 old_intvl, old_all_intvl;
+    static int wasnat;
+
+    if (isnat && !wasnat) {
+       old_intvl = afs_probe_interval;
+       old_all_intvl = afs_probe_all_interval;
+       afs_probe_interval = afs_nat_probe_interval;
+       afs_probe_all_interval = afs_nat_probe_interval;
+       afs_osi_CancelWait(&AFS_CSWaitHandler);
+    } else if (!isnat && wasnat) {
+       afs_probe_interval = old_intvl;
+       afs_probe_all_interval = old_all_intvl;
+    }
+    wasnat = isnat;
+}
+
+void
 afs_CheckServerDaemon(void)
 {
     afs_int32 now, delay, lastCheck, last10MinCheck;
index eb5e5b8..ac9cb76 100644 (file)
@@ -181,5 +181,6 @@ struct cm_initparams {
 #define VIOC_NEWALIAS          _CVICEIOCTL(1)  /* create new cell alias */
 #define VIOC_GETALIAS          _CVICEIOCTL(2)  /* get alias info */
 #define VIOC_CBADDR            _CVICEIOCTL(3)  /* push callback addr */
+#define VIOC_DISCON            _CVICEIOCTL(5)  /* set/get discon mode */
 
 #endif /* AFS_VENUS_H */
index 83ef0c2..cbd010a 100644 (file)
@@ -3131,6 +3131,61 @@ GetCryptCmd(struct cmd_syndesc *as, char *arock)
     return 0;
 }
 
+#ifdef AFS_DISCON_ENV
+static char *modenames[] = {
+    "discon",
+    "fetchonly",
+    "partial",
+    "nat",
+    "full",
+    NULL
+};
+
+static afs_int32
+DisconCmd(struct cmd_syndesc *as, char *arock)
+{
+    struct cmd_item *ti;
+    char *modename;
+    int modelen;
+    afs_int32 mode, code;
+    struct ViceIoctl blob;
+
+    blob.in = NULL;
+    blob.in_size = 0;
+
+    ti = as->parms[0].items;
+    if (ti) {
+       modename = ti->data;
+       modelen = strlen(modename);
+       for (mode = 0; modenames[mode] != NULL; mode++)
+           if (!strncasecmp(modename, modenames[mode], modelen))
+               break;
+       if (modenames[mode] == NULL)
+           printf("Unknown discon mode \"%s\"\n", modename);
+       else {
+           memcpy(space, &mode, sizeof mode);
+           blob.in = space;
+           blob.in_size = sizeof mode;
+       }
+    }
+
+    blob.out_size = sizeof(mode);
+    blob.out = space;
+    code = pioctl(0, VIOC_DISCON, &blob, 1);
+    if (code)
+       Die(errno, NULL);
+    else {
+       memcpy(&mode, space, sizeof mode);
+       if (mode < sizeof modenames / sizeof (char *))
+           printf("Discon mode is now \"%s\"\n", modenames[mode]);
+       else
+           printf("Unknown discon mode %d\n", mode);
+    }
+
+    return 0;
+}
+#endif
+
 #include "AFS_component_version_number.c"
 
 int
@@ -3442,6 +3497,12 @@ defect 3069
                          "get fid for file(s)");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
+#ifdef AFS_DISCON_ENV
+    ts = cmd_CreateSyntax("discon", DisconCmd, 0,
+                         "disconnection mode");
+    cmd_AddParm(ts, "-mode", CMD_SINGLE, CMD_OPTIONAL, "nat | full");
+#endif
+
     code = cmd_Dispatch(argc, argv);
     if (rxInitDone)
        rx_Finalize();