From f86af4af2600707f0573d6a5623b32116b4b0656 Mon Sep 17 00:00:00 2001 From: Jim Rees Date: Thu, 30 Mar 2006 18:13:39 +0000 Subject: [PATCH] nat-mode-20060330 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 | 20 ++++++++++++++ src/config/venus.h | 1 + src/venus/fs.c | 61 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index 1a9471b5da..c272bef9b0 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -51,10 +51,30 @@ 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) { diff --git a/src/config/venus.h b/src/config/venus.h index eb5e5b880b..ac9cb76fa1 100644 --- a/src/config/venus.h +++ b/src/config/venus.h @@ -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 */ diff --git a/src/venus/fs.c b/src/venus/fs.c index 83ef0c286b..cbd010ad79 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -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();