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>
This commit is contained in:

committed by
David S. Miller

parent
1eba1110f0
commit
b58f0e8f38
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
config ISCSI_TARGET
|
||||
tristate "Linux-iSCSI.org iSCSI Target Mode Stack"
|
||||
depends on NET
|
||||
depends on INET
|
||||
select CRYPTO
|
||||
select CRYPTO_CRC32C
|
||||
select CRYPTO_CRC32C_INTEL if X86
|
||||
|
@@ -909,14 +909,7 @@ int iscsit_setup_np(
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME: Someone please explain why this is endian-safe */
|
||||
ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *)&opt, sizeof(opt));
|
||||
if (ret < 0) {
|
||||
pr_err("kernel_setsockopt() for SO_REUSEADDR"
|
||||
" failed\n");
|
||||
goto fail;
|
||||
}
|
||||
sock_set_reuseaddr(sock->sk);
|
||||
|
||||
ret = kernel_setsockopt(sock, IPPROTO_IP, IP_FREEBIND,
|
||||
(char *)&opt, sizeof(opt));
|
||||
|
Reference in New Issue
Block a user