bb2d391712fb0208347ffc0b88abe146df14dc0a
galt
  Fri Jun 21 18:21:50 2019 -0700
Adding Support for CIDR specification of subnets, e.g. 192.168.1.255/31. It still supports the older subnet format too, e.g. 192.168

diff --git src/parasol/paraHub/paraHub.c src/parasol/paraHub/paraHub.c
index e537a51..1ebe5b5 100644
--- src/parasol/paraHub/paraHub.c
+++ src/parasol/paraHub/paraHub.c
@@ -66,87 +66,90 @@
 
 #include "paraCommon.h"
 #include "options.h"
 #include "linefile.h"
 #include "hash.h"
 #include "errAbort.h"
 #include "dystring.h"
 #include "dlist.h"
 #include "net.h"
 #include "internet.h"
 #include "paraHub.h"
 #include "machSpec.h"
 #include "log.h"
 #include "obscure.h"
 #include "sqlNum.h"
+#include "internet.h"
 
 
 /* command line option specifications */
 static struct optionSpec optionSpecs[] = {
     {"spokes", OPTION_INT},
     {"jobCheckPeriod", OPTION_INT},
     {"machineCheckPeriod", OPTION_INT},
     {"subnet", OPTION_STRING},
     {"nextJobId", OPTION_INT},
     {"logFacility", OPTION_STRING},
     {"logMinPriority", OPTION_STRING},
     {"log", OPTION_STRING},
     {"debug", OPTION_BOOLEAN},
     {"noResume", OPTION_BOOLEAN},
     {"ramUnit", OPTION_STRING},
     {"defaultJobRam", OPTION_INT},
     {NULL, 0}
 };
 
 char *version = PARA_VERSION;	/* Version number. */
 
 /* Some command-line configurable quantities and their defaults. */
 int jobCheckPeriod = 10;      /* Minutes between checking running jobs. */
 int machineCheckPeriod = 20;  /* Minutes between checking dead machines. */
 int assumeDeadPeriod = 60;    /* If haven't heard from job in this long assume
                                  * machine running it is dead. */
 int initialSpokes = 30;		/* Number of spokes to start with. */
-unsigned char hubSubnet[4] = {255,255,255,255};   /* Subnet to check. */
+struct cidr *hubSubnet = NULL;   /* Subnet to check. */
+struct cidr *localHostSubnet = NULL;
 int nextJobId = 0;		/* Next free job id. */
 time_t startupTime;		/* Clock tick of paraHub startup. */
 
 /* not yet configurable */
 int sickNodeThreshold = 3;          /* Treat node as sick if this number of failures */
 int sickBatchThreshold = 25;        /* Auto-chill sick batch if this number of continuous failures */
 
 
 
 void usage()
 /* Explain usage and exit. */
 {
 errAbort("paraHub - parasol hub server version %s\n"
          "usage:\n"
 	 "    paraHub machineList\n"
 	 "Where machine list is a file with the following columns:\n"
          "    name - Network name\n"
          "    cpus - Number of CPUs we can use\n"
          "    ramSize - Megabytes of memory\n"
          "    tempDir - Location of (local) temp dir\n"
          "    localDir - Location of local data dir\n"
          "    localSize - Megabytes of local disk\n"
          "    switchName - Name of switch this is on\n"
 	 "\n"
 	 "options:\n"
 	 "   -spokes=N  Number of processes that feed jobs to nodes - default %d.\n"
 	 "   -jobCheckPeriod=N  Minutes between checking on job - default %d.\n"
 	 "   -machineCheckPeriod=N  Minutes between checking on machine - default %d.\n"
 	 "   -subnet=XXX.YYY.ZZZ Only accept connections from subnet (example 192.168).\n"
+	 "     Or CIDR notation (example 192.168.1.2/24).\n"
 	 "   -nextJobId=N  Starting job ID number.\n"
 	 "   -logFacility=facility  Log to the specified syslog facility - default local0.\n"
          "   -logMinPriority=pri minimum syslog priority to log, also filters file logging.\n"
          "    defaults to \"warn\"\n"
          "   -log=file  Log to file instead of syslog.\n"
          "   -debug  Don't daemonize\n"
 	 "   -noResume  Don't try to reconnect with jobs running on nodes.\n"
          "   -ramUnit=N  Number of bytes of RAM in the base unit used by the jobs.\n"
          "      Default is RAM on node divided by number of cpus on node.\n"
          "      Shorthand expressions allow t,g,m,k for tera, giga, mega, kilo.\n"
          "      e.g. 4g = 4 Gigabytes.\n"
 	 "   -defaultJobRam=N Number of ram units in a job has no specified ram usage.\n"
 	 "      Defaults to 1.\n"
 	               ,
 	 version, initialSpokes, jobCheckPeriod, machineCheckPeriod
@@ -3442,33 +3445,32 @@
     else 
          warn("Unrecognized command %s", command);
     pmFree(&pm);
     }
 endHeartbeat();
 killSpokes();
 saveJobId();
 #ifdef SOON
 #endif /* SOON */
 }
 
 void fillInSubnet()
 /* Parse subnet paramenter if any into subnet variable. */
 {
 char *sns = optionVal("subnet", NULL);
-if (sns == NULL)
-    sns = optionVal("subNet", NULL);
-netParseSubnet(sns, hubSubnet);
+hubSubnet = internetParseSubnetCidr(sns);
+localHostSubnet = internetParseSubnetCidr("127.0.0.1"); /* Address for local host */
 }
 
 int main(int argc, char *argv[])
 /* Process command line. */
 {
 optionInit(&argc, argv, optionSpecs);
 if (argc < 2)
     usage();
 if (optionExists("ramUnit"))
     {
     ramUnit = paraParseRam(optionVal("ramUnit", ""));
     if (ramUnit == -1)
 	errAbort("Invalid RAM expression '%s' in '-ramUnit=' option", optionVal("ramUnit", ""));
     }
 if (optionExists("defaultJobRam"))