forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/target/iscsi/iscsi_target_login.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*******************************************************************************
23 * This file contains the login functions used by the iSCSI Target driver.
34 *
....@@ -5,15 +6,6 @@
56 *
67 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
78 *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
179 ******************************************************************************/
1810
1911 #include <crypto/hash.h>
....@@ -23,6 +15,7 @@
2315 #include <linux/sched/signal.h>
2416 #include <linux/idr.h>
2517 #include <linux/tcp.h> /* TCP_NODELAY */
18
+#include <net/ip.h>
2619 #include <net/ipv6.h> /* ipv6_addr_v4mapped() */
2720 #include <scsi/iscsi_proto.h>
2821 #include <target/target_core_base.h>
....@@ -579,7 +572,7 @@
579572 }
580573
581574 /*
582
- * Check for any connection recovery entires containing CID.
575
+ * Check for any connection recovery entries containing CID.
583576 * We use the original ExpStatSN sent in the first login request
584577 * to acknowledge commands for the failed connection.
585578 *
....@@ -863,7 +856,7 @@
863856 struct sockaddr_storage *sockaddr)
864857 {
865858 struct socket *sock = NULL;
866
- int backlog = ISCSIT_TCP_BACKLOG, ret, opt = 0, len;
859
+ int backlog = ISCSIT_TCP_BACKLOG, ret, len;
867860
868861 switch (np->np_network_transport) {
869862 case ISCSI_TCP:
....@@ -883,9 +876,6 @@
883876 np->np_network_transport);
884877 return -EINVAL;
885878 }
886
-
887
- np->np_ip_proto = IPPROTO_TCP;
888
- np->np_sock_type = SOCK_STREAM;
889879
890880 ret = sock_create(sockaddr->ss_family, np->np_sock_type,
891881 np->np_ip_proto, &sock);
....@@ -908,34 +898,10 @@
908898 /*
909899 * Set SO_REUSEADDR, and disable Nagel Algorithm with TCP_NODELAY.
910900 */
911
- /* FIXME: Someone please explain why this is endian-safe */
912
- opt = 1;
913
- if (np->np_network_transport == ISCSI_TCP) {
914
- ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
915
- (char *)&opt, sizeof(opt));
916
- if (ret < 0) {
917
- pr_err("kernel_setsockopt() for TCP_NODELAY"
918
- " failed: %d\n", ret);
919
- goto fail;
920
- }
921
- }
922
-
923
- /* FIXME: Someone please explain why this is endian-safe */
924
- ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
925
- (char *)&opt, sizeof(opt));
926
- if (ret < 0) {
927
- pr_err("kernel_setsockopt() for SO_REUSEADDR"
928
- " failed\n");
929
- goto fail;
930
- }
931
-
932
- ret = kernel_setsockopt(sock, IPPROTO_IP, IP_FREEBIND,
933
- (char *)&opt, sizeof(opt));
934
- if (ret < 0) {
935
- pr_err("kernel_setsockopt() for IP_FREEBIND"
936
- " failed\n");
937
- goto fail;
938
- }
901
+ if (np->np_network_transport == ISCSI_TCP)
902
+ tcp_sock_set_nodelay(sock->sk);
903
+ sock_set_reuseaddr(sock->sk);
904
+ ip_sock_set_freebind(sock->sk);
939905
940906 ret = kernel_bind(sock, (struct sockaddr *)&np->np_sockaddr, len);
941907 if (ret < 0) {
....@@ -1160,13 +1126,13 @@
11601126
11611127 if (!zalloc_cpumask_var(&conn->conn_cpumask, GFP_KERNEL)) {
11621128 pr_err("Unable to allocate conn->conn_cpumask\n");
1163
- goto free_mask;
1129
+ goto free_conn_ops;
11641130 }
11651131
11661132 return conn;
11671133
1168
-free_mask:
1169
- free_cpumask_var(conn->conn_cpumask);
1134
+free_conn_ops:
1135
+ kfree(conn->conn_ops);
11701136 put_transport:
11711137 iscsit_put_transport(conn->conn_transport);
11721138 free_conn: