summaryrefslogtreecommitdiffstats
path: root/meta-networking
diff options
context:
space:
mode:
authorJagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>2016-09-26 01:31:34 +0530
committerJoe MacDonald <joe_macdonald@mentor.com>2016-10-20 11:16:55 -0400
commit93b0d657931c9ea7a6fc0df8ca9925a0fa7a80cc (patch)
tree6a9a3d499c46609625f48a2db583f4a4a2d0374f /meta-networking
parent9e8d127a800d1dbada68ba4cf5ba5cfd72be1675 (diff)
downloadmeta-openembedded-93b0d657931c9ea7a6fc0df8ca9925a0fa7a80cc.tar.gz
iscsitarget: resolve build error with linux kernel 4.8
The below changes in kernel source, triggered iscsitarget build fail with linux kernel v4.8. 1. An extra 'flags' argument has been passed to vfs_readv/vfs_writev syscalls in v4.8. So, set this argument to "0" for now (as there is no real need for that). Ref: https://github.com/torvalds/linux/commit/793b80ef14af56d20c998265287648ad34239b6f Solves: -- snip -- TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c: In function 'write_data': TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c:350:9: error: too few arguments to function 'vfs_writev' res = vfs_writev(file, (struct iovec __user *) iop, count, &off); ^~~~~~~~~~ -- snip -- 2. Redefine dropped PAGE_CACHE_* and page_cache_{get,release} definitions, as they have been dropped with v4.8 Ref: https://github.com/torvalds/linux/commit/1fa64f198b9f8d6ec0f7aec7c18dc94684391140 Solves: -- snip -- TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/param.c: In function 'sess_param_check': TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/param.c:48:41: error: 'PAGE_CACHE_SIZE' undeclared (first use in this function) (u32) ((ISCSI_CONN_IOV_MAX - 1) * PAGE_CACHE_SIZE)); ^ -- snip -- 3. Replace crypto_hash interfaces with crypto_ahash interfaces, Ref: https://github.com/torvalds/linux/commit/896545098777564212b9e91af4c973f094649aa7 Ref: https://www.redhat.com/archives/dm-devel/2016-January/msg00244.html Solves: -- snip -- TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c: In function 'digest_init': TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c:42:23: error: implicit declaration of function 'crypto_alloc_hash' [-Werror=implicit-function-declaration] conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0, ^~~~~~~~~~~~~~~~~ TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c: In function 'digest_cleanup': TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c:77:3: error: implicit declaration of function 'crypto_free_hash' [-Werror=implicit-function-declaration] crypto_free_hash(conn->tx_hash.tfm); ^~~~~~~~~~~~~~~~ -- snip -- 4. The earlier "rw" parameter has been set in "bi_rw" within bio structure, hence remove "rw" argument. Ref: https://github.com/torvalds/linux/commit/4e49ea4a3d276365bf7396c9b77b4d1d5923835a Solves: -- snip -- TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/block-io.c:140:14: warning: passing argument 1 of 'submit_bio' makes pointer from integer without a cast [-Wint-conversion] submit_bio(rw, bio); ^~ -- snip -- 5. The 'len' argument from sk_data_ready() callback has been removed in linux kernel v4.3 and above. Ref: https://github.com/torvalds/linux/commit/676d23690fb62b5d51ba5d659935e9f7d9da9f8e Solves: -- snip -- TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c: In function 'iet_socket_bind': TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c:143:38: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types] target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready; ^ TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c:144:32: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types] conn->sock->sk->sk_data_ready = iet_data_ready; ^ -- snip -- 6. A. The "size" argument has been dropped from sock_recvmsg syscall in v4.8, as all callers have it equal to msg_data_left(msg). B. 'struct user_msghdr' is being used for userland-side msghdr instead of 'struct msghdr', which is used for kernel-side msghdr in linux v3.19 and above, so typecase it while calling sock_recvmsg syscall. Ref: https://github.com/torvalds/linux/commit/2da62906b1e298695e1bb725927041cd59942c98 https://github.com/torvalds/linux/commit/666547ff591cebdedc4679bf6b1b3f3383a8dea3 Solves: -- snip -- TOPDIR/tmp-glibc/work-shared/qemux86/kernel-source/include/linux/net.h:222:5: note: expected 'struct msghdr *' but argument is of type 'struct user_msghdr *' int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags); ^~~~~~~~~~~~ TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c:129:8: error: too many arguments to function 'sock_recvmsg' res = sock_recvmsg(conn->sock, &msg, len, MSG_DONTWAIT | MSG_NOSIGNAL); ^~~~~~~~~~~~ -- snip -- Detailed error log is at: http://errors.yoctoproject.org/Errors/Details/83334/ Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
Diffstat (limited to 'meta-networking')
-rw-r--r--meta-networking/recipes-extended/iscsitarget/files/build_with_updated_interfaces_of_linux_v4.8_and_above.patch525
-rw-r--r--meta-networking/recipes-extended/iscsitarget/iscsitarget_1.4.20.3+svn502.bb6
2 files changed, 527 insertions, 4 deletions
diff --git a/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_interfaces_of_linux_v4.8_and_above.patch b/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_interfaces_of_linux_v4.8_and_above.patch
new file mode 100644
index 000000000..e55c407a4
--- /dev/null
+++ b/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_interfaces_of_linux_v4.8_and_above.patch
@@ -0,0 +1,525 @@
1Resolve build error with linux kernel 4.8
2
3The below changes in kernel source, triggered iscsitarget
4build fail with linux kernel v4.8.
5
61. An extra 'flags' argument has been passed to vfs_readv/vfs_writev
7 syscalls in v4.8. So, set this argument to "0" for now
8 (as there is no real need for that).
9 Ref: https://github.com/torvalds/linux/commit/793b80ef14af56d20c998265287648ad34239b6f
10 Solves:
11 -- snip --
12TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c: In function 'write_data':
13TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c:350:9: error: too few arguments to function 'vfs_writev'
14 res = vfs_writev(file, (struct iovec __user *) iop, count, &off);
15 ^~~~~~~~~~
16 -- snip --
17
182. Redefine dropped PAGE_CACHE_* and page_cache_{get,release} definitions,
19 as they have been dropped with v4.8
20 Ref: https://github.com/torvalds/linux/commit/1fa64f198b9f8d6ec0f7aec7c18dc94684391140
21 Solves:
22 -- snip --
23TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/param.c: In function 'sess_param_check':
24TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/param.c:48:41: error: 'PAGE_CACHE_SIZE' undeclared (first use in this function)
25 (u32) ((ISCSI_CONN_IOV_MAX - 1) * PAGE_CACHE_SIZE));
26 ^
27 -- snip --
28
293. Replace crypto_hash interfaces with crypto_ahash interfaces,
30 Ref: https://github.com/torvalds/linux/commit/896545098777564212b9e91af4c973f094649aa7
31 Ref: https://www.redhat.com/archives/dm-devel/2016-January/msg00244.html
32 Solves:
33 -- snip --
34TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c: In function 'digest_init':
35TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c:42:23: error: implicit declaration of function 'crypto_alloc_hash' [-Werror=implicit-function-declaration]
36 conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
37 ^~~~~~~~~~~~~~~~~
38TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c: In function 'digest_cleanup':
39TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c:77:3: error: implicit declaration of function 'crypto_free_hash' [-Werror=implicit-function-declaration]
40 crypto_free_hash(conn->tx_hash.tfm);
41 ^~~~~~~~~~~~~~~~
42 -- snip --
43
444. The earlier "rw" parameter has been set in "bi_rw" within
45 bio structure, hence remove "rw" argument.
46 Ref: https://github.com/torvalds/linux/commit/4e49ea4a3d276365bf7396c9b77b4d1d5923835a
47 Solves:
48-- snip --
49TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/block-io.c:140:14: warning: passing argument 1 of 'submit_bio' makes pointer from integer without a cast [-Wint-conversion]
50 submit_bio(rw, bio);
51 ^~
52-- snip --
53
545. The 'len' argument from sk_data_ready() callback has been removed in
55 linux kernel v4.3 and above.
56 Ref: https://github.com/torvalds/linux/commit/676d23690fb62b5d51ba5d659935e9f7d9da9f8e
57 Solves:
58-- snip --
59TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c: In function 'iet_socket_bind':
60TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c:143:38: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
61 target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
62 ^
63TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c:144:32: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
64 conn->sock->sk->sk_data_ready = iet_data_ready;
65 ^
66-- snip --
67
686.
69 A. The "size" argument has been dropped from sock_recvmsg syscall in v4.8,
70 as all callers have it equal to msg_data_left(msg).
71 B. 'struct user_msghdr' is being used for userland-side msghdr instead
72 of 'struct msghdr', which is used for kernel-side msghdr in linux v3.19
73 and above, so typecase it while calling sock_recvmsg syscall.
74 Ref: https://github.com/torvalds/linux/commit/2da62906b1e298695e1bb725927041cd59942c98
75 https://github.com/torvalds/linux/commit/666547ff591cebdedc4679bf6b1b3f3383a8dea3
76 Solves:
77 -- snip --
78TOPDIR/tmp-glibc/work-shared/qemux86/kernel-source/include/linux/net.h:222:5: note: expected 'struct msghdr *' but argument is of type 'struct user_msghdr *'
79 int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags);
80 ^~~~~~~~~~~~
81TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c:129:8: error: too many arguments to function 'sock_recvmsg'
82 res = sock_recvmsg(conn->sock, &msg, len, MSG_DONTWAIT | MSG_NOSIGNAL);
83 ^~~~~~~~~~~~
84 -- snip --
85
86Detailed error log is at: http://errors.yoctoproject.org/Errors/Details/83334/
87
88Upstream-Status: Pending
89
90Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
91
92diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c iscsitarget-1.4.20.3+svn502/kernel/block-io.c
93--- iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c 2016-09-25 19:45:01.814641016 +0530
94+++ iscsitarget-1.4.20.3+svn502/kernel/block-io.c 2016-09-25 19:47:59.666474094 +0530
95@@ -57,7 +57,6 @@ static int
96 blockio_make_request(struct iet_volume *volume, struct tio *tio, int rw)
97 {
98 struct blockio_data *bio_data = volume->private;
99- struct request_queue *bdev_q = bdev_get_queue(bio_data->bdev);
100 struct tio_work *tio_work;
101 struct bio *tio_bio = NULL, *bio = NULL, *biotail = NULL;
102 struct blk_plug plug;
103@@ -69,6 +68,7 @@ blockio_make_request(struct iet_volume *
104 int err = 0;
105 loff_t ppos = tio->offset;
106 #else
107+ struct request_queue *bdev_q = bdev_get_queue(bio_data->bdev);
108 int max_pages = 1;
109 int err = 0;
110
111@@ -102,7 +102,11 @@ blockio_make_request(struct iet_volume *
112 /* bi_sector is ALWAYS in units of 512 bytes */
113 bio->bi_iter.bi_sector = ppos >> 9;
114 bio->bi_bdev = bio_data->bdev;
115+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
116+ bio->bi_end_io = (bio_end_io_t *) blockio_bio_endio;
117+#else
118 bio->bi_end_io = blockio_bio_endio;
119+#endif
120 bio->bi_private = tio_work;
121
122 if (tio_bio)
123@@ -137,7 +141,12 @@ blockio_make_request(struct iet_volume *
124 tio_bio = tio_bio->bi_next;
125 bio->bi_next = NULL;
126
127+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
128+ bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
129+ submit_bio(bio);
130+#else
131 submit_bio(rw, bio);
132+#endif
133 }
134
135 blk_finish_plug(&plug);
136diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/conn.c iscsitarget-1.4.20.3+svn502/kernel/conn.c
137--- iscsitarget-1.4.20.3+svn502_org/kernel/conn.c 2016-09-25 19:45:01.774641057 +0530
138+++ iscsitarget-1.4.20.3+svn502/kernel/conn.c 2016-09-25 19:47:59.666474094 +0530
139@@ -89,13 +89,21 @@ static void iet_state_change(struct sock
140 target->nthread_info.old_state_change(sk);
141 }
142
143+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
144+static void iet_data_ready(struct sock *sk)
145+#else
146 static void iet_data_ready(struct sock *sk, int len)
147+#endif
148 {
149 struct iscsi_conn *conn = sk->sk_user_data;
150 struct iscsi_target *target = conn->session->target;
151
152 nthread_wakeup(target);
153+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
154+ target->nthread_info.old_data_ready(sk);
155+#else
156 target->nthread_info.old_data_ready(sk, len);
157+#endif
158 }
159
160 /*
161@@ -140,8 +148,14 @@ static void iet_socket_bind(struct iscsi
162 target->nthread_info.old_state_change = conn->sock->sk->sk_state_change;
163 conn->sock->sk->sk_state_change = iet_state_change;
164
165+#if 0//LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
166+ target->nthread_info.old_data_ready = (void (*) (struct sock *, int )) \
167+ conn->sock->sk->sk_data_ready;
168+ conn->sock->sk->sk_data_ready = (void (*) (struct sock *)) iet_data_ready;
169+#else
170 target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
171 conn->sock->sk->sk_data_ready = iet_data_ready;
172+#endif
173
174 target->nthread_info.old_write_space = conn->sock->sk->sk_write_space;
175 conn->sock->sk->sk_write_space = iet_write_space;
176diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/digest.c iscsitarget-1.4.20.3+svn502/kernel/digest.c
177--- iscsitarget-1.4.20.3+svn502_org/kernel/digest.c 2014-05-07 02:29:55.000000000 +0530
178+++ iscsitarget-1.4.20.3+svn502/kernel/digest.c 2016-09-25 19:47:59.666474094 +0530
179@@ -30,6 +30,9 @@ void digest_alg_available(unsigned int *
180 int digest_init(struct iscsi_conn *conn)
181 {
182 int err = 0;
183+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
184+ struct crypto_ahash *tfm;
185+#endif
186
187 if (!(conn->hdigest_type & DIGEST_ALL))
188 conn->hdigest_type = DIGEST_NONE;
189@@ -39,15 +42,40 @@ int digest_init(struct iscsi_conn *conn)
190
191 if (conn->hdigest_type & DIGEST_CRC32C ||
192 conn->ddigest_type & DIGEST_CRC32C) {
193+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
194+ tfm = crypto_alloc_ahash("crc32c", 0, CRYPTO_ALG_ASYNC);
195+ if (IS_ERR(tfm)) {
196+ tfm = NULL;
197+#else
198 conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
199 CRYPTO_ALG_ASYNC);
200 conn->rx_hash.flags = 0;
201 if (IS_ERR(conn->rx_hash.tfm)) {
202 conn->rx_hash.tfm = NULL;
203+#endif
204 err = -ENOMEM;
205 goto out;
206 }
207-
208+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
209+ conn->rx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
210+ if (!conn->rx_hash) {
211+ pr_err("ahash_request_alloc() failed for conn->rx_hash\n");
212+ crypto_free_ahash(tfm);
213+ err = -ENOMEM;
214+ goto out;
215+ }
216+ ahash_request_set_callback(conn->rx_hash, 0, NULL, NULL);
217+ conn->tx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
218+ if(!conn->tx_hash) {
219+ pr_err("ahash_request_alloc() failed for conn->tx_hash\n");
220+ ahash_request_free(conn->rx_hash);
221+ conn->rx_hash = NULL;
222+ crypto_free_ahash(tfm);
223+ err = -ENOMEM;
224+ goto out;
225+ }
226+ ahash_request_set_callback(conn->tx_hash, 0, NULL, NULL);
227+#else
228 conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
229 CRYPTO_ALG_ASYNC);
230 conn->tx_hash.flags = 0;
231@@ -56,6 +84,7 @@ int digest_init(struct iscsi_conn *conn)
232 err = -ENOMEM;
233 goto out;
234 }
235+#endif
236 }
237
238 out:
239@@ -73,10 +102,21 @@ out:
240 */
241 void digest_cleanup(struct iscsi_conn *conn)
242 {
243+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
244+ ahash_request_free(conn->tx_hash);
245+ if (conn->rx_hash) {
246+ struct crypto_ahash *tfm;
247+ tfm = crypto_ahash_reqtfm(conn->rx_hash);
248+ ahash_request_free(conn->rx_hash);
249+ crypto_free_ahash(tfm);
250+ }
251+
252+#else
253 if (conn->tx_hash.tfm)
254 crypto_free_hash(conn->tx_hash.tfm);
255 if (conn->rx_hash.tfm)
256 crypto_free_hash(conn->rx_hash.tfm);
257+#endif
258 }
259
260 /**
261@@ -160,8 +200,13 @@ static inline void __dbg_simulate_data_d
262 }
263 }
264
265+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
266+static void digest_header(struct ahash_request *hash, struct iscsi_pdu *pdu,
267+ u8 *crc)
268+#else
269 static void digest_header(struct hash_desc *hash, struct iscsi_pdu *pdu,
270 u8 *crc)
271+#endif
272 {
273 struct scatterlist sg[2];
274 unsigned int nbytes = sizeof(struct iscsi_hdr);
275@@ -174,16 +219,27 @@ static void digest_header(struct hash_de
276 nbytes += pdu->ahssize;
277 }
278
279+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
280+ crypto_ahash_init(hash);
281+ ahash_request_set_crypt(hash, sg, crc, nbytes);
282+ crypto_ahash_update(hash);
283+ crypto_ahash_digest(hash);
284+#else
285 crypto_hash_init(hash);
286 crypto_hash_update(hash, sg, nbytes);
287 crypto_hash_final(hash, crc);
288+#endif
289 }
290
291 int digest_rx_header(struct iscsi_cmnd *cmnd)
292 {
293 u32 crc;
294
295+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
296+ digest_header(cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
297+#else
298 digest_header(&cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
299+#endif
300 if (crc != cmnd->hdigest)
301 return -EIO;
302
303@@ -192,11 +248,20 @@ int digest_rx_header(struct iscsi_cmnd *
304
305 void digest_tx_header(struct iscsi_cmnd *cmnd)
306 {
307+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
308+ digest_header(cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
309+#else
310 digest_header(&cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
311+#endif
312 }
313
314+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
315+static void digest_data(struct ahash_request *hash, struct iscsi_cmnd *cmnd,
316+ struct tio *tio, u32 offset, u8 *crc)
317+#else
318 static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
319 struct tio *tio, u32 offset, u8 *crc)
320+#endif
321 {
322 struct scatterlist *sg = cmnd->conn->hash_sg;
323 u32 size, length, npages;
324@@ -214,7 +279,11 @@ static void digest_data(struct hash_desc
325 BUG_ON(npages > ISCSI_CONN_IOV_MAX);
326
327 sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
328+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
329+ crypto_ahash_init(hash);
330+#else
331 crypto_hash_init(hash);
332+#endif
333
334 for (i = 0; size > 0; i++) {
335 length = min_t(u32, PAGE_CACHE_SIZE - offset, size);
336@@ -225,8 +294,14 @@ static void digest_data(struct hash_desc
337
338 sg_mark_end(&sg[i - 1]);
339
340+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
341+ ahash_request_set_crypt(hash, sg, crc, nbytes);
342+ crypto_ahash_update(hash);
343+ crypto_ahash_digest(hash);
344+#else
345 crypto_hash_update(hash, sg, nbytes);
346 crypto_hash_final(hash, crc);
347+#endif
348 }
349
350 int digest_rx_data(struct iscsi_cmnd *cmnd)
351@@ -251,8 +326,11 @@ int digest_rx_data(struct iscsi_cmnd *cm
352 tio = cmnd->tio;
353 offset = 0;
354 }
355-
356+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
357+ digest_data(cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
358+#else
359 digest_data(&cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
360+#endif
361
362 if (!cmnd->conn->read_overflow &&
363 (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
364@@ -269,6 +347,11 @@ void digest_tx_data(struct iscsi_cmnd *c
365 struct iscsi_data_out_hdr *req = (struct iscsi_data_out_hdr *)&cmnd->pdu.bhs;
366
367 assert(tio);
368+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
369+ digest_data(cmnd->conn->tx_hash, cmnd, tio,
370+ be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
371+#else
372 digest_data(&cmnd->conn->tx_hash, cmnd, tio,
373 be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
374+#endif
375 }
376diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h iscsitarget-1.4.20.3+svn502/kernel/iscsi.h
377--- iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h 2016-09-25 19:45:01.734641099 +0530
378+++ iscsitarget-1.4.20.3+svn502/kernel/iscsi.h 2016-09-25 19:47:59.666474094 +0530
379@@ -14,6 +14,7 @@
380 #include <linux/pagemap.h>
381 #include <linux/seq_file.h>
382 #include <linux/mm.h>
383+#include <crypto/hash.h>
384 #include <linux/crypto.h>
385 #include <linux/scatterlist.h>
386 #include <net/sock.h>
387@@ -81,7 +82,11 @@ struct network_thread_info {
388 spinlock_t nthread_lock;
389
390 void (*old_state_change)(struct sock *);
391+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
392+ void (*old_data_ready)(struct sock *);
393+#else
394 void (*old_data_ready)(struct sock *, int);
395+#endif
396 void (*old_write_space)(struct sock *);
397 };
398
399@@ -275,8 +280,13 @@ struct iscsi_conn {
400 u32 write_offset;
401 int write_state;
402
403+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
404+ struct ahash_request *rx_hash;
405+ struct ahash_request *tx_hash;
406+#else
407 struct hash_desc rx_hash;
408 struct hash_desc tx_hash;
409+#endif
410 struct scatterlist hash_sg[ISCSI_CONN_IOV_MAX];
411 };
412
413@@ -552,4 +562,10 @@ enum cmnd_flags {
414 #define PRODUCT_ID "VIRTUAL-DISK"
415 #define PRODUCT_REV "0"
416
417+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
418+#define PAGE_CACHE_SHIFT PAGE_SHIFT
419+#define PAGE_CACHE_SIZE PAGE_SIZE
420+#define PAGE_CACHE_MASK PAGE_MASK
421+#endif
422+
423 #endif /* __ISCSI_H__ */
424diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/nthread.c iscsitarget-1.4.20.3+svn502/kernel/nthread.c
425--- iscsitarget-1.4.20.3+svn502_org/kernel/nthread.c 2016-09-25 19:45:01.734641099 +0530
426+++ iscsitarget-1.4.20.3+svn502/kernel/nthread.c 2016-09-25 19:47:59.666474094 +0530
427@@ -126,7 +126,12 @@ static int do_recv(struct iscsi_conn *co
428
429 oldfs = get_fs();
430 set_fs(get_ds());
431+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
432+ res = sock_recvmsg(conn->sock, (struct msghdr *) &msg, \
433+ MSG_DONTWAIT | MSG_NOSIGNAL);
434+#else
435 res = sock_recvmsg(conn->sock, &msg, len, MSG_DONTWAIT | MSG_NOSIGNAL);
436+#endif
437 set_fs(oldfs);
438
439 if (res <= 0) {
440@@ -347,7 +352,11 @@ static int write_data(struct iscsi_conn
441 ;
442 oldfs = get_fs();
443 set_fs(KERNEL_DS);
444+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
445+ res = vfs_writev(file, (struct iovec __user *) iop, count, &off, 0);
446+#else
447 res = vfs_writev(file, (struct iovec __user *) iop, count, &off);
448+#endif
449 set_fs(oldfs);
450 dprintk(D_DATA, "%#Lx:%u: %d(%ld)\n",
451 (unsigned long long) conn->session->sid, conn->cid,
452@@ -478,7 +487,11 @@ static int tx_ddigest(struct iscsi_cmnd
453 iov.iov_base = (char *) (&cmnd->ddigest) + (sizeof(u32) - rest);
454 iov.iov_len = rest;
455
456+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
457+ res = kernel_sendmsg(cmnd->conn->sock, (struct msghdr *) &msg, &iov, 1, rest);
458+#else
459 res = kernel_sendmsg(cmnd->conn->sock, &msg, &iov, 1, rest);
460+#endif
461
462 if (res > 0) {
463 cmnd->conn->write_size -= res;
464@@ -677,7 +690,12 @@ static void close_conn(struct iscsi_conn
465
466 write_lock_bh(&conn->sock->sk->sk_callback_lock);
467 conn->sock->sk->sk_state_change = target->nthread_info.old_state_change;
468+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
469+ conn->sock->sk->sk_data_ready = (void (*) (struct sock *)) \
470+ target->nthread_info.old_data_ready;
471+#else
472 conn->sock->sk->sk_data_ready = target->nthread_info.old_data_ready;
473+#endif
474 conn->sock->sk->sk_write_space = target->nthread_info.old_write_space;
475 write_unlock_bh(&conn->sock->sk->sk_callback_lock);
476
477diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/volume.c iscsitarget-1.4.20.3+svn502/kernel/volume.c
478--- iscsitarget-1.4.20.3+svn502_org/kernel/volume.c 2016-09-25 19:45:01.734641099 +0530
479+++ iscsitarget-1.4.20.3+svn502/kernel/volume.c 2016-09-25 19:47:59.666474094 +0530
480@@ -84,12 +84,25 @@ static int set_scsisn(struct iet_volume
481 /* Generate a MD5 hash of the target IQN and LUN number */
482 static void gen_scsiid(struct iet_volume *volume)
483 {
484+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
485+ struct ahash_request *hash;
486+ struct crypto_ahash *tfm;
487+#else
488 struct hash_desc hash;
489+#endif
490
491+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
492+ tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC);
493+#else
494 hash.tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
495 hash.flags = 0;
496+#endif
497
498+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
499+ if (!IS_ERR(tfm)) {
500+#else
501 if (!IS_ERR(hash.tfm)) {
502+#endif
503 struct scatterlist sg[2];
504 unsigned int nbytes = 0;
505
506@@ -102,11 +115,19 @@ static void gen_scsiid(struct iet_volume
507 sg_set_buf(&sg[1], &volume->lun, sizeof(volume->lun));
508 nbytes += sizeof(volume->lun);
509
510+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
511+ crypto_ahash_init(hash);
512+ ahash_request_set_crypt(hash, sg, volume->scsi_id, nbytes);
513+ crypto_ahash_update(hash);
514+ crypto_ahash_digest(hash);
515+ crypto_free_ahash(tfm);
516+#else
517 crypto_hash_init(&hash);
518 crypto_hash_update(&hash, sg, nbytes);
519 crypto_hash_final(&hash, volume->scsi_id);
520
521 crypto_free_hash(hash.tfm);
522+#endif
523 } else {
524 /* If no MD5 available set ID to TID and LUN */
525 memcpy(volume->scsi_id, &volume->target->tid,
diff --git a/meta-networking/recipes-extended/iscsitarget/iscsitarget_1.4.20.3+svn502.bb b/meta-networking/recipes-extended/iscsitarget/iscsitarget_1.4.20.3+svn502.bb
index 4b5622b6e..7279bc637 100644
--- a/meta-networking/recipes-extended/iscsitarget/iscsitarget_1.4.20.3+svn502.bb
+++ b/meta-networking/recipes-extended/iscsitarget/iscsitarget_1.4.20.3+svn502.bb
@@ -12,7 +12,8 @@ SRC_URI = "http://ftp.heanet.ie/mirrors/ubuntu/pool/universe/i/${BPN}/${BPN}_${P
12 file://use-kernel-makefile-to-get-kernel-version.patch \ 12 file://use-kernel-makefile-to-get-kernel-version.patch \
13 file://fix-errors-observed-with-linux-3.19-and-greater.patch \ 13 file://fix-errors-observed-with-linux-3.19-and-greater.patch \
14 file://access-sk_v6_daddr-iff-IPV6-defined.patch \ 14 file://access-sk_v6_daddr-iff-IPV6-defined.patch \
15 file://build_with_updated_bio_struct_of_linux_v4.3_and_above.patch" 15 file://build_with_updated_bio_struct_of_linux_v4.3_and_above.patch \
16 file://build_with_updated_interfaces_of_linux_v4.8_and_above.patch"
16 17
17SRC_URI[md5sum] = "ef9bc823bbabd3c772208c00d5f2d089" 18SRC_URI[md5sum] = "ef9bc823bbabd3c772208c00d5f2d089"
18SRC_URI[sha256sum] = "d3196ccb78a43266dce28587bfe30d8ab4db7566d7bce96057dfbb84100babb5" 19SRC_URI[sha256sum] = "d3196ccb78a43266dce28587bfe30d8ab4db7566d7bce96057dfbb84100babb5"
@@ -56,6 +57,3 @@ FILES_${PN} += "${sbindir} \
56 57
57RDEPENDS_${PN} = "kernel-module-iscsi-trgt" 58RDEPENDS_${PN} = "kernel-module-iscsi-trgt"
58RRECOMMENDS_${PN} = "kernel-module-crc32c kernel-module-libcrc32c" 59RRECOMMENDS_${PN} = "kernel-module-crc32c kernel-module-libcrc32c"
59
60# http://errors.yoctoproject.org/Errors/Details/83334/
61PNBLACKLIST[iscsitarget] ?= "BROKEN: not compatible with default kernel version 4.8"