@@ -1393,23 +1393,20 @@ static bool _match_ctrl(struct nvme_ctrl *c, struct candidate_args *candidate)
13931393 */
13941394static ctrl_match_t _candidate_init (struct nvme_global_ctx * ctx ,
13951395 struct candidate_args * candidate ,
1396- const char * transport ,
1397- const char * traddr ,
1398- const char * trsvcid ,
1399- const char * subsysnqn ,
1400- const char * host_traddr ,
1401- const char * host_iface )
1396+ struct nvmf_context * fctx )
14021397{
14031398 memset (candidate , 0 , sizeof (* candidate ));
14041399
1405- candidate -> traddr = traddr ;
1406- candidate -> trsvcid = trsvcid ;
1407- candidate -> transport = transport ;
1408- candidate -> subsysnqn = subsysnqn ;
1409- candidate -> host_iface = streqcase0 (host_iface , "none" ) ? NULL : host_iface ;
1410- candidate -> host_traddr = streqcase0 (host_traddr , "none" ) ? NULL : host_traddr ;
1400+ candidate -> traddr = fctx -> traddr ;
1401+ candidate -> trsvcid = fctx -> trsvcid ;
1402+ candidate -> transport = fctx -> transport ;
1403+ candidate -> subsysnqn = fctx -> subsysnqn ;
1404+ candidate -> host_iface = streqcase0 (fctx -> host_iface , "none" ) ?
1405+ NULL : fctx -> host_iface ;
1406+ candidate -> host_traddr = streqcase0 (fctx -> host_traddr , "none" ) ?
1407+ NULL : fctx -> host_traddr ;
14111408
1412- if (streq0 (subsysnqn , NVME_DISC_SUBSYS_NAME )) {
1409+ if (streq0 (fctx -> subsysnqn , NVME_DISC_SUBSYS_NAME )) {
14131410 /* Since TP8013, the NQN of discovery controllers can be the
14141411 * well-known NQN (i.e. nqn.2014-08.org.nvmexpress.discovery) or
14151412 * a unique NQN. A DC created using the well-known NQN may later
@@ -1421,13 +1418,13 @@ static ctrl_match_t _candidate_init(struct nvme_global_ctx *ctx,
14211418 candidate -> well_known_nqn = true;
14221419 }
14231420
1424- if (streq0 (transport , "tcp" )) {
1421+ if (streq0 (fctx -> transport , "tcp" )) {
14251422 candidate -> iface_list = nvme_getifaddrs (ctx ); /* TCP only */
14261423 candidate -> addreq = nvme_ipaddrs_eq ;
14271424 return _tcp_match_ctrl ;
14281425 }
14291426
1430- if (streq0 (transport , "rdma" )) {
1427+ if (streq0 (fctx -> transport , "rdma" )) {
14311428 candidate -> addreq = nvme_ipaddrs_eq ;
14321429 return _match_ctrl ;
14331430 }
@@ -1445,10 +1442,7 @@ nvme_ctrl_t __nvme_lookup_ctrl(nvme_subsystem_t s, struct nvmf_context *fctx,
14451442 ctrl_match_t ctrl_match ;
14461443
14471444 /* Init candidate and get the matching function to use */
1448- ctrl_match = _candidate_init (s -> h -> ctx , & candidate ,
1449- fctx -> transport , fctx -> traddr ,
1450- fctx -> trsvcid , fctx -> subsysnqn ,
1451- fctx -> host_traddr , fctx -> host_iface );
1445+ ctrl_match = _candidate_init (s -> h -> ctx , & candidate , fctx );
14521446
14531447 c = p ? nvme_subsystem_next_ctrl (s , p ) : nvme_subsystem_first_ctrl (s );
14541448 for (; c != NULL ; c = nvme_subsystem_next_ctrl (s , c )) {
@@ -1468,11 +1462,17 @@ __public bool nvme_ctrl_match_config(struct nvme_ctrl *c, const char *transport,
14681462{
14691463 struct candidate_args candidate = {};
14701464 ctrl_match_t ctrl_match ;
1465+ struct nvmf_context fctx = {
1466+ .transport = transport ,
1467+ .traddr = traddr ,
1468+ .host_traddr = host_traddr ,
1469+ .host_iface = host_iface ,
1470+ .trsvcid = trsvcid ,
1471+ .subsysnqn = subsysnqn ,
1472+ };
14711473
14721474 /* Init candidate and get the matching function to use */
1473- ctrl_match = _candidate_init (c -> ctx , & candidate , transport , traddr ,
1474- trsvcid , subsysnqn , host_traddr ,
1475- host_iface );
1475+ ctrl_match = _candidate_init (c -> ctx , & candidate , & fctx );
14761476
14771477 return ctrl_match (c , & candidate );
14781478}
0 commit comments