diff options
author | Christoph Hellwig <hch@lst.de> | 2020-05-28 08:12:11 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-28 21:11:44 +0300 |
commit | 6e43496745e75ac49d644df984d2f4ee5b5b6b4e (patch) | |
tree | ef3eeb80b015aa53a98072d925fe7900b8634a07 /drivers/nvme/target | |
parent | c433594c07457d2b2e41a87014bfad9bec279abf (diff) | |
download | linux-6e43496745e75ac49d644df984d2f4ee5b5b6b4e.tar.xz |
net: add sock_set_priority
Add a helper to directly set the SO_PRIORITY sockopt from kernel space
without going through a fake uaccess.
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/target')
-rw-r--r-- | drivers/nvme/target/tcp.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index e0801494b097..f3088156d01d 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1448,12 +1448,8 @@ static int nvmet_tcp_set_queue_sock(struct nvmet_tcp_queue *queue) */ sock_no_linger(sock->sk); - if (so_priority > 0) { - ret = kernel_setsockopt(sock, SOL_SOCKET, SO_PRIORITY, - (char *)&so_priority, sizeof(so_priority)); - if (ret) - return ret; - } + if (so_priority > 0) + sock_set_priority(sock->sk, so_priority); /* Set socket type of service */ if (inet->rcv_tos > 0) { @@ -1638,14 +1634,8 @@ static int nvmet_tcp_add_port(struct nvmet_port *nport) goto err_sock; } - if (so_priority > 0) { - ret = kernel_setsockopt(port->sock, SOL_SOCKET, SO_PRIORITY, - (char *)&so_priority, sizeof(so_priority)); - if (ret) { - pr_err("failed to set SO_PRIORITY sock opt %d\n", ret); - goto err_sock; - } - } + if (so_priority > 0) + sock_set_priority(port->sock->sk, so_priority); ret = kernel_bind(port->sock, (struct sockaddr *)&port->addr, sizeof(port->addr)); |