Skip to content

Commit 4963779

Browse files
committed
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] (cherry picked from 99dd46f) Signed-off-by: Daniel Wagner <[email protected]>
1 parent faf7326 commit 4963779

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

nbft.c

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,34 @@ static bool validate_uri(struct nbft_info_discovery *dd,
103103
return true;
104104
}
105105

106+
static void update_tls_concat(struct nvmf_disc_log_entry *e,
107+
struct nvme_fabrics_config *cfg)
108+
{
109+
if (e->trtype != NVMF_TRTYPE_TCP ||
110+
e->tsas.tcp.sectype == NVMF_TCP_SECTYPE_NONE)
111+
return;
112+
113+
if (e->treq & NVMF_TREQ_REQUIRED) {
114+
fprintf(stderr,
115+
"setting --tls due to treq %s and sectype %s\n",
116+
nvmf_treq_str(e->treq),
117+
nvmf_sectype_str(e->tsas.tcp.sectype));
118+
119+
cfg->tls = true;
120+
return;
121+
}
122+
123+
if (e->treq & NVMF_TREQ_NOT_REQUIRED) {
124+
fprintf(stderr,
125+
"setting --concat due to treq %s and sectype %s\n",
126+
nvmf_treq_str(e->treq),
127+
nvmf_sectype_str(e->tsas.tcp.sectype));
128+
129+
cfg->concat = true;
130+
return;
131+
}
132+
}
133+
106134
/* returns 0 for success or negative errno otherwise */
107135
static int do_connect(nvme_root_t r,
108136
nvme_host_t h,
@@ -138,11 +166,8 @@ static int do_connect(nvme_root_t r,
138166
nvme_init_logging(r, -1, false, false);
139167
}
140168

141-
if (e) {
142-
if (e->trtype == NVMF_TRTYPE_TCP &&
143-
e->tsas.tcp.sectype != NVMF_TCP_SECTYPE_NONE)
144-
cfg->tls = true;
145-
}
169+
/* Update tls or concat */
170+
update_tls_concat(e, cfg);
146171

147172
errno = 0;
148173
ret = nvmf_add_ctrl(h, c, cfg);

0 commit comments

Comments
 (0)