From 6a0d6dd10e3ddcc5eafef07df4330a613b539c5f Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 11 Mar 2015 10:38:40 +0100 Subject: [PATCH] LU-6356 tgt: handle sec context requests properly When dealing with security context initialization requests, no export is associated with the request yet, because these requests are sent before *_CONNECT requests. So the normal *_common_slice handlers will not be called, given there is no reference to the target. So add a special case for handling of SEC_CTX_INIT, SEC_CTX_INIT_CONT and SEC_CTX_FINI requests in tgt_handle_request0() and tgt_request_handle(), in order to directly send the reply. Also remove tgt_sec_ctx_handlers because they become useless. Signed-off-by: Sebastien Buisson Change-Id: Ic0947082c7acc188ebbf2e9cb9ff57e999b5ed3e Reviewed-on: http://review.whamcloud.com/14041 Tested-by: Jenkins Reviewed-by: Andrew Perepechko Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- lustre/include/lu_target.h | 1 - lustre/mgs/mgs_handler.c | 5 ----- lustre/target/tgt_handler.c | 46 +++++++++++++++++++++++++++------------------ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index 4b5b7d7..78800cf 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -351,7 +351,6 @@ void tgt_register_lfsck_query(int (*query)(const struct lu_env *, struct dt_device *, struct lfsck_request *)); -extern struct tgt_handler tgt_sec_ctx_handlers[]; extern struct tgt_handler tgt_lfsck_handlers[]; extern struct tgt_handler tgt_obd_handlers[]; extern struct tgt_handler tgt_dlm_handlers[]; diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index ea95a04..a77c1cf 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -1072,11 +1072,6 @@ static struct tgt_opc_slice mgs_common_slice[] = { .tos_hs = mgs_llog_handlers }, { - .tos_opc_start = SEC_FIRST_OPC, - .tos_opc_end = SEC_LAST_OPC, - .tos_hs = tgt_sec_ctx_handlers - }, - { .tos_hs = NULL } }; diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 41770e9..5be36e2 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -374,9 +374,24 @@ static int tgt_handle_request0(struct tgt_session_info *tsi, { int serious = 0; int rc; + __u32 opc = lustre_msg_get_opc(req->rq_reqmsg); ENTRY; + + /* When dealing with sec context requests, no export is associated yet, + * because these requests are sent before *_CONNECT requests. + * A NULL req->rq_export means the normal *_common_slice handlers will + * not be called, because there is no reference to the target. + * So deal with them by hand and jump directly to target_send_reply(). + */ + switch (opc) { + case SEC_CTX_INIT: + case SEC_CTX_INIT_CONT: + case SEC_CTX_FINI: + GOTO(out, rc = 0); + } + /* * Checking for various OBD_FAIL_$PREF_$OPC_NET codes. _Do_ not try * to put same checks into handlers like mdt_close(), mdt_reint(), @@ -444,6 +459,7 @@ static int tgt_handle_request0(struct tgt_session_info *tsi, if (likely(rc == 0 && req->rq_export)) target_committed_to_req(req); +out: target_send_reply(req, rc, tsi->tsi_reply_fail_id); RETURN(0); } @@ -621,6 +637,14 @@ int tgt_request_handle(struct ptlrpc_request *req) } if (unlikely(!class_connected_export(req->rq_export))) { + if (opc == SEC_CTX_INIT || opc == SEC_CTX_INIT_CONT || + opc == SEC_CTX_FINI) { + /* sec context initialization has to be handled + * by hand in tgt_handle_request0() */ + tsi->tsi_reply_fail_id = OBD_FAIL_SEC_CTX_INIT_NET; + h = NULL; + GOTO(handle_recov, rc = 0); + } CDEBUG(D_HA, "operation %d on unconnected OST from %s\n", opc, libcfs_id2str(req->rq_peer)); req->rq_status = -ENOTCONN; @@ -653,6 +677,9 @@ int tgt_request_handle(struct ptlrpc_request *req) GOTO(out, rc); } + LASSERTF(h->th_opc == opc, "opcode mismatch %d != %d\n", + h->th_opc, opc); + if (CFS_FAIL_CHECK_ORSET(request_fail_id, CFS_FAIL_ONCE)) GOTO(out, rc = 0); @@ -666,10 +693,9 @@ int tgt_request_handle(struct ptlrpc_request *req) GOTO(out, rc); } +handle_recov: rc = tgt_handle_recovery(req, tsi->tsi_reply_fail_id); if (likely(rc == 1)) { - LASSERTF(h->th_opc == opc, "opcode mismatch %d != %d\n", - h->th_opc, opc); rc = tgt_handle_request0(tsi, h, req); if (rc) GOTO(out, rc); @@ -1382,22 +1408,6 @@ TGT_LLOG_HDL_VAR(0, LLOG_ORIGIN_HANDLE_CLOSE, tgt_llog_close), }; EXPORT_SYMBOL(tgt_llog_handlers); -/* - * sec context handlers - */ -/* XXX: Implement based on mdt_sec_ctx_handle()? */ -static int tgt_sec_ctx_handle(struct tgt_session_info *tsi) -{ - return 0; -} - -struct tgt_handler tgt_sec_ctx_handlers[] = { -TGT_SEC_HDL_VAR(0, SEC_CTX_INIT, tgt_sec_ctx_handle), -TGT_SEC_HDL_VAR(0, SEC_CTX_INIT_CONT, tgt_sec_ctx_handle), -TGT_SEC_HDL_VAR(0, SEC_CTX_FINI, tgt_sec_ctx_handle), -}; -EXPORT_SYMBOL(tgt_sec_ctx_handlers); - int (*tgt_lfsck_in_notify)(const struct lu_env *env, struct dt_device *key, struct lfsck_request *lr, -- 1.8.3.1