Print this page
nfssrv: nfsstat reports zeroed data in zone

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/nfs/nfs_server.c
          +++ new/usr/src/uts/common/fs/nfs/nfs_server.c
↓ open down ↓ 187 lines elided ↑ open up ↑
 188  188                  ((disp->dis_flags & RPC_PUBLICFH_OK) && \
 189  189                  ((exi->exi_export.ex_flags & EX_PUBLIC) || \
 190  190                  (exi == ne->exi_public && exportmatch(ne->exi_root, \
 191  191                  fsid, xfid))))
 192  192  
 193  193  static void     nfs_srv_shutdown_all(int);
 194  194  static void     rfs4_server_start(nfs_globals_t *, int);
 195  195  static void     nullfree(void);
 196  196  static void     rfs_dispatch(struct svc_req *, SVCXPRT *);
 197  197  static void     acl_dispatch(struct svc_req *, SVCXPRT *);
 198      -static void     common_dispatch(struct svc_req *, SVCXPRT *,
 199      -                rpcvers_t, rpcvers_t, char *,
 200      -                struct rpc_disptable *);
 201  198  static  int     checkauth(struct exportinfo *, struct svc_req *, cred_t *, int,
 202  199                  bool_t, bool_t *);
 203  200  static char     *client_name(struct svc_req *req);
 204  201  static char     *client_addr(struct svc_req *req, char *buf);
 205  202  extern  int     sec_svc_getcred(struct svc_req *, cred_t *cr, char **, int *);
 206  203  extern  bool_t  sec_svc_inrootlist(int, caddr_t, int, caddr_t *);
 207  204  static void     *nfs_server_zone_init(zoneid_t);
 208  205  static void     nfs_server_zone_fini(zoneid_t, void *);
 209  206  static void     nfs_server_zone_shutdown(zoneid_t, void *);
 210  207  
↓ open down ↓ 1116 lines elided ↑ open up ↑
1327 1324          /* RFS_NULL = 0 */
1328 1325  
1329 1326          /* RFS4_COMPOUND = 1 */
1330 1327          COMPOUND4res nfs4_compound_res;
1331 1328  
1332 1329  };
1333 1330  
1334 1331  static struct rpc_disptable rfs_disptable[] = {
1335 1332          {sizeof (rfsdisptab_v2) / sizeof (rfsdisptab_v2[0]),
1336 1333              rfscallnames_v2,
1337      -            &rfsproccnt_v2_ptr, rfsdisptab_v2},
     1334 +            rfsdisptab_v2},
1338 1335          {sizeof (rfsdisptab_v3) / sizeof (rfsdisptab_v3[0]),
1339 1336              rfscallnames_v3,
1340      -            &rfsproccnt_v3_ptr, rfsdisptab_v3},
     1337 +            rfsdisptab_v3},
1341 1338          {sizeof (rfsdisptab_v4) / sizeof (rfsdisptab_v4[0]),
1342 1339              rfscallnames_v4,
1343      -            &rfsproccnt_v4_ptr, rfsdisptab_v4},
     1340 +            rfsdisptab_v4},
1344 1341  };
1345 1342  
1346 1343  /*
1347 1344   * If nfs_portmon is set, then clients are required to use privileged
1348 1345   * ports (ports < IPPORT_RESERVED) in order to get NFS services.
1349 1346   *
1350 1347   * N.B.: this attempt to carry forward the already ill-conceived notion
1351 1348   * of privileged ports for TCP/UDP is really quite ineffectual.  Not only
1352 1349   * is it transport-dependent, it's laughably easy to spoof.  If you're
1353 1350   * really interested in security, you must start with secure RPC instead.
↓ open down ↓ 101 lines elided ↑ open up ↑
1455 1452                  if ((enum wnfsstat)dr->dr_status == WNFSERR_CLNT_FLAVOR)
1456 1453                          return (TRUE);
1457 1454          } else if (req->rq_vers == NFS_V3 && req->rq_proc == NFSPROC3_LOOKUP) {
1458 1455                  LOOKUP3res *resp = (LOOKUP3res *)res;
1459 1456                  if ((enum wnfsstat)resp->status == WNFSERR_CLNT_FLAVOR)
1460 1457                          return (TRUE);
1461 1458          }
1462 1459          return (FALSE);
1463 1460  }
1464 1461  
1465      -
1466 1462  static void
1467 1463  common_dispatch(struct svc_req *req, SVCXPRT *xprt, rpcvers_t min_vers,
1468 1464      rpcvers_t max_vers, char *pgmname, struct rpc_disptable *disptable)
1469 1465  {
1470 1466          int which;
1471 1467          rpcvers_t vers;
1472 1468          char *args;
1473 1469          union {
1474 1470                          union rfs_args ra;
1475 1471                          union acl_args aa;
↓ open down ↓ 16 lines elided ↑ open up ↑
1492 1488          bool_t publicfh_ok = FALSE;
1493 1489          enum_t auth_flavor;
1494 1490          bool_t dupcached = FALSE;
1495 1491          struct netbuf   nb;
1496 1492          bool_t logging_enabled = FALSE;
1497 1493          struct exportinfo *nfslog_exi = NULL;
1498 1494          char **procnames;
1499 1495          char cbuf[INET6_ADDRSTRLEN];    /* to hold both IPv4 and IPv6 addr */
1500 1496          bool_t ro = FALSE;
1501 1497          nfs_export_t *ne = nfs_get_export();
     1498 +        nfs_globals_t *ng = ne->ne_globals;
     1499 +        kstat_named_t *svstat, *procstat;
1502 1500  
     1501 +        ASSERT(req->rq_prog == NFS_PROGRAM || req->rq_prog == NFS_ACL_PROGRAM);
     1502 +
1503 1503          vers = req->rq_vers;
1504 1504  
     1505 +        svstat = ng->svstat[req->rq_vers];
     1506 +        procstat = (req->rq_prog == NFS_PROGRAM) ?
     1507 +            ng->rfsproccnt[vers] : ng->aclproccnt[vers];
     1508 +
1505 1509          if (vers < min_vers || vers > max_vers) {
1506 1510                  svcerr_progvers(req->rq_xprt, min_vers, max_vers);
1507 1511                  error++;
1508 1512                  cmn_err(CE_NOTE, "%s: bad version number %u", pgmname, vers);
1509 1513                  goto done;
1510 1514          }
1511 1515          vers -= min_vers;
1512 1516  
1513 1517          which = req->rq_proc;
1514 1518          if (which < 0 || which >= disptable[(int)vers].dis_nprocs) {
1515 1519                  svcerr_noproc(req->rq_xprt);
1516 1520                  error++;
1517 1521                  goto done;
1518 1522          }
1519 1523  
1520      -        (*(disptable[(int)vers].dis_proccntp))[which].value.ui64++;
     1524 +        procstat[which].value.ui64++;
1521 1525  
1522 1526          disp = &disptable[(int)vers].dis_table[which];
1523 1527          procnames = disptable[(int)vers].dis_procnames;
1524 1528  
1525 1529          auth_flavor = req->rq_cred.oa_flavor;
1526 1530  
1527 1531          /*
1528 1532           * Deserialize into the args struct.
1529 1533           */
1530 1534          args = (char *)&args_buf;
↓ open down ↓ 301 lines elided ↑ open up ↑
1832 1836          } else {
1833 1837                  if (!SVC_FREEARGS(xprt, (xdrproc_t)0, (caddr_t)0)) {
1834 1838                          cmn_err(CE_NOTE, "%s: bad freeargs", pgmname);
1835 1839                          error++;
1836 1840                  }
1837 1841          }
1838 1842  
1839 1843          if (exi != NULL)
1840 1844                  exi_rele(exi);
1841 1845  
1842      -        global_svstat_ptr[req->rq_vers][NFS_BADCALLS].value.ui64 += error;
1843      -
1844      -        global_svstat_ptr[req->rq_vers][NFS_CALLS].value.ui64++;
     1846 +        svstat[NFS_BADCALLS].value.ui64 += error;
     1847 +        svstat[NFS_CALLS].value.ui64++;
1845 1848  }
1846 1849  
1847 1850  static void
1848 1851  rfs_dispatch(struct svc_req *req, SVCXPRT *xprt)
1849 1852  {
1850 1853          common_dispatch(req, xprt, NFS_VERSMIN, NFS_VERSMAX,
1851 1854              "NFS", rfs_disptable);
1852 1855  }
1853 1856  
1854 1857  static char *aclcallnames_v2[] = {
↓ open down ↓ 102 lines elided ↑ open up ↑
1957 1960          {acl3_getxattrdir,
1958 1961              xdr_GETXATTRDIR3args, NULL_xdrproc_t, sizeof (GETXATTRDIR3args),
1959 1962              xdr_GETXATTRDIR3res, NULL_xdrproc_t, sizeof (GETXATTRDIR3res),
1960 1963              nullfree, RPC_IDEMPOTENT,
1961 1964              acl3_getxattrdir_getfh},
1962 1965  };
1963 1966  
1964 1967  static struct rpc_disptable acl_disptable[] = {
1965 1968          {sizeof (acldisptab_v2) / sizeof (acldisptab_v2[0]),
1966 1969                  aclcallnames_v2,
1967      -                &aclproccnt_v2_ptr, acldisptab_v2},
     1970 +                acldisptab_v2},
1968 1971          {sizeof (acldisptab_v3) / sizeof (acldisptab_v3[0]),
1969 1972                  aclcallnames_v3,
1970      -                &aclproccnt_v3_ptr, acldisptab_v3},
     1973 +                acldisptab_v3},
1971 1974  };
1972 1975  
1973 1976  static void
1974 1977  acl_dispatch(struct svc_req *req, SVCXPRT *xprt)
1975 1978  {
1976 1979          common_dispatch(req, xprt, NFS_ACL_VERSMIN, NFS_ACL_VERSMAX,
1977 1980              "ACL", acl_disptable);
1978 1981  }
1979 1982  
1980 1983  int
↓ open down ↓ 661 lines elided ↑ open up ↑
2642 2645          mutex_init(&ng->rdma_wait_mutex, NULL, MUTEX_DEFAULT, NULL);
2643 2646          cv_init(&ng->rdma_wait_cv, NULL, CV_DEFAULT, NULL);
2644 2647  
2645 2648          ng->nfs_zoneid = zoneid;
2646 2649  
2647 2650          /*
2648 2651           * Order here is important.
2649 2652           * export init must precede srv init calls.
2650 2653           */
2651 2654          nfs_export_zone_init(ng);
     2655 +        rfs_stat_zone_init(ng);
2652 2656          rfs_srv_zone_init(ng);
2653 2657          rfs3_srv_zone_init(ng);
2654 2658          rfs4_srv_zone_init(ng);
2655 2659          nfsauth_zone_init(ng);
2656 2660  
2657 2661          rw_enter(&nfssrv_globals_rwl, RW_WRITER);
2658 2662          list_insert_tail(&nfssrv_globals_list, ng);
2659 2663          rw_exit(&nfssrv_globals_rwl);
2660 2664  
2661 2665          return (ng);
↓ open down ↓ 28 lines elided ↑ open up ↑
2690 2694          rw_exit(&nfssrv_globals_rwl);
2691 2695  
2692 2696          /*
2693 2697           * Order here is important.
2694 2698           * reverse order from init
2695 2699           */
2696 2700          nfsauth_zone_fini(ng);
2697 2701          rfs4_srv_zone_fini(ng);
2698 2702          rfs3_srv_zone_fini(ng);
2699 2703          rfs_srv_zone_fini(ng);
     2704 +        rfs_stat_zone_fini(ng);
2700 2705          nfs_export_zone_fini(ng);
2701 2706  
2702 2707          mutex_destroy(&ng->nfs_server_upordown_lock);
2703 2708          cv_destroy(&ng->nfs_server_upordown_cv);
2704 2709          mutex_destroy(&ng->rdma_wait_mutex);
2705 2710          cv_destroy(&ng->rdma_wait_cv);
2706 2711  
2707 2712          kmem_free(ng, sizeof (*ng));
2708 2713  }
2709 2714  
↓ open down ↓ 696 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX