diff options
author | Christoph Hellwig <hch@lst.de> | 2020-05-28 07:12:09 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-28 20:11:44 +0200 |
commit | b58f0e8f38c0a44afa59601a115bd231f23471e1 (patch) | |
tree | 591622253553216fe2635b360b4f31a62636226b /drivers/nvme | |
parent | Merge tag 'mlx5-updates-2020-05-26' of git://git.kernel.org/pub/scm/linux/ker... (diff) | |
download | linux-b58f0e8f38c0a44afa59601a115bd231f23471e1.tar.xz linux-b58f0e8f38c0a44afa59601a115bd231f23471e1.zip |
net: add sock_set_reuseaddr
Add a helper to directly set the SO_REUSEADDR sockopt from kernel space
without going through a fake uaccess.
For this the iscsi target now has to formally depend on inet to avoid
a mostly theoretical compile failure. For actual operation it already
did depend on having ipv4 or ipv6 support.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/target/tcp.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index f0da04e960f4..40757a63f455 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1632,6 +1632,7 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) port->sock->sk->sk_user_data = port; port->data_ready = port->sock->sk->sk_data_ready; port->sock->sk->sk_data_ready = nvmet_tcp_listen_data_ready; + sock_set_reuseaddr(port->sock->sk); opt = 1; ret = kernel_setsockopt(port->sock, IPPROTO_TCP, @@ -1641,13 +1642,6 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) goto err_sock; } - ret = kernel_setsockopt(port->sock, SOL_SOCKET, SO_REUSEADDR, - (char *)&opt, sizeof(opt)); - if (ret) { - pr_err("failed to set SO_REUSEADDR sock opt %d\n", ret); - goto err_sock; - } - if (so_priority > 0) { ret = kernel_setsockopt(port->sock, SOL_SOCKET, SO_PRIORITY, (char *)&so_priority, sizeof(so_priority)); |