From 50c79ee142be4bad9e63d603dda0a8d80ac40444 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 3 Aug 2015 10:36:16 -0400 Subject: [PATCH] LU-6490 gss: handle struct key_type match replacement Starting with the 3.17 kernel the function match used by struct key_type was replaced by a new function match_preparse. This patch added support for this change. Signed-off-by: James Simmons Change-Id: I2db0860cf089b0ba8f70bad9155f48e52ec8c4b5 Reviewed-on: http://review.whamcloud.com/15804 Tested-by: Jenkins Reviewed-by: Bob Glossman Tested-by: Maloo Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 21 +++++++++++++++++++ lustre/ptlrpc/gss/gss_keyring.c | 46 +++++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index b7dca3b..2ce6386 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1720,6 +1720,24 @@ file_function_iter, [ ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER # +# LC_KEY_MATCH_DATA +# +# 3.17 replaces key_type::match with match_preparse +# and has new struct key_match_data +# +AC_DEFUN([LC_KEY_MATCH_DATA], [ +LB_CHECK_COMPILE([if struct key_match field exist], +key_match, [ + #include +],[ + struct key_match_data data; +],[ + AC_DEFINE(HAVE_KEY_MATCH_DATA, 1, + [struct key_match_data exist]) +]) +]) # LC_KEY_MATCH_DATA + +# # LC_NFS_FILLDIR_USE_CTX # # 3.18 kernel moved from void cookie to struct dir_context @@ -1939,6 +1957,9 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_HAVE_IOV_ITER_INIT_DIRECTION LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER + # 3.17 + LC_KEY_MATCH_DATA + # 3.18 LC_NFS_FILLDIR_USE_CTX diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c index 5256adc..e722d3c 100644 --- a/lustre/ptlrpc/gss/gss_keyring.c +++ b/lustre/ptlrpc/gss/gss_keyring.c @@ -73,7 +73,7 @@ static int sec_install_rctx_kr(struct ptlrpc_sec *sec, /* * the timeout is only for the case that upcall child process die abnormally. * in any other cases it should finally update kernel key. - * + * * FIXME we'd better to incorporate the client & server side upcall timeouts * into the framework of Adaptive Timeouts, but we need to figure out how to * make sure that kernel knows the upcall processes is in-progress or died @@ -1408,11 +1408,31 @@ out: RETURN(0); } -static -int gss_kt_match(const struct key *key, const void *desc) +#ifndef HAVE_KEY_MATCH_DATA +static int +gss_kt_match(const struct key *key, const void *desc) +{ + return (strcmp(key->description, (const char *) desc) == 0); +} +#else /* ! HAVE_KEY_MATCH_DATA */ +static bool +gss_kt_match(const struct key *key, const struct key_match_data *match_data) +{ + const char *desc = match_data->raw_data; + + return (strcmp(key->description, desc) == 0); +} + +/* + * Preparse the match criterion. + */ +static int gss_kt_match_preparse(struct key_match_data *match_data) { - return (strcmp(key->description, (const char *) desc) == 0); + match_data->lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT; + match_data->cmp = gss_kt_match; + return 0; } +#endif /* HAVE_KEY_MATCH_DATA */ static void gss_kt_destroy(struct key *key) @@ -1434,13 +1454,17 @@ void gss_kt_describe(const struct key *key, struct seq_file *s) static struct key_type gss_key_type = { - .name = "lgssc", - .def_datalen = 0, - .instantiate = gss_kt_instantiate, - .update = gss_kt_update, - .match = gss_kt_match, - .destroy = gss_kt_destroy, - .describe = gss_kt_describe, + .name = "lgssc", + .def_datalen = 0, + .instantiate = gss_kt_instantiate, + .update = gss_kt_update, +#ifdef HAVE_KEY_MATCH_DATA + .match_preparse = gss_kt_match_preparse, +#else + .match = gss_kt_match, +#endif + .destroy = gss_kt_destroy, + .describe = gss_kt_describe, }; /**************************************** -- 1.8.3.1