Print this page
195 Need replacement for nfs/lockd+klm
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Jeremy Jones <jeremy@delphix.com>
Reviewed by: Jeff Biseda <jbiseda@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_nlm.c
          +++ new/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_nlm.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  /*
  23   23   * Copyright (c) 1991, 1998, 2001 by Sun Microsystems, Inc.
  24   24   * All rights reserved.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
       29 + * Copyright (c) 2012 by Delphix. All rights reserved.
       30 + */
       31 +
  27   32  #include <sys/types.h>
  28   33  #include <setjmp.h>
  29   34  #include <string.h>
  30   35  
  31   36  #ifdef notdef
  32   37  #include <rpc/xdr.h>
  33   38  #include <rpc/auth.h>
  34   39  #include <rpc/rpc_msg.h>
  35   40  #endif /* notdef */
  36   41  #include <rpcsvc/nlm_prot.h>
↓ open down ↓ 774 lines elided ↑ open up ↑
 811  816                  }
 812  817  
 813  818                  line = get_sum_line();
 814  819  
 815  820                  if (type == CALL) {
 816  821                          (void) sprintf(line,
 817  822                                  "NLM C %s",
 818  823                                  procnames_short_4[proc]);
 819  824                          line += strlen(line);
 820  825                          switch (proc) {
 821      -                        case NLMPROC4_TEST:
 822      -                        case NLMPROC4_GRANTED:
 823      -                        case NLMPROC4_TEST_MSG:
 824      -                        case NLMPROC4_GRANTED_MSG:
      826 +                        case NLM4_TEST:
      827 +                        case NLM4_GRANTED:
      828 +                        case NLM4_TEST_MSG:
      829 +                        case NLM4_GRANTED_MSG:
 825  830                                  /* testargs */
 826  831                                  (void) strcat(line, sum_netobj("OH"));
 827  832                                  (void) getxdr_bool();   /* Excl */
 828  833                                  (void) strcat(line, sum_lock4());
 829  834                                  break;
 830      -                        case NLMPROC4_LOCK:
 831      -                        case NLMPROC4_LOCK_MSG:
      835 +                        case NLM4_LOCK:
      836 +                        case NLM4_LOCK_MSG:
 832  837                                  /* lockargs */
 833  838                                  (void) strcat(line, sum_netobj("OH"));
 834  839                                  (void) getxdr_bool();   /* Block */
 835  840                                  (void) getxdr_bool();   /* Excl */
 836  841                                  (void) strcat(line, sum_lock4());
 837  842                                  /* ignore reclaim, state fields */
 838  843                                  break;
 839      -                        case NLMPROC4_CANCEL:
 840      -                        case NLMPROC4_CANCEL_MSG:
      844 +                        case NLM4_CANCEL:
      845 +                        case NLM4_CANCEL_MSG:
 841  846                                  /* cancargs */
 842  847                                  (void) strcat(line, sum_netobj("OH"));
 843  848                                  (void) getxdr_bool();   /* Block */
 844  849                                  (void) getxdr_bool();   /* Excl */
 845  850                                  (void) strcat(line, sum_lock4());
 846  851                                  break;
 847      -                        case NLMPROC4_UNLOCK:
 848      -                        case NLMPROC4_UNLOCK_MSG:
      852 +                        case NLM4_UNLOCK:
      853 +                        case NLM4_UNLOCK_MSG:
 849  854                                  /* unlockargs */
 850  855                                  (void) strcat(line, sum_netobj("OH"));
 851  856                                  (void) strcat(line, sum_lock4());
 852  857                                  break;
 853      -                        case NLMPROC4_TEST_RES:
      858 +                        case NLM4_TEST_RES:
 854  859                                  /* testres */
 855  860                                  (void) strcat(line, sum_netobj("OH"));
 856  861                                  (void) strcat(line, " ");
 857  862                                  (void) strcat(line,
 858  863                                      nameof_stat4(getxdr_u_long()));
 859  864                                  break;
 860      -                        case NLMPROC4_LOCK_RES:
 861      -                        case NLMPROC4_CANCEL_RES:
 862      -                        case NLMPROC4_UNLOCK_RES:
 863      -                        case NLMPROC4_GRANTED_RES:
      865 +                        case NLM4_LOCK_RES:
      866 +                        case NLM4_CANCEL_RES:
      867 +                        case NLM4_UNLOCK_RES:
      868 +                        case NLM4_GRANTED_RES:
 864  869                                  /* res */
 865  870                                  (void) strcat(line, sum_netobj("OH"));
 866  871                                  (void) strcat(line, " ");
 867  872                                  (void) strcat(line,
 868  873                                          nameof_stat4(getxdr_u_long()));
 869  874                                  break;
 870      -                        case NLMPROC4_SHARE:
 871      -                        case NLMPROC4_UNSHARE:
      875 +                        case NLM4_SHARE:
      876 +                        case NLM4_UNSHARE:
 872  877                                  (void) strcat(line, sum_netobj("OH"));
 873  878                                  (void) strcat(line, sum_share());
 874  879                                  break;
 875      -                        case NLMPROC4_NM_LOCK:
      880 +                        case NLM4_NM_LOCK:
 876  881                                  /* lockargs */
 877  882                                  skip_netobj();          /* Cookie */
 878  883                                  (void) getxdr_bool();   /* Block */
 879  884                                  (void) getxdr_bool();   /* Excl */
 880  885                                  (void) strcat(line, sum_lock4());
 881  886                                  /* skip reclaim & state fields */
 882  887                                  break;
 883      -                        case NLMPROC4_FREE_ALL:
      888 +                        case NLM4_FREE_ALL:
 884  889                                  (void) sprintf(line,
 885  890                                          " %s", sum_notify());
 886  891                                  break;
 887  892                          }
 888  893                          check_retransmit(line, (ulong_t)xid);
 889  894                  } else {
 890  895                          (void) sprintf(line, "NLM R %s",
 891  896                                  procnames_short_4[proc]);
 892  897                          line += strlen(line);
 893  898                          switch (proc) {
 894      -                        case NLMPROC4_TEST:
      899 +                        case NLM4_TEST:
 895  900                                  /* testres */
 896  901                                  (void) strcat(line, sum_netobj("OH"));
 897  902                                  (void) strcat(line, " ");
 898  903                                  (void) strcat(line,
 899  904                                      nameof_stat4(getxdr_u_long()));
 900  905                                  break;
 901      -                        case NLMPROC4_LOCK:
 902      -                        case NLMPROC4_CANCEL:
 903      -                        case NLMPROC4_UNLOCK:
 904      -                        case NLMPROC4_GRANTED:
 905      -                        case NLMPROC4_NM_LOCK:
      906 +                        case NLM4_LOCK:
      907 +                        case NLM4_CANCEL:
      908 +                        case NLM4_UNLOCK:
      909 +                        case NLM4_GRANTED:
      910 +                        case NLM4_NM_LOCK:
 906  911                                  /* res */
 907  912                                  (void) strcat(line, sum_netobj("OH"));
 908  913                                  (void) strcat(line, " ");
 909  914                                  (void) strcat(line,
 910  915                                          nameof_stat4(getxdr_u_long()));
 911  916                                  break;
 912      -                        case NLMPROC4_SHARE:
 913      -                        case NLMPROC4_UNSHARE:
      917 +                        case NLM4_SHARE:
      918 +                        case NLM4_UNSHARE:
 914  919                                  /* shareres */
 915  920                                  pl = sum_netobj("OH");
 916  921                                  i = getxdr_u_long();
 917  922                                  sprintf(line, "%s %s %ld",
 918  923                                          pl, nameof_stat4(i), getxdr_long());
 919  924                                  break;
 920      -                        case NLMPROC4_FREE_ALL:
      925 +                        case NLM4_FREE_ALL:
 921  926                                  break;
 922  927                          }
 923  928                  }
 924  929          }
 925  930  
 926  931          if (flags & F_DTAIL) {
 927  932                  show_header("NLM:  ", "Network Lock Manager", len);
 928  933                  show_space();
 929  934                  if (setjmp(xdr_err)) {
 930  935                          return;
 931  936                  }
 932  937                  (void) sprintf(get_line(0, 0),
 933  938                          "Proc = %d (%s)",
 934  939                          proc, procnames_long_4[proc]);
 935  940                  if (type == CALL) {
 936  941                          switch (proc) {
 937      -                        case NLMPROC4_TEST:
 938      -                        case NLMPROC4_GRANTED:
 939      -                        case NLMPROC4_TEST_MSG:
 940      -                        case NLMPROC4_GRANTED_MSG:
      942 +                        case NLM4_TEST:
      943 +                        case NLM4_GRANTED:
      944 +                        case NLM4_TEST_MSG:
      945 +                        case NLM4_GRANTED_MSG:
 941  946                                  show_testargs4();
 942  947                                  break;
 943      -                        case NLMPROC4_LOCK:
 944      -                        case NLMPROC4_LOCK_MSG:
 945      -                        case NLMPROC4_NM_LOCK:
      948 +                        case NLM4_LOCK:
      949 +                        case NLM4_LOCK_MSG:
      950 +                        case NLM4_NM_LOCK:
 946  951                                  show_lockargs4();
 947  952                                  break;
 948      -                        case NLMPROC4_CANCEL:
 949      -                        case NLMPROC4_CANCEL_MSG:
      953 +                        case NLM4_CANCEL:
      954 +                        case NLM4_CANCEL_MSG:
 950  955                                  show_cancargs4();
 951  956                                  break;
 952      -                        case NLMPROC4_UNLOCK:
 953      -                        case NLMPROC4_UNLOCK_MSG:
      957 +                        case NLM4_UNLOCK:
      958 +                        case NLM4_UNLOCK_MSG:
 954  959                                  show_unlockargs4();
 955  960                                  break;
 956      -                        case NLMPROC4_TEST_RES:
      961 +                        case NLM4_TEST_RES:
 957  962                                  show_testres4();
 958  963                                  break;
 959      -                        case NLMPROC4_LOCK_RES:
 960      -                        case NLMPROC4_CANCEL_RES:
 961      -                        case NLMPROC4_UNLOCK_RES:
 962      -                        case NLMPROC4_GRANTED_RES:
      964 +                        case NLM4_LOCK_RES:
      965 +                        case NLM4_CANCEL_RES:
      966 +                        case NLM4_UNLOCK_RES:
      967 +                        case NLM4_GRANTED_RES:
 963  968                                  show_res4();
 964  969                                  break;
 965      -                        case NLMPROC4_SHARE:
 966      -                        case NLMPROC4_UNSHARE:
      970 +                        case NLM4_SHARE:
      971 +                        case NLM4_UNSHARE:
 967  972                                  show_shareargs();
 968  973                                  break;
 969      -                        case NLMPROC4_FREE_ALL:
      974 +                        case NLM4_FREE_ALL:
 970  975                                  show_notify();
 971  976                                  break;
 972  977                          }
 973  978                  } else {
 974  979                          switch (proc) {
 975      -                        case NLMPROC4_TEST:
      980 +                        case NLM4_TEST:
 976  981                                  show_testres4();
 977  982                                  break;
 978      -                        case NLMPROC4_LOCK:
 979      -                        case NLMPROC4_CANCEL:
 980      -                        case NLMPROC4_UNLOCK:
 981      -                        case NLMPROC4_GRANTED:
      983 +                        case NLM4_LOCK:
      984 +                        case NLM4_CANCEL:
      985 +                        case NLM4_UNLOCK:
      986 +                        case NLM4_GRANTED:
 982  987                          case NLM_NM_LOCK:
 983  988                                  show_res4();
 984  989                                  break;
 985      -                        case NLMPROC4_TEST_MSG:
 986      -                        case NLMPROC4_LOCK_MSG:
 987      -                        case NLMPROC4_CANCEL_MSG:
 988      -                        case NLMPROC4_UNLOCK_MSG:
 989      -                        case NLMPROC4_GRANTED_MSG:
 990      -                        case NLMPROC4_TEST_RES:
 991      -                        case NLMPROC4_LOCK_RES:
 992      -                        case NLMPROC4_CANCEL_RES:
 993      -                        case NLMPROC4_UNLOCK_RES:
 994      -                        case NLMPROC4_GRANTED_RES:
      990 +                        case NLM4_TEST_MSG:
      991 +                        case NLM4_LOCK_MSG:
      992 +                        case NLM4_CANCEL_MSG:
      993 +                        case NLM4_UNLOCK_MSG:
      994 +                        case NLM4_GRANTED_MSG:
      995 +                        case NLM4_TEST_RES:
      996 +                        case NLM4_LOCK_RES:
      997 +                        case NLM4_CANCEL_RES:
      998 +                        case NLM4_UNLOCK_RES:
      999 +                        case NLM4_GRANTED_RES:
 995 1000                                  break;
 996 1001                          case NLM_SHARE:
 997 1002                          case NLM_UNSHARE:
 998 1003                                  show_shareres4();
 999 1004                                  break;
1000 1005                          case NLM_FREE_ALL:
1001 1006                                  break;
1002 1007                          }
1003 1008                  }
1004 1009                  show_trailer();
↓ open down ↓ 70 lines elided ↑ open up ↑
1075 1080  {
1076 1081          show_netobj("Cookie = %s");
1077 1082          (void) show_stat4();
1078 1083  }
1079 1084  
1080 1085  static char *
1081 1086  nameof_stat4(s)
1082 1087          ulong_t s;
1083 1088  {
1084 1089          switch ((enum nlm4_stats) s) {
1085      -        case NLM4_GRANTED:      return ("granted");
1086      -        case NLM4_DENIED:       return ("denied");
1087      -        case NLM4_DENIED_NOLOCKS:return ("denied (no locks)");
1088      -        case NLM4_BLOCKED:      return ("blocked");
1089      -        case NLM4_DENIED_GRACE_PERIOD: return ("denied (grace period)");
1090      -        case NLM4_DEADLCK:      return ("deadlock");
1091      -        case NLM4_ROFS:         return ("read-only fs");
1092      -        case NLM4_STALE_FH:     return ("stale fh");
1093      -        case NLM4_FBIG:         return ("file too big");
1094      -        case NLM4_FAILED:       return ("failed");
     1090 +        case nlm4_granted:      return ("granted");
     1091 +        case nlm4_denied:       return ("denied");
     1092 +        case nlm4_denied_nolocks:return ("denied (no locks)");
     1093 +        case nlm4_blocked:      return ("blocked");
     1094 +        case nlm4_denied_grace_period: return ("denied (grace period)");
     1095 +        case nlm4_deadlck:      return ("deadlock");
     1096 +        case nlm4_rofs:         return ("read-only fs");
     1097 +        case nlm4_stale_fh:     return ("stale fh");
     1098 +        case nlm4_fbig:         return ("file too big");
     1099 +        case nlm4_failed:       return ("failed");
1095 1100          default:                return ("?");
1096 1101          }
1097 1102  }
1098 1103  
1099 1104  static enum nlm4_stats
1100 1105  show_stat4()
1101 1106  {
1102 1107          enum nlm4_stats s;
1103 1108  
1104 1109          s = (enum nlm4_stats) getxdr_u_long();
↓ open down ↓ 27 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX