Skip to content

Commit 99dd46f

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 <marting@netapp.com> [wagi: reformated the function to improve readability] Signed-off-by: Daniel Wagner <wagi@kernel.org>
1 parent f1818da commit 99dd46f

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
@@ -1129,6 +1129,34 @@ __public int nvmf_connect_ctrl(nvme_ctrl_t c)
11291129
return 0;
11301130
}
11311131

1132+
static void nvmf_update_tls_concat(struct nvmf_disc_log_entry *e,
1133+
nvme_ctrl_t c, nvme_host_t h)
1134+
{
1135+
if (e->trtype != NVMF_TRTYPE_TCP ||
1136+
e->tsas.tcp.sectype == NVMF_TCP_SECTYPE_NONE)
1137+
return;
1138+
1139+
if (e->treq & NVMF_TREQ_REQUIRED) {
1140+
nvme_msg(h->ctx, LOG_DEBUG,
1141+
"setting --tls due to treq %s and sectype %s\n",
1142+
nvmf_treq_str(e->treq),
1143+
nvmf_sectype_str(e->tsas.tcp.sectype));
1144+
1145+
c->cfg.tls = true;
1146+
return;
1147+
}
1148+
1149+
if (e->treq & NVMF_TREQ_NOT_REQUIRED) {
1150+
nvme_msg(h->ctx, LOG_DEBUG,
1151+
"setting --concat due to treq %s and sectype %s\n",
1152+
nvmf_treq_str(e->treq),
1153+
nvmf_sectype_str(e->tsas.tcp.sectype));
1154+
1155+
c->cfg.concat = true;
1156+
return;
1157+
}
1158+
}
1159+
11321160
static int nvmf_connect_disc_entry(nvme_host_t h,
11331161
struct nvmf_disc_log_entry *e,
11341162
struct nvmf_context *fctx,
@@ -1222,18 +1250,8 @@ static int nvmf_connect_disc_entry(nvme_host_t h,
12221250
nvmf_check_option(h->ctx, disable_sqflow))
12231251
c->cfg.disable_sqflow = true;
12241252

1225-
if (e->trtype == NVMF_TRTYPE_TCP &&
1226-
e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE) {
1227-
if (e->treq & NVMF_TREQ_REQUIRED) {
1228-
nvme_msg(h->ctx, LOG_DEBUG, "setting --tls due to treq %s and sectype %s\n",
1229-
nvmf_treq_str(e->treq), nvmf_sectype_str(e->tsas.tcp.sectype));
1230-
c->cfg.tls = true;
1231-
} else if (e->treq & NVMF_TREQ_NOT_REQUIRED) {
1232-
nvme_msg(h->ctx, LOG_DEBUG, "setting --concat due to treq %s and sectype %s\n",
1233-
nvmf_treq_str(e->treq), nvmf_sectype_str(e->tsas.tcp.sectype));
1234-
c->cfg.concat = true;
1235-
}
1236-
}
1253+
/* update tls or concat */
1254+
nvmf_update_tls_concat(e, c, h);
12371255

12381256
ret = nvmf_add_ctrl(h, c, cfg);
12391257
if (!ret) {
@@ -2585,11 +2603,8 @@ static int nbft_connect(struct nvme_global_ctx *ctx,
25852603
if (ss && ss->unavailable && saved_log_level < 1)
25862604
nvme_set_logging_level(ctx, -1, false, false);
25872605

2588-
if (e) {
2589-
if (e->trtype == NVMF_TRTYPE_TCP &&
2590-
e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE)
2591-
cfg->tls = true;
2592-
}
2606+
/* Update tls or concat */
2607+
nvmf_update_tls_concat(e, c, h);
25932608

25942609
ret = nvmf_add_ctrl(h, c, cfg);
25952610

0 commit comments

Comments
 (0)