832 delay(SEC_TO_TICK(NLM_NSM_RPCBIND_TIMEOUT));
833 continue;
834 }
835 }
836
837 break;
838 }
839
840 if (stat != RPC_SUCCESS) {
841 DTRACE_PROBE2(rpcbind__error, enum clnt_stat, stat,
842 int, retries);
843 error = ENOENT;
844 goto error;
845 }
846
847 /*
848 * Create an RPC handle that'll be used for communication with local
849 * statd using the status monitor protocol.
850 */
851 error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS,
852 0, NLM_RPC_RETRIES, kcred, &nsm->ns_handle);
853 if (error != 0)
854 goto error;
855
856 /*
857 * Create an RPC handle that'll be used for communication with the
858 * local statd using the address registration protocol.
859 */
860 error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM,
861 NSM_ADDR_V1, 0, NLM_RPC_RETRIES, kcred, &nsm->ns_addr_handle);
862 if (error != 0)
863 goto error;
864
865 sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL);
866 return (0);
867
868 error:
869 kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
870 if (nsm->ns_handle)
871 CLNT_DESTROY(nsm->ns_handle);
872
873 return (error);
874 }
875
876 static void
877 nlm_nsm_fini(struct nlm_nsm *nsm)
878 {
879 kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
880 CLNT_DESTROY(nsm->ns_addr_handle);
881 nsm->ns_addr_handle = NULL;
882 CLNT_DESTROY(nsm->ns_handle);
883 nsm->ns_handle = NULL;
884 sema_destroy(&nsm->ns_sem);
885 }
886
887 static enum clnt_stat
888 nlm_nsm_simu_crash(struct nlm_nsm *nsm)
889 {
890 enum clnt_stat stat;
891
892 sema_p(&nsm->ns_sem);
893 nlm_nsm_clnt_init(nsm->ns_handle, nsm);
894 stat = sm_simu_crash_1(NULL, NULL, nsm->ns_handle);
895 sema_v(&nsm->ns_sem);
896
897 return (stat);
898 }
899
900 static enum clnt_stat
901 nlm_nsm_stat(struct nlm_nsm *nsm, int32_t *out_stat)
2791
2792 rw_exit(&lm_lck);
2793 }
2794
2795 void
2796 nlm_cprresume(void)
2797 {
2798 struct nlm_globals *g;
2799
2800 rw_enter(&lm_lck, RW_READER);
2801 TAILQ_FOREACH(g, &nlm_zones_list, nlm_link)
2802 nlm_resume_zone(g);
2803
2804 rw_exit(&lm_lck);
2805 }
2806
2807 void
2808 nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
2809 {
2810 (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
2811 NLM_RPC_RETRIES, kcred);
2812 }
2813
2814 void
2815 nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
2816 {
2817 /* LINTED pointer alignment */
2818 struct sockaddr *sa = (struct sockaddr *)addr->buf;
2819
2820 *family = sa->sa_family;
2821
2822 switch (sa->sa_family) {
2823 case AF_INET: {
2824 /* LINTED pointer alignment */
2825 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
2826
2827 obj->n_len = sizeof (sin->sin_addr);
2828 obj->n_bytes = (char *)&sin->sin_addr;
2829 break;
2830 }
2831
|
832 delay(SEC_TO_TICK(NLM_NSM_RPCBIND_TIMEOUT));
833 continue;
834 }
835 }
836
837 break;
838 }
839
840 if (stat != RPC_SUCCESS) {
841 DTRACE_PROBE2(rpcbind__error, enum clnt_stat, stat,
842 int, retries);
843 error = ENOENT;
844 goto error;
845 }
846
847 /*
848 * Create an RPC handle that'll be used for communication with local
849 * statd using the status monitor protocol.
850 */
851 error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS,
852 0, NLM_RPC_RETRIES, zone_kcred(), &nsm->ns_handle);
853 if (error != 0)
854 goto error;
855
856 /*
857 * Create an RPC handle that'll be used for communication with the
858 * local statd using the address registration protocol.
859 */
860 error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM,
861 NSM_ADDR_V1, 0, NLM_RPC_RETRIES, zone_kcred(),
862 &nsm->ns_addr_handle);
863 if (error != 0)
864 goto error;
865
866 sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL);
867 return (0);
868
869 error:
870 kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
871 if (nsm->ns_handle) {
872 ASSERT(nsm->ns_handle->cl_auth != NULL);
873 auth_destroy(nsm->ns_handle->cl_auth);
874 CLNT_DESTROY(nsm->ns_handle);
875 }
876
877 return (error);
878 }
879
880 static void
881 nlm_nsm_fini(struct nlm_nsm *nsm)
882 {
883 kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
884 if (nsm->ns_addr_handle->cl_auth != NULL)
885 auth_destroy(nsm->ns_addr_handle->cl_auth);
886 CLNT_DESTROY(nsm->ns_addr_handle);
887 nsm->ns_addr_handle = NULL;
888 if (nsm->ns_handle->cl_auth != NULL)
889 auth_destroy(nsm->ns_handle->cl_auth);
890 CLNT_DESTROY(nsm->ns_handle);
891 nsm->ns_handle = NULL;
892 sema_destroy(&nsm->ns_sem);
893 }
894
895 static enum clnt_stat
896 nlm_nsm_simu_crash(struct nlm_nsm *nsm)
897 {
898 enum clnt_stat stat;
899
900 sema_p(&nsm->ns_sem);
901 nlm_nsm_clnt_init(nsm->ns_handle, nsm);
902 stat = sm_simu_crash_1(NULL, NULL, nsm->ns_handle);
903 sema_v(&nsm->ns_sem);
904
905 return (stat);
906 }
907
908 static enum clnt_stat
909 nlm_nsm_stat(struct nlm_nsm *nsm, int32_t *out_stat)
2799
2800 rw_exit(&lm_lck);
2801 }
2802
2803 void
2804 nlm_cprresume(void)
2805 {
2806 struct nlm_globals *g;
2807
2808 rw_enter(&lm_lck, RW_READER);
2809 TAILQ_FOREACH(g, &nlm_zones_list, nlm_link)
2810 nlm_resume_zone(g);
2811
2812 rw_exit(&lm_lck);
2813 }
2814
2815 void
2816 nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
2817 {
2818 (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
2819 NLM_RPC_RETRIES, zone_kcred());
2820 }
2821
2822 void
2823 nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
2824 {
2825 /* LINTED pointer alignment */
2826 struct sockaddr *sa = (struct sockaddr *)addr->buf;
2827
2828 *family = sa->sa_family;
2829
2830 switch (sa->sa_family) {
2831 case AF_INET: {
2832 /* LINTED pointer alignment */
2833 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
2834
2835 obj->n_len = sizeof (sin->sin_addr);
2836 obj->n_bytes = (char *)&sin->sin_addr;
2837 break;
2838 }
2839
|