From 71cbaa10a8eef8816c07c336577137eec373a831 Mon Sep 17 00:00:00 2001 From: lsy Date: Tue, 20 Sep 2005 12:37:20 +0000 Subject: [PATCH] add debug msg, and some cleanup. capa_renew should use tcapa instead of capa. --- lustre/include/linux/lustre_sec.h | 13 ++++++------- lustre/obdfilter/filter_capa.c | 27 ++++++++++++--------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/lustre/include/linux/lustre_sec.h b/lustre/include/linux/lustre_sec.h index f937450..d7592a6 100644 --- a/lustre/include/linux/lustre_sec.h +++ b/lustre/include/linux/lustre_sec.h @@ -531,8 +531,7 @@ struct lustre_capa_data { } __attribute__((packed)); struct client_capa { - struct inode *inode; /* this should be always valid - * if c_refc > 0 */ + struct inode *inode; struct lustre_handle handle; /* handle of mds_file_data */ struct list_head lli_list; /* link to lli_capas */ #if 0 /* TODO: support multi mount point */ @@ -576,11 +575,11 @@ enum lustre_capa_type { #define DEBUG_CAPA(level, capa, fmt, args...) \ do { \ -CDEBUG(level, fmt " capa@%p uid %u op %u ino "LPU64" mdsid %d keyid %d " \ - "expiry "LPU64" flags %u\n", \ - ##args, capa, (capa)->lc_uid, (capa)->lc_op, (capa)->lc_ino, \ - (capa)->lc_mdsid, (capa)->lc_keyid, (capa)->lc_expiry, \ - (capa)->lc_flags); \ +CDEBUG(level, fmt " capa@%p uid %u ruid %u op %u ino "LPU64" igen %u mdsid %d "\ + "keyid %d expiry "LPU64" flags %u, hmac %.*s\n", \ + ##args, capa, (capa)->lc_uid, (capa)->lc_ruid, (capa)->lc_op, \ + (capa)->lc_ino, (capa)->lc_igen, (capa)->lc_mdsid, (capa)->lc_keyid, \ + (capa)->lc_expiry, (capa)->lc_flags, CAPA_DIGEST_SIZE, (capa)->lc_hmac);\ } while (0) #define DEBUG_CAPA_KEY(level, key, fmt, args...) \ diff --git a/lustre/obdfilter/filter_capa.c b/lustre/obdfilter/filter_capa.c index 339c153..7d94c73 100644 --- a/lustre/obdfilter/filter_capa.c +++ b/lustre/obdfilter/filter_capa.c @@ -215,8 +215,7 @@ filter_verify_capa(int cmd, struct obd_export *exp, struct lustre_capa *capa) struct filter_obd *filter = &obd->u.filter; struct obd_capa *ocapa; struct lustre_capa tcapa; - struct filter_capa_key *rkey = NULL, *bkey = NULL, *tmp; - __u8 hmac_key[CAPA_KEY_LEN]; + struct filter_capa_key *rkey = NULL, *bkey = NULL, *tmp, capa_keys[2]; int rc = 0; /* capability is disabled */ @@ -311,30 +310,28 @@ new_capa: } LASSERT(rkey); - - memcpy(&tcapa, capa, sizeof(tcapa)); - tcapa.lc_keyid = rkey->k_key.lk_keyid; - memcpy(hmac_key, rkey->k_key.lk_key, sizeof(hmac_key)); + capa_keys[0] = *rkey; + if (bkey) + capa_keys[1] = *bkey; spin_unlock(&filter->fo_capa_lock); - capa_hmac(filter->fo_capa_hmac, hmac_key, &tcapa); + tcapa = *capa; + tcapa.lc_keyid = capa_keys[0].k_key.lk_keyid; + capa_hmac(filter->fo_capa_hmac, capa_keys[0].k_key.lk_key, &tcapa); /* store in capa cache */ - ocapa = capa_renew(capa, FILTER_CAPA); + ocapa = capa_renew(&tcapa, FILTER_CAPA); if (!ocapa) GOTO(out, rc = -ENOMEM); if (bkey) { - spin_lock(&filter->fo_capa_lock); - tcapa.lc_keyid = bkey->k_key.lk_keyid; - memcpy(hmac_key, bkey->k_key.lk_key, sizeof(hmac_key)); - ocapa->c_bkeyid = bkey->k_key.lk_keyid; - spin_unlock(&filter->fo_capa_lock); - - capa_hmac(filter->fo_capa_hmac, bkey->k_key.lk_key, &tcapa); + tcapa.lc_keyid = capa_keys[1].k_key.lk_keyid; + capa_hmac(filter->fo_capa_hmac, capa_keys[1].k_key.lk_key, + &tcapa); spin_lock(&filter->fo_capa_lock); memcpy(ocapa->c_bhmac, tcapa.lc_hmac, sizeof(ocapa->c_bhmac)); + ocapa->c_bkeyid = capa_keys[1].k_key.lk_keyid; ocapa->c_bvalid = 1; spin_unlock(&filter->fo_capa_lock); } -- 1.8.3.1