-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add new NVMe syntax to add and manage NQN, hosts and ports. #173
base: master
Are you sure you want to change the base?
Conversation
Change nvmet_scan_ports() to handle ports not linked to any NQN. Fix a potential mem leak in ip_validate().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting review. Not finished yet.
@@ -112,7 +135,7 @@ int exec_cmdline_arg(int argcin, char *argvin[]) | |||
|
|||
sprintf(header, "%s %s\n%s\n\n", PROCESS, VERSION_NUM, COPYRIGHT); | |||
|
|||
while ((i = getopt(argcin, argvin, "?:a:b:c:d:ef:gH:hi:jL:lm:NnP:p:qRr:s:t:U:u:VvXx")) != INVALID_VALUE) { | |||
while ((i = getopt(argcin, argvin, "?:a:b:c:d:ef:gH:hi:jL:lm:NnP:p:qRr:s:t:U:u:VvXxYyzZoOTM")) != INVALID_VALUE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is much easier to follow if these are placed in alphabetical order (capital first, then lower case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is much easier to follow if these are placed in alphabetical order (capital first, then lower case).
Ok! Please consider all the new swicth's names as completely temptative.
@@ -217,6 +242,30 @@ int exec_cmdline_arg(int argcin, char *argvin[]) | |||
case 'x': | |||
action = ACTION_UNEXPORT_NVMET; | |||
break; | |||
case 'y': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. It is much easier to follow if in alphabetical order (capital first, then lower case).
OK. I do apologize for taking as long as I did to review this but overall, I like it. Here are my thoughts: Coding style For example:
Should be:
Command Options Redundancy Client Host NQNs -- I did have a question though: what are your thoughts on breaking this out of the main EDIT
I agree!
I disagree. I used to have this and the logic to maintain it got overly complicated which is why I switched to getopt in version 7.0.
But what if more than one IP/interface is tied to that hostname?
Sure, I agree.
I do not know if the NVMe Target infrastructure on Linux support that, yet.
I agree. |
Understood. I had/have a problem with my IDE, which suddenly started changing these code style details in files without asking or warning. So I ended up with dozens of small changes in the files, related to indent/brace positions. I reverted the changes and the IDE reverted my reverts... eventually I gave up. From now on I will try to respect these rules.
Ok.
Consider that I left all the "old" code in place, to be sure the old switches kept running. So, if I can remember well, as of today there is a lot of double/rendunant code, which must be be cleaned up.
Sorry, I did not understand very well. Do you want the
These two points can merge: we can end up with a daemon-centric approach, which would carry out all the operations, while the two very small/lean command line utilities would simply forward requests to it via UNIX socket or REST (hence also remote management would in fact already be implemented). The daemon could have its own configuration file, so that it is possible to choose for example the interfaces/IPs on which it should listen, and more. Curses... Well, nomen omen ...
Ok!
While writing the
Well I would say that it is the user's responsibility to make sure the resolved IP is correct. If a hostname resolves to more than one IP address, the first one is used, which can still be shown immediately to the user and displayed later with the
Ok.
It seems it is supported: I tried with an Ubuntu 22.04 6.1.0-060100-generic with an exported NQN on an on-link IPv6 address connected to an Ubuntu 20.04 5.15.0-69-generic, and worked.
Ok. |
Change nvmet_scan_ports() to handle ports not linked to any NQN. Fix a potential mem leak in ip_validate().
This commit adds some new command line switches to
rapiddisk
to add/remove/link/unlink NVMe PORTs, NVMe allowed HOSTS and NVMe NQN.The goal is to be able to add a PORT, HOST or NQN without the need to bind them one to each other upon creation.
Examples:
-y
/-Y
switches create/remove a NQN. The creation/removal just requires a ramdisk name. The new NQN is configured with an empty list of allowed hosts but is marked as accessible from any host. The new NQN is not usable/reachable since it is not linked to any PORT. If the NQN is linked to a PORT or to a HOST, it is not possible to directly remove it. It must be unlinked from that PORT/HOST first.es.
$ sudo ./rapiddisk -y -b rd0
-i
/-X
switches create/remove a PORT and work the same way as before, with some differences. Now it is possible to specify an ip address instead of an network interface name. If a PORT is linked to a NQN, it cannot be removed. Ifloop
is specfified after the-t
switch, the interface name/ip address following the-i
switch is simply ignored, but a string of any sort must be present, such as NULL. NOTE: the ip address is not checked against existing network interfaces, so PORTs can exist which refers to unassigned IP addresses. These PORTs cannot be linked to a NQN until their IP address is assigned to an interface.es.
$ sudo ./rapiddisk -i 192.168.20.40 -P 2 -t tcp
-o
/-O
switches link/unlink an existing NQN to an existing PORT.es.
$ sudo ./rapiddisk -o -b rd0 -P 2
-z
/-Z
switches add/remove a new HOST to the global allowed host list. You can't remove an HOST globally if it is linked to a NQN.es.
$ sudo ./rapiddisk -z -H myhost
-T
/-M
switches link/unlink an existing HOST to an existing NQN. When a HOST is linked to an NQN with no other HOSTs already linked to it, the NQN will change its policy from "accept connection from all" to "accept connection from linked allowed HOSTs only". The other way around, when the last HOST linked to a NQN is unlinked from it, the NQN is put back into "accept connection from all" mode.es.
$ sudo ./rapiddisk -T -b rd0 -H myhost
As a general rule, when something is linked to something else, it cannot be removed from the subsystem. This means that to remove a NQN, it must be not linked to PORTs or HOSTs; to remove a PORT, it must not be linked to any NQN; to remove a HOST, it must not be linked to any NQN.
TODO:
rapiddisk -action_name -param_name_01 param_value_01 -param_name_02 param_value_02
So to add a new ramdisk of 10 MB, the command should change from
rapiddisk -a 10
to (example)
rapiddisk -a -s 10
and so on. This is good from bash command args autocompletion
--add
EXAMPLE: