2019-02-18 09:31:03 +01:00
// SPDX-License-Identifier: GPL-2.0
2016-06-13 16:45:26 +02:00
/*
* NVMe over Fabrics common host code .
* Copyright ( c ) 2015 - 2016 HGST , a Western Digital Company .
*/
# define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
# include <linux/init.h>
# include <linux/miscdevice.h>
# include <linux/module.h>
# include <linux/mutex.h>
# include <linux/parser.h>
# include <linux/seq_file.h>
# include "nvme.h"
# include "fabrics.h"
static LIST_HEAD ( nvmf_transports ) ;
2017-08-29 10:33:44 -07:00
static DECLARE_RWSEM ( nvmf_transports_rwsem ) ;
2016-06-13 16:45:26 +02:00
static LIST_HEAD ( nvmf_hosts ) ;
static DEFINE_MUTEX ( nvmf_hosts_mutex ) ;
static struct nvmf_host * nvmf_default_host ;
static struct nvmf_host * __nvmf_host_find ( const char * hostnqn )
{
struct nvmf_host * host ;
list_for_each_entry ( host , & nvmf_hosts , list ) {
if ( ! strcmp ( host - > nqn , hostnqn ) )
return host ;
}
return NULL ;
}
static struct nvmf_host * nvmf_host_add ( const char * hostnqn )
{
struct nvmf_host * host ;
mutex_lock ( & nvmf_hosts_mutex ) ;
host = __nvmf_host_find ( hostnqn ) ;
2016-08-18 11:16:35 -07:00
if ( host ) {
kref_get ( & host - > ref ) ;
2016-06-13 16:45:26 +02:00
goto out_unlock ;
2016-08-18 11:16:35 -07:00
}
2016-06-13 16:45:26 +02:00
host = kmalloc ( sizeof ( * host ) , GFP_KERNEL ) ;
if ( ! host )
goto out_unlock ;
kref_init ( & host - > ref ) ;
2018-05-25 11:04:03 +02:00
strlcpy ( host - > nqn , hostnqn , NVMF_NQN_SIZE ) ;
2016-06-13 16:45:26 +02:00
list_add_tail ( & host - > list , & nvmf_hosts ) ;
out_unlock :
mutex_unlock ( & nvmf_hosts_mutex ) ;
return host ;
}
static struct nvmf_host * nvmf_host_default ( void )
{
struct nvmf_host * host ;
host = kmalloc ( sizeof ( * host ) , GFP_KERNEL ) ;
if ( ! host )
return NULL ;
kref_init ( & host - > ref ) ;
2018-01-05 12:44:06 -05:00
uuid_gen ( & host - > id ) ;
2016-06-13 16:45:26 +02:00
snprintf ( host - > nqn , NVMF_NQN_SIZE ,
2017-08-30 15:18:19 -07:00
" nqn.2014-08.org.nvmexpress:uuid:%pUb " , & host - > id ) ;
2016-06-13 16:45:26 +02:00
mutex_lock ( & nvmf_hosts_mutex ) ;
list_add_tail ( & host - > list , & nvmf_hosts ) ;
mutex_unlock ( & nvmf_hosts_mutex ) ;
return host ;
}
static void nvmf_host_destroy ( struct kref * ref )
{
struct nvmf_host * host = container_of ( ref , struct nvmf_host , ref ) ;
nvme-fabrics: add-remove ctrl repeat fix
Repeatedly adding then removing the same NVMe-over-Fabrics controller
over and over again (shown below) can cause a kernel crash (also shown
below). This patch fixes that.
[nvmf]# ./setup_nvme_connections.sh
traddr=192.168.1.100,transport=rdma,trsvcid=4420,nqn=darkside
-nqn,hostnqn=evil-wins-nqn,nr_io_queues=16 > /dev/nvme-fabrics
traddr=192.168.1.100,transport=rdma,trsvcid=4420,nqn=lightside
-nqn,hostnqn=good-wins-nqn > /dev/nvme-fabrics
[nvmf]# ./remove_nvme_connections.sh 2
echo 1 > /sys/class/nvme/nvme0/delete_controller
echo 1 > /sys/class/nvme/nvme1/delete_controller
[nvmf]# ./setup_nvme_connections.sh
traddr=192.168.1.100,transport=rdma,trsvcid=4420,nqn=darkside
-nqn,hostnqn=evil-wins-nqn,nr_io_queues=16 > /dev/nvme-fabrics
Killed
[nvmf]# dmesg
[ 313.416908] nvme nvme0: creating 16 I/O queues.
[ 313.523908] nvme nvme0: new ctrl: NQN "darkside-nqn", addr
192.168.1.100:4420
[ 313.524857] BUG: unable to handle kernel NULL pointer dereference at
0000000000000010
[ 313.525262] IP: [<ffffffff8136c60e>] strcmp+0xe/0x30
[ 313.525490] PGD 0
[ 313.525726] Oops: 0000 [#1] SMP
[ 313.525900] Modules linked in: nvme_rdma nvme_fabrics nvme_core
ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm mlx4_en
mlx4_ib ib_core mlx4_core
[ 313.527085] CPU: 15 PID: 5856 Comm: setup_nvme_conn Not tainted
4.7.0-rc2+ #2
[ 313.527259] Hardware name: Supermicro X9DRT-F/IBQF/IBFF/X9DRT
-F/IBQF/IBFF, BIOS 1.0a 10/09/2012
[ 313.527551] task: ffff88027646cd40 ti: ffff88025b980000 task.ti:
ffff88025b980000
[ 313.527879] RIP: 0010:[<ffffffff8136c60e>] [<ffffffff8136c60e>]
strcmp+0xe/0x30
[ 313.528232] RSP: 0018:ffff88025b983db0 EFLAGS: 00010206
[ 313.528403] RAX: 0000000000000000 RBX: ffff880471879880 RCX:
fffffffffffffff1
[ 313.528594] RDX: 0000000000000000 RSI: ffff880474afa860 RDI:
0000000000000011
[ 313.528778] RBP: ffff88025b983db0 R08: ffff880474afa860 R09:
ffff880471879058
[ 313.528956] R10: 000000000000002c R11: ffff88047f415000 R12:
ffff880471879800
[ 313.529129] R13: ffff880471879000 R14: ffff880474afa860 R15:
fffffffffffffff8
[ 313.529303] FS: 00007f778f510700(0000) GS:ffff88047fbc0000(0000)
knlGS:0000000000000000
[ 313.529629] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 313.529817] CR2: 0000000000000010 CR3: 0000000274174000 CR4:
00000000000406e0
[ 313.529989] Stack:
[ 313.530154] ffff88025b983e48 ffffffffa0171c74 0000000000000001
0000000000000059
[ 313.530621] ffff880476f32400 ffff88047e8add80 0000010074b33aa0
ffff880471879059
[ 313.531162] ffff88047187904b ffff880471879058 0000000000000000
ffff88047736e000
[ 313.531629] Call Trace:
[ 313.531797] [<ffffffffa0171c74>] nvmf_dev_write+0x674/0x840
[nvme_fabrics]
[ 313.531974] [<ffffffff81180b53>] __vfs_write+0x23/0x120
[ 313.532146] [<ffffffff8119daff>] ? __fd_install+0x1f/0xc0
[ 313.532316] [<ffffffff8119d97a>] ? __alloc_fd+0x3a/0x170
[ 313.532487] [<ffffffff811811f3>] vfs_write+0xb3/0x1b0
[ 313.532658] [<ffffffff8117e321>] ? filp_close+0x51/0x70
[ 313.532845] [<ffffffff811824e1>] SyS_write+0x41/0xa0
[ 313.533016] [<ffffffff8183055b>]
entry_SYSCALL_64_fastpath+0x13/0x8f
[ 313.533188] Code: 80 3a 00 75 f7 48 83 c6 01 0f b6 4e ff 48 83 c2 01
84 c9 88 4a ff 75 ed 5d c3 0f 1f 00 55 48 89 e5 eb 04 84 c0 74 18 48 83
c7 01 <0f> b6 47 ff 48 83 c6 01 3a 46 ff 74 eb 19 c0 83 c8 01 5d c3 31
[ 313.536563] RIP [<ffffffff8136c60e>] strcmp+0xe/0x30
[ 313.536815] RSP <ffff88025b983db0>
[ 313.536981] CR2: 0000000000000010
[ 313.537151] ---[ end trace 3d952e590e7bc2d5 ]---
Reported-and-tested-by: Jay Freyensee <james.p.freyensee@intel.com>
Signed-off-by: Ming Lin <mlin@kernel.org>
Signed-off-by: Jay Freyensee <james.p.freyensee@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
2016-07-01 12:13:32 -07:00
mutex_lock ( & nvmf_hosts_mutex ) ;
list_del ( & host - > list ) ;
mutex_unlock ( & nvmf_hosts_mutex ) ;
2016-06-13 16:45:26 +02:00
kfree ( host ) ;
}
static void nvmf_host_put ( struct nvmf_host * host )
{
if ( host )
kref_put ( & host - > ref , nvmf_host_destroy ) ;
}
/**
* nvmf_get_address ( ) - Get address / port
* @ ctrl : Host NVMe controller instance which we got the address
* @ buf : OUTPUT parameter that will contain the address / port
* @ size : buffer size
*/
int nvmf_get_address ( struct nvme_ctrl * ctrl , char * buf , int size )
{
2016-08-02 10:40:01 +03:00
int len = 0 ;
if ( ctrl - > opts - > mask & NVMF_OPT_TRADDR )
2020-03-11 09:50:37 +01:00
len + = scnprintf ( buf , size , " traddr=%s " , ctrl - > opts - > traddr ) ;
2016-08-02 10:40:01 +03:00
if ( ctrl - > opts - > mask & NVMF_OPT_TRSVCID )
2020-03-11 09:50:37 +01:00
len + = scnprintf ( buf + len , size - len , " %strsvcid=%s " ,
2016-08-02 10:40:01 +03:00
( len ) ? " , " : " " , ctrl - > opts - > trsvcid ) ;
2016-08-02 10:42:10 +03:00
if ( ctrl - > opts - > mask & NVMF_OPT_HOST_TRADDR )
2020-03-11 09:50:37 +01:00
len + = scnprintf ( buf + len , size - len , " %shost_traddr=%s " ,
2016-08-02 10:42:10 +03:00
( len ) ? " , " : " " , ctrl - > opts - > host_traddr ) ;
nvme-tcp: allow selecting the network interface for connections
In our application, we need a way to force TCP connections to go out a
specific IP interface instead of letting Linux select the interface
based on the routing tables.
Add the 'host-iface' option to allow specifying the interface to use.
When the option host-iface is specified, the driver uses the specified
interface to set the option SO_BINDTODEVICE on the TCP socket before
connecting.
This new option is needed in addtion to the existing host-traddr for
the following reasons:
Specifying an IP interface by its associated IP address is less
intuitive than specifying the actual interface name and, in some cases,
simply doesn't work. That's because the association between interfaces
and IP addresses is not predictable. IP addresses can be changed or can
change by themselves over time (e.g. DHCP). Interface names are
predictable [1] and will persist over time. Consider the following
configuration.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state ...
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 100.0.0.100/24 scope global lo
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:21:65:ec brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s3
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s8
valid_lft forever preferred_lft forever
The above is a VM that I configured with the same IP address
(100.0.0.100) on all interfaces. Doing a reverse lookup to identify the
unique interface associated with 100.0.0.100 does not work here. And
this is why the option host_iface is required. I understand that the
above config does not represent a standard host system, but I'm using
this to prove a point: "We can never know how users will configure
their systems". By te way, The above configuration is perfectly fine
by Linux.
The current TCP implementation for host_traddr performs a
bind()-before-connect(). This is a common construct to set the source
IP address on a TCP socket before connecting. This has no effect on how
Linux selects the interface for the connection. That's because Linux
uses the Weak End System model as described in RFC1122 [2]. On the other
hand, setting the Source IP Address has benefits and should be supported
by linux-nvme. In fact, setting the Source IP Address is a mandatory
FedGov requirement (e.g. connection to a RADIUS/TACACS+ server).
Consider the following configuration.
$ ip addr list dev enp0s8
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.56.101/24 brd 192.168.56.255 scope global enp0s8
valid_lft 426sec preferred_lft 426sec
inet 192.168.56.102/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.103/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.104/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
Here we can see that several addresses are associated with interface
enp0s8. By default, Linux always selects the default IP address,
192.168.56.101, as the source address when connecting over interface
enp0s8. Some users, however, want the ability to specify a different
source address (e.g., 192.168.56.102, 192.168.56.103, ...). The option
host_traddr can be used as-is to perform this function.
In conclusion, I believe that we need 2 options for TCP connections.
One that can be used to specify an interface (host-iface). And one that
can be used to set the source address (host-traddr). Users should be
allowed to use one or the other, or both, or none. Of course, the
documentation for host_traddr will need some clarification. It should
state that when used for TCP connection, this option only sets the
source address. And the documentation for host_iface should say that
this option is only available for TCP connections.
References:
[1] https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
[2] https://tools.ietf.org/html/rfc1122
Tested both IPv4 and IPv6 connections.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2021-05-20 15:09:34 -04:00
if ( ctrl - > opts - > mask & NVMF_OPT_HOST_IFACE )
len + = scnprintf ( buf + len , size - len , " %shost_iface=%s " ,
( len ) ? " , " : " " , ctrl - > opts - > host_iface ) ;
2020-03-11 09:50:37 +01:00
len + = scnprintf ( buf + len , size - len , " \n " ) ;
2016-08-02 10:40:01 +03:00
return len ;
2016-06-13 16:45:26 +02:00
}
EXPORT_SYMBOL_GPL ( nvmf_get_address ) ;
/**
* nvmf_reg_read32 ( ) - NVMe Fabrics " Property Get " API function .
* @ ctrl : Host NVMe controller instance maintaining the admin
* queue used to submit the property read command to
* the allocated NVMe controller resource on the target system .
* @ off : Starting offset value of the targeted property
* register ( see the fabrics section of the NVMe standard ) .
* @ val : OUTPUT parameter that will contain the value of
* the property after a successful read .
*
* Used by the host system to retrieve a 32 - bit capsule property value
* from an NVMe controller on the target system .
*
* ( " Capsule property " is an " PCIe register concept " applied to the
* NVMe fabrics space . )
*
* Return :
* 0 : successful read
* > 0 : NVMe error status code
* < 0 : Linux errno error code
*/
int nvmf_reg_read32 ( struct nvme_ctrl * ctrl , u32 off , u32 * val )
{
struct nvme_command cmd ;
2016-11-10 07:32:33 -08:00
union nvme_result res ;
2016-06-13 16:45:26 +02:00
int ret ;
memset ( & cmd , 0 , sizeof ( cmd ) ) ;
cmd . prop_get . opcode = nvme_fabrics_command ;
cmd . prop_get . fctype = nvme_fabrics_type_property_get ;
cmd . prop_get . offset = cpu_to_le32 ( off ) ;
2019-08-02 19:33:59 -07:00
ret = __nvme_submit_sync_cmd ( ctrl - > fabrics_q , & cmd , & res , NULL , 0 , 0 ,
2021-06-10 14:44:35 -07:00
NVME_QID_ANY , 0 , 0 ) ;
2016-06-13 16:45:26 +02:00
if ( ret > = 0 )
2016-11-10 07:32:33 -08:00
* val = le64_to_cpu ( res . u64 ) ;
2016-06-13 16:45:26 +02:00
if ( unlikely ( ret ! = 0 ) )
dev_err ( ctrl - > device ,
" Property Get error: %d, offset %#x \n " ,
ret > 0 ? ret & ~ NVME_SC_DNR : ret , off ) ;
return ret ;
}
EXPORT_SYMBOL_GPL ( nvmf_reg_read32 ) ;
/**
* nvmf_reg_read64 ( ) - NVMe Fabrics " Property Get " API function .
* @ ctrl : Host NVMe controller instance maintaining the admin
* queue used to submit the property read command to
* the allocated controller resource on the target system .
* @ off : Starting offset value of the targeted property
* register ( see the fabrics section of the NVMe standard ) .
* @ val : OUTPUT parameter that will contain the value of
* the property after a successful read .
*
* Used by the host system to retrieve a 64 - bit capsule property value
* from an NVMe controller on the target system .
*
* ( " Capsule property " is an " PCIe register concept " applied to the
* NVMe fabrics space . )
*
* Return :
* 0 : successful read
* > 0 : NVMe error status code
* < 0 : Linux errno error code
*/
int nvmf_reg_read64 ( struct nvme_ctrl * ctrl , u32 off , u64 * val )
{
2021-06-14 19:45:51 -07:00
struct nvme_command cmd = { } ;
2016-11-10 07:32:33 -08:00
union nvme_result res ;
2016-06-13 16:45:26 +02:00
int ret ;
cmd . prop_get . opcode = nvme_fabrics_command ;
cmd . prop_get . fctype = nvme_fabrics_type_property_get ;
cmd . prop_get . attrib = 1 ;
cmd . prop_get . offset = cpu_to_le32 ( off ) ;
2019-08-02 19:33:59 -07:00
ret = __nvme_submit_sync_cmd ( ctrl - > fabrics_q , & cmd , & res , NULL , 0 , 0 ,
2021-06-10 14:44:35 -07:00
NVME_QID_ANY , 0 , 0 ) ;
2016-06-13 16:45:26 +02:00
if ( ret > = 0 )
2016-11-10 07:32:33 -08:00
* val = le64_to_cpu ( res . u64 ) ;
2016-06-13 16:45:26 +02:00
if ( unlikely ( ret ! = 0 ) )
dev_err ( ctrl - > device ,
" Property Get error: %d, offset %#x \n " ,
ret > 0 ? ret & ~ NVME_SC_DNR : ret , off ) ;
return ret ;
}
EXPORT_SYMBOL_GPL ( nvmf_reg_read64 ) ;
/**
* nvmf_reg_write32 ( ) - NVMe Fabrics " Property Write " API function .
* @ ctrl : Host NVMe controller instance maintaining the admin
* queue used to submit the property read command to
* the allocated NVMe controller resource on the target system .
* @ off : Starting offset value of the targeted property
* register ( see the fabrics section of the NVMe standard ) .
* @ val : Input parameter that contains the value to be
* written to the property .
*
* Used by the NVMe host system to write a 32 - bit capsule property value
* to an NVMe controller on the target system .
*
* ( " Capsule property " is an " PCIe register concept " applied to the
* NVMe fabrics space . )
*
* Return :
* 0 : successful write
* > 0 : NVMe error status code
* < 0 : Linux errno error code
*/
int nvmf_reg_write32 ( struct nvme_ctrl * ctrl , u32 off , u32 val )
{
2021-06-14 19:45:52 -07:00
struct nvme_command cmd = { } ;
2016-06-13 16:45:26 +02:00
int ret ;
cmd . prop_set . opcode = nvme_fabrics_command ;
cmd . prop_set . fctype = nvme_fabrics_type_property_set ;
cmd . prop_set . attrib = 0 ;
cmd . prop_set . offset = cpu_to_le32 ( off ) ;
cmd . prop_set . value = cpu_to_le64 ( val ) ;
2019-08-02 19:33:59 -07:00
ret = __nvme_submit_sync_cmd ( ctrl - > fabrics_q , & cmd , NULL , NULL , 0 , 0 ,
2021-06-10 14:44:35 -07:00
NVME_QID_ANY , 0 , 0 ) ;
2016-06-13 16:45:26 +02:00
if ( unlikely ( ret ) )
dev_err ( ctrl - > device ,
" Property Set error: %d, offset %#x \n " ,
ret > 0 ? ret & ~ NVME_SC_DNR : ret , off ) ;
return ret ;
}
EXPORT_SYMBOL_GPL ( nvmf_reg_write32 ) ;
/**
2021-05-21 15:41:57 -07:00
* nvmf_log_connect_error ( ) - Error - parsing - diagnostic print out function for
* connect ( ) errors .
* @ ctrl : The specific / dev / nvmeX device that had the error .
* @ errval : Error code to be decoded in a more human - friendly
* printout .
* @ offset : For use with the NVMe error code
* NVME_SC_CONNECT_INVALID_PARAM .
* @ cmd : This is the SQE portion of a submission capsule .
* @ data : This is the " Data " portion of a submission capsule .
2016-06-13 16:45:26 +02:00
*/
static void nvmf_log_connect_error ( struct nvme_ctrl * ctrl ,
int errval , int offset , struct nvme_command * cmd ,
struct nvmf_connect_data * data )
{
2021-05-21 15:42:00 -07:00
int err_sctype = errval & ~ NVME_SC_DNR ;
2016-06-13 16:45:26 +02:00
switch ( err_sctype ) {
case ( NVME_SC_CONNECT_INVALID_PARAM ) :
if ( offset > > 16 ) {
char * inv_data = " Connect Invalid Data Parameter " ;
switch ( offset & 0xffff ) {
case ( offsetof ( struct nvmf_connect_data , cntlid ) ) :
dev_err ( ctrl - > device ,
" %s, cntlid: %d \n " ,
inv_data , data - > cntlid ) ;
break ;
case ( offsetof ( struct nvmf_connect_data , hostnqn ) ) :
dev_err ( ctrl - > device ,
" %s, hostnqn \" %s \" \n " ,
inv_data , data - > hostnqn ) ;
break ;
case ( offsetof ( struct nvmf_connect_data , subsysnqn ) ) :
dev_err ( ctrl - > device ,
" %s, subsysnqn \" %s \" \n " ,
inv_data , data - > subsysnqn ) ;
break ;
default :
dev_err ( ctrl - > device ,
" %s, starting byte offset: %d \n " ,
inv_data , offset & 0xffff ) ;
break ;
}
} else {
char * inv_sqe = " Connect Invalid SQE Parameter " ;
switch ( offset ) {
case ( offsetof ( struct nvmf_connect_command , qid ) ) :
dev_err ( ctrl - > device ,
" %s, qid %d \n " ,
inv_sqe , cmd - > connect . qid ) ;
break ;
default :
dev_err ( ctrl - > device ,
" %s, starting byte offset: %d \n " ,
inv_sqe , offset ) ;
}
}
break ;
2017-06-13 10:51:24 +08:00
case NVME_SC_CONNECT_INVALID_HOST :
dev_err ( ctrl - > device ,
" Connect for subsystem %s is not allowed, hostnqn: %s \n " ,
data - > subsysnqn , data - > hostnqn ) ;
break ;
case NVME_SC_CONNECT_CTRL_BUSY :
dev_err ( ctrl - > device ,
" Connect command failed: controller is busy or not available \n " ) ;
break ;
case NVME_SC_CONNECT_FORMAT :
dev_err ( ctrl - > device ,
" Connect incompatible format: %d " ,
cmd - > connect . recfmt ) ;
break ;
2021-06-03 10:28:03 +03:00
case NVME_SC_HOST_PATH_ERROR :
dev_err ( ctrl - > device ,
" Connect command failed: host path error \n " ) ;
break ;
2016-06-13 16:45:26 +02:00
default :
dev_err ( ctrl - > device ,
" Connect command failed, error wo/DNR bit: %d \n " ,
err_sctype ) ;
break ;
2021-05-21 15:41:59 -07:00
}
2016-06-13 16:45:26 +02:00
}
/**
* nvmf_connect_admin_queue ( ) - NVMe Fabrics Admin Queue " Connect "
* API function .
* @ ctrl : Host nvme controller instance used to request
* a new NVMe controller allocation on the target
* system and establish an NVMe Admin connection to
* that controller .
*
* This function enables an NVMe host device to request a new allocation of
* an NVMe controller resource on a target system as well establish a
* fabrics - protocol connection of the NVMe Admin queue between the
* host system device and the allocated NVMe controller on the
* target system via a NVMe Fabrics " Connect " command .
*
* Return :
* 0 : success
* > 0 : NVMe error status code
* < 0 : Linux errno error code
*
*/
int nvmf_connect_admin_queue ( struct nvme_ctrl * ctrl )
{
2021-06-14 19:45:53 -07:00
struct nvme_command cmd = { } ;
2016-11-10 07:32:33 -08:00
union nvme_result res ;
2016-06-13 16:45:26 +02:00
struct nvmf_connect_data * data ;
int ret ;
cmd . connect . opcode = nvme_fabrics_command ;
cmd . connect . fctype = nvme_fabrics_type_connect ;
cmd . connect . qid = 0 ;
2017-06-18 16:15:59 +03:00
cmd . connect . sqsize = cpu_to_le16 ( NVME_AQ_DEPTH - 1 ) ;
2016-08-17 15:00:26 -07:00
2016-06-13 16:45:28 +02:00
/*
* Set keep - alive timeout in seconds granularity ( ms * 1000 )
*/
2021-04-16 13:46:20 +02:00
cmd . connect . kato = cpu_to_le32 ( ctrl - > kato * 1000 ) ;
2016-06-13 16:45:26 +02:00
2018-11-19 14:11:15 -08:00
if ( ctrl - > opts - > disable_sqflow )
cmd . connect . cattr | = NVME_CONNECT_DISABLE_SQFLOW ;
2016-06-13 16:45:26 +02:00
data = kzalloc ( sizeof ( * data ) , GFP_KERNEL ) ;
if ( ! data )
return - ENOMEM ;
2017-05-17 09:54:27 +02:00
uuid_copy ( & data - > hostid , & ctrl - > opts - > host - > id ) ;
2016-06-13 16:45:26 +02:00
data - > cntlid = cpu_to_le16 ( 0xffff ) ;
strncpy ( data - > subsysnqn , ctrl - > opts - > subsysnqn , NVMF_NQN_SIZE ) ;
strncpy ( data - > hostnqn , ctrl - > opts - > host - > nqn , NVMF_NQN_SIZE ) ;
2019-08-02 19:33:59 -07:00
ret = __nvme_submit_sync_cmd ( ctrl - > fabrics_q , & cmd , & res ,
2016-06-13 16:45:26 +02:00
data , sizeof ( * data ) , 0 , NVME_QID_ANY , 1 ,
2021-06-10 14:44:35 -07:00
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT ) ;
2016-06-13 16:45:26 +02:00
if ( ret ) {
2016-11-10 07:32:33 -08:00
nvmf_log_connect_error ( ctrl , ret , le32_to_cpu ( res . u32 ) ,
2016-06-13 16:45:26 +02:00
& cmd , data ) ;
goto out_free_data ;
}
2016-11-10 07:32:33 -08:00
ctrl - > cntlid = le16_to_cpu ( res . u16 ) ;
2016-06-13 16:45:26 +02:00
out_free_data :
kfree ( data ) ;
return ret ;
}
EXPORT_SYMBOL_GPL ( nvmf_connect_admin_queue ) ;
/**
* nvmf_connect_io_queue ( ) - NVMe Fabrics I / O Queue " Connect "
* API function .
* @ ctrl : Host nvme controller instance used to establish an
* NVMe I / O queue connection to the already allocated NVMe
* controller on the target system .
* @ qid : NVMe I / O queue number for the new I / O connection between
* host and target ( note qid = = 0 is illegal as this is
* the Admin queue , per NVMe standard ) .
*
* This function issues a fabrics - protocol connection
* of a NVMe I / O queue ( via NVMe Fabrics " Connect " command )
* between the host system device and the allocated NVMe controller
* on the target system .
*
* Return :
* 0 : success
* > 0 : NVMe error status code
* < 0 : Linux errno error code
*/
2021-06-10 14:44:35 -07:00
int nvmf_connect_io_queue ( struct nvme_ctrl * ctrl , u16 qid )
2016-06-13 16:45:26 +02:00
{
2021-06-14 19:45:54 -07:00
struct nvme_command cmd = { } ;
2016-06-13 16:45:26 +02:00
struct nvmf_connect_data * data ;
2016-11-10 07:32:33 -08:00
union nvme_result res ;
2016-06-13 16:45:26 +02:00
int ret ;
cmd . connect . opcode = nvme_fabrics_command ;
cmd . connect . fctype = nvme_fabrics_type_connect ;
cmd . connect . qid = cpu_to_le16 ( qid ) ;
cmd . connect . sqsize = cpu_to_le16 ( ctrl - > sqsize ) ;
2018-11-19 14:11:15 -08:00
if ( ctrl - > opts - > disable_sqflow )
cmd . connect . cattr | = NVME_CONNECT_DISABLE_SQFLOW ;
2016-06-13 16:45:26 +02:00
data = kzalloc ( sizeof ( * data ) , GFP_KERNEL ) ;
if ( ! data )
return - ENOMEM ;
2017-05-17 09:54:27 +02:00
uuid_copy ( & data - > hostid , & ctrl - > opts - > host - > id ) ;
2016-06-13 16:45:26 +02:00
data - > cntlid = cpu_to_le16 ( ctrl - > cntlid ) ;
strncpy ( data - > subsysnqn , ctrl - > opts - > subsysnqn , NVMF_NQN_SIZE ) ;
strncpy ( data - > hostnqn , ctrl - > opts - > host - > nqn , NVMF_NQN_SIZE ) ;
2016-11-10 07:32:33 -08:00
ret = __nvme_submit_sync_cmd ( ctrl - > connect_q , & cmd , & res ,
2016-06-13 16:45:26 +02:00
data , sizeof ( * data ) , 0 , qid , 1 ,
2021-06-10 14:44:35 -07:00
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT ) ;
2016-06-13 16:45:26 +02:00
if ( ret ) {
2016-11-10 07:32:33 -08:00
nvmf_log_connect_error ( ctrl , ret , le32_to_cpu ( res . u32 ) ,
2016-06-13 16:45:26 +02:00
& cmd , data ) ;
}
kfree ( data ) ;
return ret ;
}
EXPORT_SYMBOL_GPL ( nvmf_connect_io_queue ) ;
2017-03-18 20:52:36 +02:00
bool nvmf_should_reconnect ( struct nvme_ctrl * ctrl )
{
2018-08-07 23:42:39 +03:00
if ( ctrl - > opts - > max_reconnects = = - 1 | |
2017-05-04 13:33:15 +03:00
ctrl - > nr_reconnects < ctrl - > opts - > max_reconnects )
2017-03-18 20:52:36 +02:00
return true ;
return false ;
}
EXPORT_SYMBOL_GPL ( nvmf_should_reconnect ) ;
2016-06-13 16:45:26 +02:00
/**
* nvmf_register_transport ( ) - NVMe Fabrics Library registration function .
* @ ops : Transport ops instance to be registered to the
* common fabrics library .
*
* API function that registers the type of specific transport fabric
* being implemented to the common NVMe fabrics library . Part of
* the overall init sequence of starting up a fabrics driver .
*/
2017-01-27 09:03:45 +01:00
int nvmf_register_transport ( struct nvmf_transport_ops * ops )
2016-06-13 16:45:26 +02:00
{
2018-02-22 07:24:08 -08:00
if ( ! ops - > create_ctrl )
2017-01-27 09:03:45 +01:00
return - EINVAL ;
2017-08-29 10:33:44 -07:00
down_write ( & nvmf_transports_rwsem ) ;
2016-06-13 16:45:26 +02:00
list_add_tail ( & ops - > entry , & nvmf_transports ) ;
2017-08-29 10:33:44 -07:00
up_write ( & nvmf_transports_rwsem ) ;
2017-01-27 09:03:45 +01:00
return 0 ;
2016-06-13 16:45:26 +02:00
}
EXPORT_SYMBOL_GPL ( nvmf_register_transport ) ;
/**
* nvmf_unregister_transport ( ) - NVMe Fabrics Library unregistration function .
* @ ops : Transport ops instance to be unregistered from the
* common fabrics library .
*
* Fabrics API function that unregisters the type of specific transport
* fabric being implemented from the common NVMe fabrics library .
* Part of the overall exit sequence of unloading the implemented driver .
*/
void nvmf_unregister_transport ( struct nvmf_transport_ops * ops )
{
2017-08-29 10:33:44 -07:00
down_write ( & nvmf_transports_rwsem ) ;
2016-06-13 16:45:26 +02:00
list_del ( & ops - > entry ) ;
2017-08-29 10:33:44 -07:00
up_write ( & nvmf_transports_rwsem ) ;
2016-06-13 16:45:26 +02:00
}
EXPORT_SYMBOL_GPL ( nvmf_unregister_transport ) ;
static struct nvmf_transport_ops * nvmf_lookup_transport (
struct nvmf_ctrl_options * opts )
{
struct nvmf_transport_ops * ops ;
2017-08-29 10:33:44 -07:00
lockdep_assert_held ( & nvmf_transports_rwsem ) ;
2016-06-13 16:45:26 +02:00
list_for_each_entry ( ops , & nvmf_transports , entry ) {
if ( strcmp ( ops - > name , opts - > transport ) = = 0 )
return ops ;
}
return NULL ;
}
static const match_table_t opt_tokens = {
{ NVMF_OPT_TRANSPORT , " transport=%s " } ,
{ NVMF_OPT_TRADDR , " traddr=%s " } ,
{ NVMF_OPT_TRSVCID , " trsvcid=%s " } ,
{ NVMF_OPT_NQN , " nqn=%s " } ,
{ NVMF_OPT_QUEUE_SIZE , " queue_size=%d " } ,
{ NVMF_OPT_NR_IO_QUEUES , " nr_io_queues=%d " } ,
{ NVMF_OPT_RECONNECT_DELAY , " reconnect_delay=%d " } ,
2017-03-18 20:52:36 +02:00
{ NVMF_OPT_CTRL_LOSS_TMO , " ctrl_loss_tmo=%d " } ,
2016-06-13 16:45:28 +02:00
{ NVMF_OPT_KATO , " keep_alive_tmo=%d " } ,
2016-06-13 16:45:26 +02:00
{ NVMF_OPT_HOSTNQN , " hostnqn=%s " } ,
2016-08-02 10:42:10 +03:00
{ NVMF_OPT_HOST_TRADDR , " host_traddr=%s " } ,
nvme-tcp: allow selecting the network interface for connections
In our application, we need a way to force TCP connections to go out a
specific IP interface instead of letting Linux select the interface
based on the routing tables.
Add the 'host-iface' option to allow specifying the interface to use.
When the option host-iface is specified, the driver uses the specified
interface to set the option SO_BINDTODEVICE on the TCP socket before
connecting.
This new option is needed in addtion to the existing host-traddr for
the following reasons:
Specifying an IP interface by its associated IP address is less
intuitive than specifying the actual interface name and, in some cases,
simply doesn't work. That's because the association between interfaces
and IP addresses is not predictable. IP addresses can be changed or can
change by themselves over time (e.g. DHCP). Interface names are
predictable [1] and will persist over time. Consider the following
configuration.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state ...
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 100.0.0.100/24 scope global lo
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:21:65:ec brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s3
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s8
valid_lft forever preferred_lft forever
The above is a VM that I configured with the same IP address
(100.0.0.100) on all interfaces. Doing a reverse lookup to identify the
unique interface associated with 100.0.0.100 does not work here. And
this is why the option host_iface is required. I understand that the
above config does not represent a standard host system, but I'm using
this to prove a point: "We can never know how users will configure
their systems". By te way, The above configuration is perfectly fine
by Linux.
The current TCP implementation for host_traddr performs a
bind()-before-connect(). This is a common construct to set the source
IP address on a TCP socket before connecting. This has no effect on how
Linux selects the interface for the connection. That's because Linux
uses the Weak End System model as described in RFC1122 [2]. On the other
hand, setting the Source IP Address has benefits and should be supported
by linux-nvme. In fact, setting the Source IP Address is a mandatory
FedGov requirement (e.g. connection to a RADIUS/TACACS+ server).
Consider the following configuration.
$ ip addr list dev enp0s8
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.56.101/24 brd 192.168.56.255 scope global enp0s8
valid_lft 426sec preferred_lft 426sec
inet 192.168.56.102/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.103/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.104/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
Here we can see that several addresses are associated with interface
enp0s8. By default, Linux always selects the default IP address,
192.168.56.101, as the source address when connecting over interface
enp0s8. Some users, however, want the ability to specify a different
source address (e.g., 192.168.56.102, 192.168.56.103, ...). The option
host_traddr can be used as-is to perform this function.
In conclusion, I believe that we need 2 options for TCP connections.
One that can be used to specify an interface (host-iface). And one that
can be used to set the source address (host-traddr). Users should be
allowed to use one or the other, or both, or none. Of course, the
documentation for host_traddr will need some clarification. It should
state that when used for TCP connection, this option only sets the
source address. And the documentation for host_iface should say that
this option is only available for TCP connections.
References:
[1] https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
[2] https://tools.ietf.org/html/rfc1122
Tested both IPv4 and IPv6 connections.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2021-05-20 15:09:34 -04:00
{ NVMF_OPT_HOST_IFACE , " host_iface=%s " } ,
2017-06-20 14:23:01 +02:00
{ NVMF_OPT_HOST_ID , " hostid=%s " } ,
2017-10-20 16:17:06 -07:00
{ NVMF_OPT_DUP_CONNECT , " duplicate_connect " } ,
2018-11-19 14:11:15 -08:00
{ NVMF_OPT_DISABLE_SQFLOW , " disable_sqflow " } ,
2018-12-03 17:52:12 -08:00
{ NVMF_OPT_HDR_DIGEST , " hdr_digest " } ,
2018-12-03 17:52:13 -08:00
{ NVMF_OPT_DATA_DIGEST , " data_digest " } ,
2018-12-11 23:38:56 -08:00
{ NVMF_OPT_NR_WRITE_QUEUES , " nr_write_queues=%d " } ,
2018-12-14 11:06:09 -08:00
{ NVMF_OPT_NR_POLL_QUEUES , " nr_poll_queues=%d " } ,
2019-08-18 12:08:51 +03:00
{ NVMF_OPT_TOS , " tos=%d " } ,
2020-11-24 18:34:59 +00:00
{ NVMF_OPT_FAIL_FAST_TMO , " fast_io_fail_tmo=%d " } ,
2016-06-13 16:45:26 +02:00
{ NVMF_OPT_ERR , NULL }
} ;
static int nvmf_parse_options ( struct nvmf_ctrl_options * opts ,
const char * buf )
{
substring_t args [ MAX_OPT_ARGS ] ;
char * options , * o , * p ;
int token , ret = 0 ;
size_t nqnlen = 0 ;
2017-03-18 20:52:36 +02:00
int ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO ;
2017-06-20 14:23:01 +02:00
uuid_t hostid ;
2016-06-13 16:45:26 +02:00
/* Set defaults */
opts - > queue_size = NVMF_DEF_QUEUE_SIZE ;
opts - > nr_io_queues = num_online_cpus ( ) ;
opts - > reconnect_delay = NVMF_DEF_RECONNECT_DELAY ;
2021-02-11 23:28:26 +05:30
opts - > kato = 0 ;
2017-10-20 16:17:06 -07:00
opts - > duplicate_connect = false ;
2020-11-24 18:34:59 +00:00
opts - > fast_io_fail_tmo = NVMF_DEF_FAIL_FAST_TMO ;
2018-12-03 17:52:12 -08:00
opts - > hdr_digest = false ;
2018-12-03 17:52:13 -08:00
opts - > data_digest = false ;
2019-08-18 12:08:51 +03:00
opts - > tos = - 1 ; /* < 0 == use transport default */
2016-06-13 16:45:26 +02:00
options = o = kstrdup ( buf , GFP_KERNEL ) ;
if ( ! options )
return - ENOMEM ;
2017-06-20 14:23:01 +02:00
uuid_gen ( & hostid ) ;
2016-06-13 16:45:26 +02:00
while ( ( p = strsep ( & o , " , \n " ) ) ! = NULL ) {
if ( ! * p )
continue ;
token = match_token ( p , opt_tokens , args ) ;
opts - > mask | = token ;
switch ( token ) {
case NVMF_OPT_TRANSPORT :
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
2018-04-14 20:06:19 +08:00
kfree ( opts - > transport ) ;
2016-06-13 16:45:26 +02:00
opts - > transport = p ;
break ;
case NVMF_OPT_NQN :
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
2018-04-14 20:06:19 +08:00
kfree ( opts - > subsysnqn ) ;
2016-06-13 16:45:26 +02:00
opts - > subsysnqn = p ;
nqnlen = strlen ( opts - > subsysnqn ) ;
if ( nqnlen > = NVMF_NQN_SIZE ) {
pr_err ( " %s needs to be < %d bytes \n " ,
2016-10-18 13:10:24 -07:00
opts - > subsysnqn , NVMF_NQN_SIZE ) ;
2016-06-13 16:45:26 +02:00
ret = - EINVAL ;
goto out ;
}
opts - > discovery_nqn =
! ( strcmp ( opts - > subsysnqn ,
NVME_DISC_SUBSYS_NAME ) ) ;
break ;
case NVMF_OPT_TRADDR :
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
2018-04-14 20:06:19 +08:00
kfree ( opts - > traddr ) ;
2016-06-13 16:45:26 +02:00
opts - > traddr = p ;
break ;
case NVMF_OPT_TRSVCID :
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
2018-04-14 20:06:19 +08:00
kfree ( opts - > trsvcid ) ;
2016-06-13 16:45:26 +02:00
opts - > trsvcid = p ;
break ;
case NVMF_OPT_QUEUE_SIZE :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < NVMF_MIN_QUEUE_SIZE | |
token > NVMF_MAX_QUEUE_SIZE ) {
pr_err ( " Invalid queue_size %d \n " , token ) ;
ret = - EINVAL ;
goto out ;
}
opts - > queue_size = token ;
break ;
case NVMF_OPT_NR_IO_QUEUES :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < = 0 ) {
pr_err ( " Invalid number of IOQs %d \n " , token ) ;
ret = - EINVAL ;
goto out ;
}
2018-03-05 11:59:53 -08:00
if ( opts - > discovery_nqn ) {
pr_debug ( " Ignoring nr_io_queues value for discovery controller \n " ) ;
break ;
}
2016-06-13 16:45:26 +02:00
opts - > nr_io_queues = min_t ( unsigned int ,
num_online_cpus ( ) , token ) ;
break ;
2016-06-13 16:45:28 +02:00
case NVMF_OPT_KATO :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < 0 ) {
pr_err ( " Invalid keep_alive_tmo %d \n " , token ) ;
ret = - EINVAL ;
goto out ;
2017-09-14 13:59:28 -03:00
} else if ( token = = 0 & & ! opts - > discovery_nqn ) {
2016-06-13 16:45:28 +02:00
/* Allowed for debug */
pr_warn ( " keep_alive_tmo 0 won't execute keep alives!!! \n " ) ;
}
opts - > kato = token ;
break ;
2017-03-18 20:52:36 +02:00
case NVMF_OPT_CTRL_LOSS_TMO :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < 0 )
pr_warn ( " ctrl_loss_tmo < 0 will reconnect forever \n " ) ;
ctrl_loss_tmo = token ;
break ;
2020-11-24 18:34:59 +00:00
case NVMF_OPT_FAIL_FAST_TMO :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token > = 0 )
pr_warn ( " I/O fail on reconnect controller after %d sec \n " ,
token ) ;
opts - > fast_io_fail_tmo = token ;
break ;
2016-06-13 16:45:26 +02:00
case NVMF_OPT_HOSTNQN :
if ( opts - > host ) {
pr_err ( " hostnqn already user-assigned: %s \n " ,
opts - > host - > nqn ) ;
ret = - EADDRINUSE ;
goto out ;
}
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
nqnlen = strlen ( p ) ;
if ( nqnlen > = NVMF_NQN_SIZE ) {
pr_err ( " %s needs to be < %d bytes \n " ,
p , NVMF_NQN_SIZE ) ;
2016-10-18 13:10:46 -07:00
kfree ( p ) ;
2016-06-13 16:45:26 +02:00
ret = - EINVAL ;
goto out ;
}
opts - > host = nvmf_host_add ( p ) ;
2016-10-18 13:10:46 -07:00
kfree ( p ) ;
2016-06-13 16:45:26 +02:00
if ( ! opts - > host ) {
ret = - ENOMEM ;
goto out ;
}
break ;
case NVMF_OPT_RECONNECT_DELAY :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < = 0 ) {
pr_err ( " Invalid reconnect_delay %d \n " , token ) ;
ret = - EINVAL ;
goto out ;
}
opts - > reconnect_delay = token ;
break ;
2016-08-02 10:42:10 +03:00
case NVMF_OPT_HOST_TRADDR :
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
2018-04-14 20:06:19 +08:00
kfree ( opts - > host_traddr ) ;
2016-08-02 10:42:10 +03:00
opts - > host_traddr = p ;
break ;
nvme-tcp: allow selecting the network interface for connections
In our application, we need a way to force TCP connections to go out a
specific IP interface instead of letting Linux select the interface
based on the routing tables.
Add the 'host-iface' option to allow specifying the interface to use.
When the option host-iface is specified, the driver uses the specified
interface to set the option SO_BINDTODEVICE on the TCP socket before
connecting.
This new option is needed in addtion to the existing host-traddr for
the following reasons:
Specifying an IP interface by its associated IP address is less
intuitive than specifying the actual interface name and, in some cases,
simply doesn't work. That's because the association between interfaces
and IP addresses is not predictable. IP addresses can be changed or can
change by themselves over time (e.g. DHCP). Interface names are
predictable [1] and will persist over time. Consider the following
configuration.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state ...
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 100.0.0.100/24 scope global lo
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:21:65:ec brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s3
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s8
valid_lft forever preferred_lft forever
The above is a VM that I configured with the same IP address
(100.0.0.100) on all interfaces. Doing a reverse lookup to identify the
unique interface associated with 100.0.0.100 does not work here. And
this is why the option host_iface is required. I understand that the
above config does not represent a standard host system, but I'm using
this to prove a point: "We can never know how users will configure
their systems". By te way, The above configuration is perfectly fine
by Linux.
The current TCP implementation for host_traddr performs a
bind()-before-connect(). This is a common construct to set the source
IP address on a TCP socket before connecting. This has no effect on how
Linux selects the interface for the connection. That's because Linux
uses the Weak End System model as described in RFC1122 [2]. On the other
hand, setting the Source IP Address has benefits and should be supported
by linux-nvme. In fact, setting the Source IP Address is a mandatory
FedGov requirement (e.g. connection to a RADIUS/TACACS+ server).
Consider the following configuration.
$ ip addr list dev enp0s8
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.56.101/24 brd 192.168.56.255 scope global enp0s8
valid_lft 426sec preferred_lft 426sec
inet 192.168.56.102/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.103/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.104/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
Here we can see that several addresses are associated with interface
enp0s8. By default, Linux always selects the default IP address,
192.168.56.101, as the source address when connecting over interface
enp0s8. Some users, however, want the ability to specify a different
source address (e.g., 192.168.56.102, 192.168.56.103, ...). The option
host_traddr can be used as-is to perform this function.
In conclusion, I believe that we need 2 options for TCP connections.
One that can be used to specify an interface (host-iface). And one that
can be used to set the source address (host-traddr). Users should be
allowed to use one or the other, or both, or none. Of course, the
documentation for host_traddr will need some clarification. It should
state that when used for TCP connection, this option only sets the
source address. And the documentation for host_iface should say that
this option is only available for TCP connections.
References:
[1] https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
[2] https://tools.ietf.org/html/rfc1122
Tested both IPv4 and IPv6 connections.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2021-05-20 15:09:34 -04:00
case NVMF_OPT_HOST_IFACE :
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
kfree ( opts - > host_iface ) ;
opts - > host_iface = p ;
break ;
2017-06-20 14:23:01 +02:00
case NVMF_OPT_HOST_ID :
p = match_strdup ( args ) ;
if ( ! p ) {
ret = - ENOMEM ;
goto out ;
}
2018-01-11 13:38:00 -08:00
ret = uuid_parse ( p , & hostid ) ;
if ( ret ) {
2017-08-03 21:40:26 +08:00
pr_err ( " Invalid hostid %s \n " , p ) ;
2017-06-20 14:23:01 +02:00
ret = - EINVAL ;
2018-01-25 09:09:25 +01:00
kfree ( p ) ;
2017-06-20 14:23:01 +02:00
goto out ;
}
2018-01-25 09:09:25 +01:00
kfree ( p ) ;
2017-06-20 14:23:01 +02:00
break ;
2017-10-20 16:17:06 -07:00
case NVMF_OPT_DUP_CONNECT :
opts - > duplicate_connect = true ;
break ;
2018-11-19 14:11:15 -08:00
case NVMF_OPT_DISABLE_SQFLOW :
opts - > disable_sqflow = true ;
break ;
2018-12-03 17:52:12 -08:00
case NVMF_OPT_HDR_DIGEST :
opts - > hdr_digest = true ;
break ;
2018-12-03 17:52:13 -08:00
case NVMF_OPT_DATA_DIGEST :
opts - > data_digest = true ;
break ;
2018-12-11 23:38:56 -08:00
case NVMF_OPT_NR_WRITE_QUEUES :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < = 0 ) {
pr_err ( " Invalid nr_write_queues %d \n " , token ) ;
ret = - EINVAL ;
goto out ;
}
opts - > nr_write_queues = token ;
break ;
2018-12-14 11:06:09 -08:00
case NVMF_OPT_NR_POLL_QUEUES :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < = 0 ) {
pr_err ( " Invalid nr_poll_queues %d \n " , token ) ;
ret = - EINVAL ;
goto out ;
}
opts - > nr_poll_queues = token ;
break ;
2019-08-18 12:08:51 +03:00
case NVMF_OPT_TOS :
if ( match_int ( args , & token ) ) {
ret = - EINVAL ;
goto out ;
}
if ( token < 0 ) {
pr_err ( " Invalid type of service %d \n " , token ) ;
ret = - EINVAL ;
goto out ;
}
if ( token > 255 ) {
pr_warn ( " Clamping type of service to 255 \n " ) ;
token = 255 ;
}
opts - > tos = token ;
break ;
2016-06-13 16:45:26 +02:00
default :
pr_warn ( " unknown parameter or missing value '%s' in ctrl creation request \n " ,
p ) ;
ret = - EINVAL ;
goto out ;
}
}
2018-05-24 16:18:15 +02:00
if ( opts - > discovery_nqn ) {
opts - > nr_io_queues = 0 ;
2019-01-07 23:54:23 -08:00
opts - > nr_write_queues = 0 ;
opts - > nr_poll_queues = 0 ;
2018-05-24 16:18:17 +02:00
opts - > duplicate_connect = true ;
2021-02-11 23:28:26 +05:30
} else {
if ( ! opts - > kato )
opts - > kato = NVME_DEFAULT_KATO ;
2018-05-24 16:18:15 +02:00
}
2020-11-24 18:34:59 +00:00
if ( ctrl_loss_tmo < 0 ) {
2017-03-18 20:52:36 +02:00
opts - > max_reconnects = - 1 ;
2020-11-24 18:34:59 +00:00
} else {
2017-03-18 20:52:36 +02:00
opts - > max_reconnects = DIV_ROUND_UP ( ctrl_loss_tmo ,
opts - > reconnect_delay ) ;
2020-11-24 18:34:59 +00:00
if ( ctrl_loss_tmo < opts - > fast_io_fail_tmo )
pr_warn ( " failfast tmo (%d) larger than controller loss tmo (%d) \n " ,
opts - > fast_io_fail_tmo , ctrl_loss_tmo ) ;
}
2017-03-18 20:52:36 +02:00
2016-06-13 16:45:26 +02:00
if ( ! opts - > host ) {
kref_get ( & nvmf_default_host - > ref ) ;
opts - > host = nvmf_default_host ;
}
2017-06-20 14:23:01 +02:00
uuid_copy ( & opts - > host - > id , & hostid ) ;
2016-06-13 16:45:26 +02:00
out :
kfree ( options ) ;
return ret ;
}
static int nvmf_check_required_opts ( struct nvmf_ctrl_options * opts ,
unsigned int required_opts )
{
if ( ( opts - > mask & required_opts ) ! = required_opts ) {
int i ;
for ( i = 0 ; i < ARRAY_SIZE ( opt_tokens ) ; i + + ) {
if ( ( opt_tokens [ i ] . token & required_opts ) & &
! ( opt_tokens [ i ] . token & opts - > mask ) ) {
pr_warn ( " missing parameter '%s' \n " ,
opt_tokens [ i ] . pattern ) ;
}
}
return - EINVAL ;
}
return 0 ;
}
2018-10-18 17:40:40 -07:00
bool nvmf_ip_options_match ( struct nvme_ctrl * ctrl ,
struct nvmf_ctrl_options * opts )
{
if ( ! nvmf_ctlr_matches_baseopts ( ctrl , opts ) | |
strcmp ( opts - > traddr , ctrl - > opts - > traddr ) | |
strcmp ( opts - > trsvcid , ctrl - > opts - > trsvcid ) )
return false ;
/*
* Checking the local address is rough . In most cases , none is specified
* and the host port is selected by the stack .
*
* Assume no match if :
* - local address is specified and address is not the same
* - local address is not specified but remote is , or vice versa
* ( admin using specific host_traddr when it matters ) .
*/
if ( ( opts - > mask & NVMF_OPT_HOST_TRADDR ) & &
( ctrl - > opts - > mask & NVMF_OPT_HOST_TRADDR ) ) {
if ( strcmp ( opts - > host_traddr , ctrl - > opts - > host_traddr ) )
return false ;
} else if ( ( opts - > mask & NVMF_OPT_HOST_TRADDR ) | |
( ctrl - > opts - > mask & NVMF_OPT_HOST_TRADDR ) ) {
return false ;
}
return true ;
}
EXPORT_SYMBOL_GPL ( nvmf_ip_options_match ) ;
2016-06-13 16:45:26 +02:00
static int nvmf_check_allowed_opts ( struct nvmf_ctrl_options * opts ,
unsigned int allowed_opts )
{
if ( opts - > mask & ~ allowed_opts ) {
int i ;
for ( i = 0 ; i < ARRAY_SIZE ( opt_tokens ) ; i + + ) {
2017-08-17 13:57:49 +02:00
if ( ( opt_tokens [ i ] . token & opts - > mask ) & &
( opt_tokens [ i ] . token & ~ allowed_opts ) ) {
2016-06-13 16:45:26 +02:00
pr_warn ( " invalid parameter '%s' \n " ,
opt_tokens [ i ] . pattern ) ;
}
}
return - EINVAL ;
}
return 0 ;
}
void nvmf_free_options ( struct nvmf_ctrl_options * opts )
{
nvmf_host_put ( opts - > host ) ;
kfree ( opts - > transport ) ;
kfree ( opts - > traddr ) ;
kfree ( opts - > trsvcid ) ;
kfree ( opts - > subsysnqn ) ;
2016-08-02 10:42:10 +03:00
kfree ( opts - > host_traddr ) ;
nvme-tcp: allow selecting the network interface for connections
In our application, we need a way to force TCP connections to go out a
specific IP interface instead of letting Linux select the interface
based on the routing tables.
Add the 'host-iface' option to allow specifying the interface to use.
When the option host-iface is specified, the driver uses the specified
interface to set the option SO_BINDTODEVICE on the TCP socket before
connecting.
This new option is needed in addtion to the existing host-traddr for
the following reasons:
Specifying an IP interface by its associated IP address is less
intuitive than specifying the actual interface name and, in some cases,
simply doesn't work. That's because the association between interfaces
and IP addresses is not predictable. IP addresses can be changed or can
change by themselves over time (e.g. DHCP). Interface names are
predictable [1] and will persist over time. Consider the following
configuration.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state ...
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 100.0.0.100/24 scope global lo
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:21:65:ec brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s3
valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 100.0.0.100/24 scope global enp0s8
valid_lft forever preferred_lft forever
The above is a VM that I configured with the same IP address
(100.0.0.100) on all interfaces. Doing a reverse lookup to identify the
unique interface associated with 100.0.0.100 does not work here. And
this is why the option host_iface is required. I understand that the
above config does not represent a standard host system, but I'm using
this to prove a point: "We can never know how users will configure
their systems". By te way, The above configuration is perfectly fine
by Linux.
The current TCP implementation for host_traddr performs a
bind()-before-connect(). This is a common construct to set the source
IP address on a TCP socket before connecting. This has no effect on how
Linux selects the interface for the connection. That's because Linux
uses the Weak End System model as described in RFC1122 [2]. On the other
hand, setting the Source IP Address has benefits and should be supported
by linux-nvme. In fact, setting the Source IP Address is a mandatory
FedGov requirement (e.g. connection to a RADIUS/TACACS+ server).
Consider the following configuration.
$ ip addr list dev enp0s8
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc ...
link/ether 08:00:27:4f:95:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.56.101/24 brd 192.168.56.255 scope global enp0s8
valid_lft 426sec preferred_lft 426sec
inet 192.168.56.102/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.103/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
inet 192.168.56.104/24 scope global secondary enp0s8
valid_lft forever preferred_lft forever
Here we can see that several addresses are associated with interface
enp0s8. By default, Linux always selects the default IP address,
192.168.56.101, as the source address when connecting over interface
enp0s8. Some users, however, want the ability to specify a different
source address (e.g., 192.168.56.102, 192.168.56.103, ...). The option
host_traddr can be used as-is to perform this function.
In conclusion, I believe that we need 2 options for TCP connections.
One that can be used to specify an interface (host-iface). And one that
can be used to set the source address (host-traddr). Users should be
allowed to use one or the other, or both, or none. Of course, the
documentation for host_traddr will need some clarification. It should
state that when used for TCP connection, this option only sets the
source address. And the documentation for host_iface should say that
this option is only available for TCP connections.
References:
[1] https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
[2] https://tools.ietf.org/html/rfc1122
Tested both IPv4 and IPv6 connections.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2021-05-20 15:09:34 -04:00
kfree ( opts - > host_iface ) ;
2016-06-13 16:45:26 +02:00
kfree ( opts ) ;
}
EXPORT_SYMBOL_GPL ( nvmf_free_options ) ;
# define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN)
# define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \
2017-06-20 14:23:01 +02:00
NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \
2018-11-19 14:11:15 -08:00
NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT | \
2020-11-24 18:34:59 +00:00
NVMF_OPT_DISABLE_SQFLOW | \
NVMF_OPT_FAIL_FAST_TMO )
2016-06-13 16:45:26 +02:00
static struct nvme_ctrl *
2019-05-11 22:42:55 +09:00
nvmf_create_ctrl ( struct device * dev , const char * buf )
2016-06-13 16:45:26 +02:00
{
struct nvmf_ctrl_options * opts ;
struct nvmf_transport_ops * ops ;
struct nvme_ctrl * ctrl ;
int ret ;
opts = kzalloc ( sizeof ( * opts ) , GFP_KERNEL ) ;
if ( ! opts )
return ERR_PTR ( - ENOMEM ) ;
ret = nvmf_parse_options ( opts , buf ) ;
if ( ret )
goto out_free_opts ;
2017-09-24 16:15:55 +03:00
request_module ( " nvme-%s " , opts - > transport ) ;
2016-06-13 16:45:26 +02:00
/*
* Check the generic options first as we need a valid transport for
* the lookup below . Then clear the generic flags so that transport
* drivers don ' t have to care about them .
*/
ret = nvmf_check_required_opts ( opts , NVMF_REQUIRED_OPTS ) ;
if ( ret )
goto out_free_opts ;
opts - > mask & = ~ NVMF_REQUIRED_OPTS ;
2017-08-29 10:33:44 -07:00
down_read ( & nvmf_transports_rwsem ) ;
2016-06-13 16:45:26 +02:00
ops = nvmf_lookup_transport ( opts ) ;
if ( ! ops ) {
pr_info ( " no handler found for transport %s. \n " ,
opts - > transport ) ;
ret = - EINVAL ;
goto out_unlock ;
}
2017-12-25 14:18:30 +02:00
if ( ! try_module_get ( ops - > module ) ) {
ret = - EBUSY ;
goto out_unlock ;
}
2018-06-01 09:11:20 +02:00
up_read ( & nvmf_transports_rwsem ) ;
2017-12-25 14:18:30 +02:00
2016-06-13 16:45:26 +02:00
ret = nvmf_check_required_opts ( opts , ops - > required_opts ) ;
if ( ret )
2017-12-25 14:18:30 +02:00
goto out_module_put ;
2016-06-13 16:45:26 +02:00
ret = nvmf_check_allowed_opts ( opts , NVMF_ALLOWED_OPTS |
ops - > allowed_opts | ops - > required_opts ) ;
if ( ret )
2017-12-25 14:18:30 +02:00
goto out_module_put ;
2016-06-13 16:45:26 +02:00
ctrl = ops - > create_ctrl ( dev , opts ) ;
if ( IS_ERR ( ctrl ) ) {
ret = PTR_ERR ( ctrl ) ;
2017-12-25 14:18:30 +02:00
goto out_module_put ;
2016-06-13 16:45:26 +02:00
}
2017-12-25 14:18:30 +02:00
module_put ( ops - > module ) ;
2016-06-13 16:45:26 +02:00
return ctrl ;
2017-12-25 14:18:30 +02:00
out_module_put :
module_put ( ops - > module ) ;
2018-06-01 09:11:20 +02:00
goto out_free_opts ;
2016-06-13 16:45:26 +02:00
out_unlock :
2017-08-29 10:33:44 -07:00
up_read ( & nvmf_transports_rwsem ) ;
2016-06-13 16:45:26 +02:00
out_free_opts :
2016-10-18 13:11:03 -07:00
nvmf_free_options ( opts ) ;
2016-06-13 16:45:26 +02:00
return ERR_PTR ( ret ) ;
}
static struct class * nvmf_class ;
static struct device * nvmf_device ;
static DEFINE_MUTEX ( nvmf_dev_mutex ) ;
static ssize_t nvmf_dev_write ( struct file * file , const char __user * ubuf ,
size_t count , loff_t * pos )
{
struct seq_file * seq_file = file - > private_data ;
struct nvme_ctrl * ctrl ;
const char * buf ;
int ret = 0 ;
if ( count > PAGE_SIZE )
return - ENOMEM ;
buf = memdup_user_nul ( ubuf , count ) ;
if ( IS_ERR ( buf ) )
return PTR_ERR ( buf ) ;
mutex_lock ( & nvmf_dev_mutex ) ;
if ( seq_file - > private ) {
ret = - EINVAL ;
goto out_unlock ;
}
2019-05-11 22:42:55 +09:00
ctrl = nvmf_create_ctrl ( nvmf_device , buf ) ;
2016-06-13 16:45:26 +02:00
if ( IS_ERR ( ctrl ) ) {
ret = PTR_ERR ( ctrl ) ;
goto out_unlock ;
}
seq_file - > private = ctrl ;
out_unlock :
mutex_unlock ( & nvmf_dev_mutex ) ;
kfree ( buf ) ;
return ret ? ret : count ;
}
static int nvmf_dev_show ( struct seq_file * seq_file , void * private )
{
struct nvme_ctrl * ctrl ;
int ret = 0 ;
mutex_lock ( & nvmf_dev_mutex ) ;
ctrl = seq_file - > private ;
if ( ! ctrl ) {
ret = - EINVAL ;
goto out_unlock ;
}
seq_printf ( seq_file , " instance=%d,cntlid=%d \n " ,
ctrl - > instance , ctrl - > cntlid ) ;
out_unlock :
mutex_unlock ( & nvmf_dev_mutex ) ;
return ret ;
}
static int nvmf_dev_open ( struct inode * inode , struct file * file )
{
/*
* The miscdevice code initializes file - > private_data , but doesn ' t
* make use of it later .
*/
file - > private_data = NULL ;
return single_open ( file , nvmf_dev_show , NULL ) ;
}
static int nvmf_dev_release ( struct inode * inode , struct file * file )
{
struct seq_file * seq_file = file - > private_data ;
struct nvme_ctrl * ctrl = seq_file - > private ;
if ( ctrl )
nvme_put_ctrl ( ctrl ) ;
return single_release ( inode , file ) ;
}
static const struct file_operations nvmf_dev_fops = {
. owner = THIS_MODULE ,
. write = nvmf_dev_write ,
. read = seq_read ,
. open = nvmf_dev_open ,
. release = nvmf_dev_release ,
} ;
static struct miscdevice nvmf_misc = {
. minor = MISC_DYNAMIC_MINOR ,
. name = " nvme-fabrics " ,
. fops = & nvmf_dev_fops ,
} ;
static int __init nvmf_init ( void )
{
int ret ;
nvmf_default_host = nvmf_host_default ( ) ;
if ( ! nvmf_default_host )
return - ENOMEM ;
nvmf_class = class_create ( THIS_MODULE , " nvme-fabrics " ) ;
if ( IS_ERR ( nvmf_class ) ) {
pr_err ( " couldn't register class nvme-fabrics \n " ) ;
ret = PTR_ERR ( nvmf_class ) ;
goto out_free_host ;
}
nvmf_device =
device_create ( nvmf_class , NULL , MKDEV ( 0 , 0 ) , NULL , " ctl " ) ;
if ( IS_ERR ( nvmf_device ) ) {
pr_err ( " couldn't create nvme-fabris device! \n " ) ;
ret = PTR_ERR ( nvmf_device ) ;
goto out_destroy_class ;
}
ret = misc_register ( & nvmf_misc ) ;
if ( ret ) {
pr_err ( " couldn't register misc device: %d \n " , ret ) ;
goto out_destroy_device ;
}
return 0 ;
out_destroy_device :
device_destroy ( nvmf_class , MKDEV ( 0 , 0 ) ) ;
out_destroy_class :
class_destroy ( nvmf_class ) ;
out_free_host :
nvmf_host_put ( nvmf_default_host ) ;
return ret ;
}
static void __exit nvmf_exit ( void )
{
misc_deregister ( & nvmf_misc ) ;
device_destroy ( nvmf_class , MKDEV ( 0 , 0 ) ) ;
class_destroy ( nvmf_class ) ;
nvmf_host_put ( nvmf_default_host ) ;
2019-04-12 00:18:31 +09:00
BUILD_BUG_ON ( sizeof ( struct nvmf_common_command ) ! = 64 ) ;
2016-06-13 16:45:26 +02:00
BUILD_BUG_ON ( sizeof ( struct nvmf_connect_command ) ! = 64 ) ;
BUILD_BUG_ON ( sizeof ( struct nvmf_property_get_command ) ! = 64 ) ;
BUILD_BUG_ON ( sizeof ( struct nvmf_property_set_command ) ! = 64 ) ;
BUILD_BUG_ON ( sizeof ( struct nvmf_connect_data ) ! = 1024 ) ;
}
MODULE_LICENSE ( " GPL v2 " ) ;
module_init ( nvmf_init ) ;
module_exit ( nvmf_exit ) ;