Skip to content

Commit 6a8e030

Browse files
martin-gpyigaw
authored andcommitted
fabrics: add helper to update tls and concat
Only --tls was properly updated in nbft_connect(), and not --concat. But this is properly done in nvmf_connect_disc_entry() already. So add a helper function to update both --tls and --concat and invoke the same from nvmf_connect_disc_entry() and nbft_connect() respectively. Signed-off-by: Martin George <[email protected]> [wagi: reformated the function to improve readability] Signed-off-by: Daniel Wagner <[email protected]>
1 parent 9c61b78 commit 6a8e030

1 file changed

Lines changed: 32 additions & 17 deletions

File tree

libnvme/src/nvme/fabrics.c

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,34 @@ __public int nvmf_connect_ctrl(nvme_ctrl_t c)
10961096
return 0;
10971097
}
10981098

1099+
static void nvmf_update_tls_concat(struct nvmf_disc_log_entry *e,
1100+
nvme_ctrl_t c, nvme_host_t h)
1101+
{
1102+
if (e->trtype != NVMF_TRTYPE_TCP ||
1103+
e->tsas.tcp.sectype == NVMF_TCP_SECTYPE_NONE)
1104+
return;
1105+
1106+
if (e->treq & NVMF_TREQ_REQUIRED) {
1107+
nvme_msg(h->ctx, LOG_DEBUG,
1108+
"setting --tls due to treq %s and sectype %s\n",
1109+
nvmf_treq_str(e->treq),
1110+
nvmf_sectype_str(e->tsas.tcp.sectype));
1111+
1112+
c->cfg.tls = true;
1113+
return;
1114+
}
1115+
1116+
if (e->treq & NVMF_TREQ_NOT_REQUIRED) {
1117+
nvme_msg(h->ctx, LOG_DEBUG,
1118+
"setting --concat due to treq %s and sectype %s\n",
1119+
nvmf_treq_str(e->treq),
1120+
nvmf_sectype_str(e->tsas.tcp.sectype));
1121+
1122+
c->cfg.concat = true;
1123+
return;
1124+
}
1125+
}
1126+
10991127
static int nvmf_connect_disc_entry(nvme_host_t h,
11001128
struct nvmf_disc_log_entry *e,
11011129
struct nvmf_context *fctx,
@@ -1189,18 +1217,8 @@ static int nvmf_connect_disc_entry(nvme_host_t h,
11891217
nvmf_check_option(h->ctx, disable_sqflow))
11901218
c->cfg.disable_sqflow = true;
11911219

1192-
if (e->trtype == NVMF_TRTYPE_TCP &&
1193-
e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE) {
1194-
if (e->treq & NVMF_TREQ_REQUIRED) {
1195-
nvme_msg(h->ctx, LOG_DEBUG, "setting --tls due to treq %s and sectype %s\n",
1196-
nvmf_treq_str(e->treq), nvmf_sectype_str(e->tsas.tcp.sectype));
1197-
c->cfg.tls = true;
1198-
} else if (e->treq & NVMF_TREQ_NOT_REQUIRED) {
1199-
nvme_msg(h->ctx, LOG_DEBUG, "setting --concat due to treq %s and sectype %s\n",
1200-
nvmf_treq_str(e->treq), nvmf_sectype_str(e->tsas.tcp.sectype));
1201-
c->cfg.concat = true;
1202-
}
1203-
}
1220+
/* update tls or concat */
1221+
nvmf_update_tls_concat(e, c, h);
12041222

12051223
ret = nvmf_add_ctrl(h, c, cfg);
12061224
if (!ret) {
@@ -2552,11 +2570,8 @@ static int nbft_connect(struct nvme_global_ctx *ctx,
25522570
if (ss && ss->unavailable && saved_log_level < 1)
25532571
nvme_set_logging_level(ctx, -1, false, false);
25542572

2555-
if (e) {
2556-
if (e->trtype == NVMF_TRTYPE_TCP &&
2557-
e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE)
2558-
cfg->tls = true;
2559-
}
2573+
/* Update tls or concat */
2574+
nvmf_update_tls_concat(e, c, h);
25602575

25612576
ret = nvmf_add_ctrl(h, c, cfg);
25622577

0 commit comments

Comments
 (0)