*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*/
#define DEBUG_SUBSYSTEM S_SEC
int sptlrpc_rule_set_choose(struct sptlrpc_rule_set *rset,
enum lustre_sec_part from,
enum lustre_sec_part to,
- lnet_nid_t nid,
+ struct lnet_nid *nid,
struct sptlrpc_flavor *sf)
{
struct sptlrpc_rule *r;
int n;
+ if (nid_is_lo0(nid))
+ /* do not enforce any sec flavor on loopback connection */
+ return 0;
+
for (n = 0; n < rset->srs_nrule; n++) {
r = &rset->srs_rules[n];
- if (LNET_NIDNET(nid) != LNET_NET_ANY &&
+ if (!LNET_NID_IS_ANY(nid) &&
r->sr_netid != LNET_NET_ANY &&
- LNET_NIDNET(nid) != r->sr_netid)
+ __be16_to_cpu(nid->nid_num) != r->sr_netid)
continue;
if (from != LUSTRE_SP_ANY && r->sr_from != LUSTRE_SP_ANY &&
* is a actual filesystem.
*/
if (server_name2fsname(target, fsname, NULL))
- strlcpy(fsname, target, sizeof(target));
+ strlcpy(fsname, target, sizeof(fsname));
rc = sptlrpc_parse_rule(param, &rule);
if (rc)
}
void sptlrpc_conf_choose_flavor(enum lustre_sec_part from,
- enum lustre_sec_part to,
- struct obd_uuid *target,
- lnet_nid_t nid,
- struct sptlrpc_flavor *sf)
+ enum lustre_sec_part to,
+ struct obd_uuid *target,
+ struct lnet_nid *nid,
+ struct sptlrpc_flavor *sf)
{
- struct sptlrpc_conf *conf;
- struct sptlrpc_conf_tgt *conf_tgt;
- char name[MTI_NAME_MAXLEN];
- int len, rc = 0;
+ struct sptlrpc_conf *conf;
+ struct sptlrpc_conf_tgt *conf_tgt;
+ char name[MTI_NAME_MAXLEN];
+ int len, rc = 0;
obd_uuid2fsname(name, target->uuid, sizeof(name));
mutex_lock(&sptlrpc_conf_lock);
- conf = sptlrpc_conf_get(name, 0);
- if (conf == NULL)
- goto out;
-
- /* convert uuid name (supposed end with _UUID) to target name */
- len = strlen(target->uuid);
- LASSERT(len > 5);
- memcpy(name, target->uuid, len - 5);
- name[len - 5] = '\0';
-
- conf_tgt = sptlrpc_conf_get_tgt(conf, name, 0);
- if (conf_tgt) {
- rc = sptlrpc_rule_set_choose(&conf_tgt->sct_rset,
- from, to, nid, sf);
- if (rc)
- goto out;
- }
+ conf = sptlrpc_conf_get(name, 0);
+ if (conf == NULL)
+ goto out;
+
+ /* convert uuid name (supposed end with _UUID) to target name */
+ len = strlen(target->uuid);
+ LASSERT(len > 5);
+ memcpy(name, target->uuid, len - 5);
+ name[len - 5] = '\0';
+
+ conf_tgt = sptlrpc_conf_get_tgt(conf, name, 0);
+ if (conf_tgt) {
+ rc = sptlrpc_rule_set_choose(&conf_tgt->sct_rset,
+ from, to, nid, sf);
+ if (rc)
+ goto out;
+ }
- rc = sptlrpc_rule_set_choose(&conf->sc_rset, from, to, nid, sf);
+ rc = sptlrpc_rule_set_choose(&conf->sc_rset, from, to,
+ nid, sf);
out:
mutex_unlock(&sptlrpc_conf_lock);
- if (rc == 0)
- get_default_flavor(sf);
+ if (rc == 0)
+ get_default_flavor(sf);
- flavor_set_flags(sf, from, to, 1);
+ flavor_set_flags(sf, from, to, 1);
}
/**
* certain peer (from, nid).
*/
void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
- enum lustre_sec_part from,
- lnet_nid_t nid,
- struct sptlrpc_flavor *sf)
+ enum lustre_sec_part from,
+ struct lnet_nid *nid,
+ struct sptlrpc_flavor *sf)
{
- if (sptlrpc_rule_set_choose(rset, from, LUSTRE_SP_ANY, nid, sf) == 0)
- get_default_flavor(sf);
+ if (sptlrpc_rule_set_choose(rset, from, LUSTRE_SP_ANY, nid, sf) == 0)
+ get_default_flavor(sf);
}
#define SEC_ADAPT_DELAY (10)