@@ -339,6 +339,12 @@ struct io_rw {
339
339
u64 len ;
340
340
};
341
341
342
+ struct io_connect {
343
+ struct file * file ;
344
+ struct sockaddr __user * addr ;
345
+ int addr_len ;
346
+ };
347
+
342
348
struct io_async_connect {
343
349
struct sockaddr_storage address ;
344
350
};
@@ -382,6 +388,7 @@ struct io_kiocb {
382
388
struct io_sync sync ;
383
389
struct io_cancel cancel ;
384
390
struct io_timeout timeout ;
391
+ struct io_connect connect ;
385
392
};
386
393
387
394
const struct io_uring_sqe * sqe ;
@@ -2406,33 +2413,28 @@ static int io_connect_prep(struct io_kiocb *req, struct io_async_ctx *io)
2406
2413
{
2407
2414
#if defined(CONFIG_NET )
2408
2415
const struct io_uring_sqe * sqe = req -> sqe ;
2409
- struct sockaddr __user * addr ;
2410
- int addr_len ;
2411
2416
2412
- addr = u64_to_user_ptr (READ_ONCE (sqe -> addr ));
2413
- addr_len = READ_ONCE (sqe -> addr2 );
2414
- return move_addr_to_kernel (addr , addr_len , & io -> connect .address );
2417
+ if (unlikely (req -> ctx -> flags & (IORING_SETUP_IOPOLL |IORING_SETUP_SQPOLL )))
2418
+ return - EINVAL ;
2419
+ if (sqe -> ioprio || sqe -> len || sqe -> buf_index || sqe -> rw_flags )
2420
+ return - EINVAL ;
2421
+
2422
+ req -> connect .addr = u64_to_user_ptr (READ_ONCE (sqe -> addr ));
2423
+ req -> connect .addr_len = READ_ONCE (sqe -> addr2 );
2424
+ return move_addr_to_kernel (req -> connect .addr , req -> connect .addr_len ,
2425
+ & io -> connect .address );
2415
2426
#else
2416
- return 0 ;
2427
+ return - EOPNOTSUPP ;
2417
2428
#endif
2418
2429
}
2419
2430
2420
2431
static int io_connect (struct io_kiocb * req , struct io_kiocb * * nxt ,
2421
2432
bool force_nonblock )
2422
2433
{
2423
2434
#if defined(CONFIG_NET )
2424
- const struct io_uring_sqe * sqe = req -> sqe ;
2425
2435
struct io_async_ctx __io , * io ;
2426
2436
unsigned file_flags ;
2427
- int addr_len , ret ;
2428
-
2429
- if (unlikely (req -> ctx -> flags & (IORING_SETUP_IOPOLL |IORING_SETUP_SQPOLL )))
2430
- return - EINVAL ;
2431
- if (sqe -> ioprio || sqe -> len || sqe -> buf_index || sqe -> rw_flags )
2432
- return - EINVAL ;
2433
-
2434
- addr_len = READ_ONCE (sqe -> addr2 );
2435
- file_flags = force_nonblock ? O_NONBLOCK : 0 ;
2437
+ int ret ;
2436
2438
2437
2439
if (req -> io ) {
2438
2440
io = req -> io ;
@@ -2443,8 +2445,10 @@ static int io_connect(struct io_kiocb *req, struct io_kiocb **nxt,
2443
2445
io = & __io ;
2444
2446
}
2445
2447
2446
- ret = __sys_connect_file (req -> file , & io -> connect .address , addr_len ,
2447
- file_flags );
2448
+ file_flags = force_nonblock ? O_NONBLOCK : 0 ;
2449
+
2450
+ ret = __sys_connect_file (req -> file , & io -> connect .address ,
2451
+ req -> connect .addr_len , file_flags );
2448
2452
if ((ret == - EAGAIN || ret == - EINPROGRESS ) && force_nonblock ) {
2449
2453
if (req -> io )
2450
2454
return - EAGAIN ;
0 commit comments