Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow connect to use configured TLS keys #2532

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@

#define NVMF_ARGS(n, c, ...) \
struct argconfig_commandline_options n[] = { \
__VA_ARGS__, \
OPT_STRING("transport", 't', "STR", &transport, nvmf_tport), \
OPT_STRING("nqn", 'n', "STR", &subsysnqn, nvmf_nqn), \
OPT_STRING("traddr", 'a', "STR", &traddr, nvmf_traddr), \
Expand All @@ -120,7 +121,6 @@
OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest), \
OPT_FLAG("tls", 0, &c.tls, nvmf_tls), \
OPT_FLAG("concat", 0, &c.concat, nvmf_concat), \
__VA_ARGS__, \
OPT_END() \
}

Expand Down Expand Up @@ -904,15 +904,18 @@
nvme_print_flags_t flags;
struct nvme_fabrics_config cfg = { 0 };
char *format = "normal";

char *keyring = NULL;
char *tls_key = NULL;

NVMF_ARGS(opts, cfg,
OPT_STRING("dhchap-ctrl-secret", 'C', "STR", &ctrlkey, nvmf_ctrlkey),
OPT_STRING("config", 'J', "FILE", &config_file, nvmf_config_file),
OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"),
OPT_FLAG("dump-config", 'O', &dump_config, "Dump JSON configuration to stdout"),
OPT_FMT("output-format", 'o', &format, "Output format: normal|json"),
OPT_STRING("context", 0, "STR", &context, nvmf_context));
OPT_FLAG("dump-config", 'O', &dump_config, "Dump JSON configuration to stdout"),

Check failure on line 914 in fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 115 exceeds 100 columns
OPT_FMT("output-format", 'o', &format, "Output format: normal|json"),

Check failure on line 915 in fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 108 exceeds 100 columns
OPT_STRING("context", 0, "STR", &context, nvmf_context),
OPT_STR("keyring", 0, &keyring, "Keyring to store the TLS key, name or keyring id"),

Check failure on line 917 in fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 130 exceeds 100 columns
OPT_STR("tls_key", 0, &tls_key, "TLS key in PSK Interchagne format or key store id"));

Check failure on line 918 in fabrics.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 132 exceeds 100 columns

nvmf_default_config(&cfg);

Expand Down Expand Up @@ -1008,9 +1011,30 @@
errno = ENOMEM;
goto out_free;
}

if (ctrlkey)
nvme_ctrl_set_dhchap_key(c, ctrlkey);

if (keyring) {
char *endptr;
long id = strtol(keyring, &endptr, 0);

if (endptr != keyring)
cfg.keyring = id;
else
nvme_ctrl_set_keyring(c, keyring);
}

if (tls_key) {
char *endptr;
long id = strtol(tls_key, &endptr, 0);

if (endptr != tls_key)
cfg.tls_key = id;
else
nvme_ctrl_set_tls_key(c, tls_key);
}

errno = 0;
ret = nvmf_add_ctrl(h, c, &cfg);
if (ret)
Expand Down
12 changes: 6 additions & 6 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -9181,8 +9181,8 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
char *hostnqn;
char *subsysnqn;
char *secret;
unsigned int hmac;
unsigned int identity;
unsigned char hmac;
unsigned char identity;
bool insert;
};

Expand All @@ -9203,8 +9203,8 @@ static int gen_tls_key(int argc, char **argv, struct command *command, struct pl
OPT_STR("hostnqn", 'n', &cfg.hostnqn, hostnqn),
OPT_STR("subsysnqn", 'c', &cfg.subsysnqn, subsysnqn),
OPT_STR("secret", 's', &cfg.secret, secret),
OPT_UINT("hmac", 'm', &cfg.hmac, hmac),
OPT_UINT("identity", 'I', &cfg.identity, identity),
OPT_BYTE("hmac", 'm', &cfg.hmac, hmac),
OPT_BYTE("identity", 'I', &cfg.identity, identity),
OPT_FLAG("insert", 'i', &cfg.insert, insert));

err = parse_args(argc, argv, desc, opts);
Expand Down Expand Up @@ -9302,7 +9302,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
char *hostnqn;
char *subsysnqn;
char *keydata;
unsigned int identity;
unsigned char identity;
bool insert;
};

Expand All @@ -9322,7 +9322,7 @@ static int check_tls_key(int argc, char **argv, struct command *command, struct
OPT_STR("hostnqn", 'n', &cfg.hostnqn, hostnqn),
OPT_STR("subsysnqn", 'c', &cfg.subsysnqn, subsysnqn),
OPT_STR("keydata", 'd', &cfg.keydata, keydata),
OPT_UINT("identity", 'I', &cfg.identity, identity),
OPT_BYTE("identity", 'I', &cfg.identity, identity),
OPT_FLAG("insert", 'i', &cfg.insert, insert));

err = parse_args(argc, argv, desc, opts);
Expand Down
Loading