Print this page
4953763 Need way to configure NFS window sizes without changing system wide defaults
6216670 NFS server needs a bigger transmit buffer


 111 int     listen_backlog = 32;    /* used by bind_to_{provider,proto}() */
 112 int     num_servers;            /* used by cots_listen_event() */
 113 int     (*Mysvc)(int, struct netbuf, struct netconfig *) = nfssvc;
 114                                 /* used by cots_listen_event() */
 115 int     max_conns_allowed = -1; /* used by cots_listen_event() */
 116 
 117 /*
 118  * Keep track of min/max versions of NFS protocol to be started.
 119  * Start with the defaults (min == 2, max == 3).  We have the
 120  * capability of starting vers=4 but only if the user requests it.
 121  */
 122 int     nfs_server_vers_min = NFS_VERSMIN_DEFAULT;
 123 int     nfs_server_vers_max = NFS_VERSMAX_DEFAULT;
 124 
 125 /*
 126  * Set the default for server delegation enablement and set per
 127  * /etc/default/nfs configuration (if present).
 128  */
 129 int     nfs_server_delegation = NFS_SERVER_DELEGATION_DEFAULT;
 130 













 131 int
 132 main(int ac, char *av[])
 133 {
 134         char *dir = "/";
 135         int allflag = 0;
 136         int df_allflag = 0;
 137         int opt_cnt = 0;
 138         int maxservers = 1;     /* zero allows inifinte number of threads */
 139         int maxservers_set = 0;
 140         int logmaxservers = 0;
 141         int pid;
 142         int i;
 143         char *provider = (char *)NULL;
 144         char *df_provider = (char *)NULL;
 145         struct protob *protobp0, *protobp;
 146         NETSELDECL(proto) = NULL;
 147         NETSELDECL(df_proto) = NULL;
 148         NETSELPDECL(providerp);
 149         char *defval;
 150         boolean_t can_do_mlp;
 151         uint_t dss_npaths = 0;
 152         char **dss_pathnames = NULL;
 153         sigset_t sgset;
 154 
 155         int pipe_fd = -1;
 156 
 157         MyName = *av;
 158 
 159         /*
 160          * Initializations that require more privileges than we need to run.
 161          */
 162         (void) _create_daemon_lock(NFSD, DAEMON_UID, DAEMON_GID);


 218                         errno = 0;
 219                         nfs_server_vers_min =
 220                             strtol(defval, (char **)NULL, 10);
 221                         if (errno != 0) {
 222                                 nfs_server_vers_min = NFS_VERSMIN_DEFAULT;
 223                         }
 224                 }
 225                 if ((defval = defread("NFS_SERVER_VERSMAX=")) != NULL) {
 226                         errno = 0;
 227                         nfs_server_vers_max =
 228                             strtol(defval, (char **)NULL, 10);
 229                         if (errno != 0) {
 230                                 nfs_server_vers_max = NFS_VERSMAX_DEFAULT;
 231                         }
 232                 }
 233                 if ((defval = defread("NFS_SERVER_DELEGATION=")) != NULL) {
 234                         if (strcmp(defval, "off") == 0) {
 235                                 nfs_server_delegation = FALSE;
 236                         }
 237                 }












 238 
 239                 /* close defaults file */
 240                 defopen(NULL);
 241         }
 242 
 243         /*
 244          * Conflict options error messages.
 245          */
 246         if (opt_cnt > 1) {
 247                 (void) fprintf(stderr, "\nConflicting options, only one of "
 248                     "the following options can be specified\n"
 249                     "in " NFSADMIN ":\n"
 250                     "\tNFSD_PROTOCOL=ALL\n"
 251                     "\tNFSD_PROTOCOL=protocol\n"
 252                     "\tNFSD_DEVICE=device\n\n");
 253                 usage();
 254         }
 255         opt_cnt = 0;
 256 
 257         while ((i = getopt(ac, av, "ac:p:s:t:l:")) != EOF) {


 517         /*
 518          * Build a protocol block list for registration.
 519          */
 520         protobp0 = protobp = (struct protob *)malloc(sizeof (struct protob));
 521         protobp->serv = "NFS";
 522         protobp->versmin = nfs_server_vers_min;
 523         protobp->versmax = nfs_server_vers_max;
 524         protobp->program = NFS_PROGRAM;
 525 
 526         protobp->next = (struct protob *)malloc(sizeof (struct protob));
 527         protobp = protobp->next;
 528         protobp->serv = "NFS_ACL";           /* not used */
 529         protobp->versmin = nfs_server_vers_min;
 530         /* XXX - this needs work to get the version just right */
 531         protobp->versmax = (nfs_server_vers_max > NFS_ACL_V3) ?
 532             NFS_ACL_V3 : nfs_server_vers_max;
 533         protobp->program = NFS_ACL_PROGRAM;
 534         protobp->next = (struct protob *)NULL;
 535 
 536         if (allflag) {
 537                 if (do_all(protobp0, nfssvc, 0) == -1) {

 538                         fprintf(stderr, "setnetconfig failed : %s",
 539                             strerror(errno));
 540                         exit(1);
 541                 }
 542         } else if (proto) {
 543                 /* there's more than one match for the same protocol */
 544                 struct netconfig *nconf;
 545                 NCONF_HANDLE *nc;
 546                 bool_t  protoFound = FALSE;
 547                 if ((nc = setnetconfig()) == (NCONF_HANDLE *) NULL) {
 548                         fprintf(stderr, "setnetconfig failed : %s",
 549                             strerror(errno));
 550                         goto done;
 551                 }
 552                 while (nconf = getnetconfig(nc)) {
 553                         if (strcmp(nconf->nc_proto, proto) == 0) {
 554                                 protoFound = TRUE;
 555                                 do_one(nconf->nc_device, NULL,
 556                                     protobp0, nfssvc, 0);

 557                         }
 558                 }
 559                 (void) endnetconfig(nc);
 560                 if (protoFound == FALSE) {
 561                         fprintf(stderr,
 562                             "couldn't find netconfig entry for protocol %s",
 563                             proto);
 564                 }
 565         } else if (provider)
 566                 do_one(provider, proto, protobp0, nfssvc, 0);

 567         else {
 568                 for (providerp = defaultproviders;
 569                     *providerp != NULL; providerp++) {
 570                         provider = *providerp;
 571                         do_one(provider, NULL, protobp0, nfssvc, 0);

 572                 }
 573         }
 574 done:
 575 
 576         free(protobp);
 577         free(protobp0);
 578 
 579         if (num_fds == 0) {
 580                 fprintf(stderr, "Could not start NFS service for any protocol."
 581                     " Exiting");
 582                 exit(1);
 583         }
 584 
 585         end_listen_fds = num_fds;
 586 
 587         /*
 588          * nfsd is up and running as far as we are concerned.
 589          */
 590         daemonize_fini(pipe_fd);
 591 




 111 int     listen_backlog = 32;    /* used by bind_to_{provider,proto}() */
 112 int     num_servers;            /* used by cots_listen_event() */
 113 int     (*Mysvc)(int, struct netbuf, struct netconfig *) = nfssvc;
 114                                 /* used by cots_listen_event() */
 115 int     max_conns_allowed = -1; /* used by cots_listen_event() */
 116 
 117 /*
 118  * Keep track of min/max versions of NFS protocol to be started.
 119  * Start with the defaults (min == 2, max == 3).  We have the
 120  * capability of starting vers=4 but only if the user requests it.
 121  */
 122 int     nfs_server_vers_min = NFS_VERSMIN_DEFAULT;
 123 int     nfs_server_vers_max = NFS_VERSMAX_DEFAULT;
 124 
 125 /*
 126  * Set the default for server delegation enablement and set per
 127  * /etc/default/nfs configuration (if present).
 128  */
 129 int     nfs_server_delegation = NFS_SERVER_DELEGATION_DEFAULT;
 130 
 131 /*
 132  * Default values for TCP send and receive buffer size of NFS server
 133  * connections.
 134  *
 135  * These values can be tuned by user via /etc/default/nfs configuration
 136  * file by setting NFS_SERVER_SNDBUFSZ and NFS_SERVER_RCVBUFSZ.
 137  *
 138  * To force NFS connections to use system-wide default for TCP send and
 139  * receive buffer, set NFS_SERVER_SNDBUFSZ and NFS_SERVER_RCVBUFSZ to 0.
 140  */
 141 int     nfs_server_sndbufsz = 1048576;
 142 int     nfs_server_rcvbufsz = 1048576;
 143 
 144 int
 145 main(int ac, char *av[])
 146 {
 147         char *dir = "/";
 148         int allflag = 0;
 149         int df_allflag = 0;
 150         int opt_cnt = 0;
 151         int maxservers = 1;     /* zero allows inifinte number of threads */
 152         int maxservers_set = 0;
 153         int logmaxservers = 0;
 154         int pid;
 155         int i, bufsz;
 156         char *provider = (char *)NULL;
 157         char *df_provider = (char *)NULL;
 158         struct protob *protobp0, *protobp;
 159         NETSELDECL(proto) = NULL;
 160         NETSELDECL(df_proto) = NULL;
 161         NETSELPDECL(providerp);
 162         char *defval;
 163         boolean_t can_do_mlp;
 164         uint_t dss_npaths = 0;
 165         char **dss_pathnames = NULL;
 166         sigset_t sgset;
 167 
 168         int pipe_fd = -1;
 169 
 170         MyName = *av;
 171 
 172         /*
 173          * Initializations that require more privileges than we need to run.
 174          */
 175         (void) _create_daemon_lock(NFSD, DAEMON_UID, DAEMON_GID);


 231                         errno = 0;
 232                         nfs_server_vers_min =
 233                             strtol(defval, (char **)NULL, 10);
 234                         if (errno != 0) {
 235                                 nfs_server_vers_min = NFS_VERSMIN_DEFAULT;
 236                         }
 237                 }
 238                 if ((defval = defread("NFS_SERVER_VERSMAX=")) != NULL) {
 239                         errno = 0;
 240                         nfs_server_vers_max =
 241                             strtol(defval, (char **)NULL, 10);
 242                         if (errno != 0) {
 243                                 nfs_server_vers_max = NFS_VERSMAX_DEFAULT;
 244                         }
 245                 }
 246                 if ((defval = defread("NFS_SERVER_DELEGATION=")) != NULL) {
 247                         if (strcmp(defval, "off") == 0) {
 248                                 nfs_server_delegation = FALSE;
 249                         }
 250                 }
 251                 if ((defval = defread("NFS_SERVER_SNDBUFSZ=")) != NULL) {
 252                         errno = 0;
 253                         bufsz = strtol(defval, (char **)NULL, 10);
 254                         if (errno == 0)
 255                                 nfs_server_sndbufsz = bufsz;
 256                 }
 257                 if ((defval = defread("NFS_SERVER_RCVBUFSZ=")) != NULL) {
 258                         errno = 0;
 259                         bufsz = strtol(defval, (char **)NULL, 10);
 260                         if (errno == 0)
 261                                 nfs_server_rcvbufsz = bufsz;
 262                 }
 263 
 264                 /* close defaults file */
 265                 defopen(NULL);
 266         }
 267 
 268         /*
 269          * Conflict options error messages.
 270          */
 271         if (opt_cnt > 1) {
 272                 (void) fprintf(stderr, "\nConflicting options, only one of "
 273                     "the following options can be specified\n"
 274                     "in " NFSADMIN ":\n"
 275                     "\tNFSD_PROTOCOL=ALL\n"
 276                     "\tNFSD_PROTOCOL=protocol\n"
 277                     "\tNFSD_DEVICE=device\n\n");
 278                 usage();
 279         }
 280         opt_cnt = 0;
 281 
 282         while ((i = getopt(ac, av, "ac:p:s:t:l:")) != EOF) {


 542         /*
 543          * Build a protocol block list for registration.
 544          */
 545         protobp0 = protobp = (struct protob *)malloc(sizeof (struct protob));
 546         protobp->serv = "NFS";
 547         protobp->versmin = nfs_server_vers_min;
 548         protobp->versmax = nfs_server_vers_max;
 549         protobp->program = NFS_PROGRAM;
 550 
 551         protobp->next = (struct protob *)malloc(sizeof (struct protob));
 552         protobp = protobp->next;
 553         protobp->serv = "NFS_ACL";           /* not used */
 554         protobp->versmin = nfs_server_vers_min;
 555         /* XXX - this needs work to get the version just right */
 556         protobp->versmax = (nfs_server_vers_max > NFS_ACL_V3) ?
 557             NFS_ACL_V3 : nfs_server_vers_max;
 558         protobp->program = NFS_ACL_PROGRAM;
 559         protobp->next = (struct protob *)NULL;
 560 
 561         if (allflag) {
 562                 if (do_all_setbuf(protobp0, nfssvc, 0, nfs_server_sndbufsz,
 563                     nfs_server_rcvbufsz) == -1) {
 564                         fprintf(stderr, "setnetconfig failed : %s",
 565                             strerror(errno));
 566                         exit(1);
 567                 }
 568         } else if (proto) {
 569                 /* there's more than one match for the same protocol */
 570                 struct netconfig *nconf;
 571                 NCONF_HANDLE *nc;
 572                 bool_t  protoFound = FALSE;
 573                 if ((nc = setnetconfig()) == (NCONF_HANDLE *) NULL) {
 574                         fprintf(stderr, "setnetconfig failed : %s",
 575                             strerror(errno));
 576                         goto done;
 577                 }
 578                 while (nconf = getnetconfig(nc)) {
 579                         if (strcmp(nconf->nc_proto, proto) == 0) {
 580                                 protoFound = TRUE;
 581                                 do_one_setbuf(nconf->nc_device, NULL,
 582                                     protobp0, nfssvc, 0,
 583                                     nfs_server_sndbufsz, nfs_server_rcvbufsz);
 584                         }
 585                 }
 586                 (void) endnetconfig(nc);
 587                 if (protoFound == FALSE) {
 588                         fprintf(stderr,
 589                             "couldn't find netconfig entry for protocol %s",
 590                             proto);
 591                 }
 592         } else if (provider)
 593                 do_one_setbuf(provider, proto, protobp0, nfssvc, 0,
 594                     nfs_server_sndbufsz, nfs_server_rcvbufsz);
 595         else {
 596                 for (providerp = defaultproviders;
 597                     *providerp != NULL; providerp++) {
 598                         provider = *providerp;
 599                         do_one_setbuf(provider, NULL, protobp0, nfssvc, 0,
 600                             nfs_server_sndbufsz, nfs_server_rcvbufsz);
 601                 }
 602         }
 603 done:
 604 
 605         free(protobp);
 606         free(protobp0);
 607 
 608         if (num_fds == 0) {
 609                 fprintf(stderr, "Could not start NFS service for any protocol."
 610                     " Exiting");
 611                 exit(1);
 612         }
 613 
 614         end_listen_fds = num_fds;
 615 
 616         /*
 617          * nfsd is up and running as far as we are concerned.
 618          */
 619         daemonize_fini(pipe_fd);
 620