File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,7 @@ enum io_uring_op {
258
258
IORING_OP_FIXED_FD_INSTALL ,
259
259
IORING_OP_FTRUNCATE ,
260
260
IORING_OP_BIND ,
261
+ IORING_OP_LISTEN ,
261
262
262
263
/* this goes last, obviously */
263
264
IORING_OP_LAST ,
Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ struct io_bind {
56
56
int addr_len ;
57
57
};
58
58
59
+ struct io_listen {
60
+ struct file * file ;
61
+ int backlog ;
62
+ };
63
+
59
64
struct io_sr_msg {
60
65
struct file * file ;
61
66
union {
@@ -1751,6 +1756,29 @@ int io_bind(struct io_kiocb *req, unsigned int issue_flags)
1751
1756
return 0 ;
1752
1757
}
1753
1758
1759
+ int io_listen_prep (struct io_kiocb * req , const struct io_uring_sqe * sqe )
1760
+ {
1761
+ struct io_listen * listen = io_kiocb_to_cmd (req , struct io_listen );
1762
+
1763
+ if (sqe -> addr || sqe -> buf_index || sqe -> rw_flags || sqe -> splice_fd_in || sqe -> addr2 )
1764
+ return - EINVAL ;
1765
+
1766
+ listen -> backlog = READ_ONCE (sqe -> len );
1767
+ return 0 ;
1768
+ }
1769
+
1770
+ int io_listen (struct io_kiocb * req , unsigned int issue_flags )
1771
+ {
1772
+ struct io_listen * listen = io_kiocb_to_cmd (req , struct io_listen );
1773
+ int ret ;
1774
+
1775
+ ret = __sys_listen_socket (sock_from_file (req -> file ), listen -> backlog );
1776
+ if (ret < 0 )
1777
+ req_set_fail (req );
1778
+ io_req_set_res (req , ret , 0 );
1779
+ return 0 ;
1780
+ }
1781
+
1754
1782
void io_netmsg_cache_free (const void * entry )
1755
1783
{
1756
1784
struct io_async_msghdr * kmsg = (struct io_async_msghdr * ) entry ;
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ void io_send_zc_cleanup(struct io_kiocb *req);
52
52
int io_bind_prep (struct io_kiocb * req , const struct io_uring_sqe * sqe );
53
53
int io_bind (struct io_kiocb * req , unsigned int issue_flags );
54
54
55
+ int io_listen_prep (struct io_kiocb * req , const struct io_uring_sqe * sqe );
56
+ int io_listen (struct io_kiocb * req , unsigned int issue_flags );
57
+
55
58
void io_netmsg_cache_free (const void * entry );
56
59
#else
57
60
static inline void io_netmsg_cache_free (const void * entry )
Original file line number Diff line number Diff line change @@ -503,6 +503,16 @@ const struct io_issue_def io_issue_defs[] = {
503
503
.async_size = sizeof (struct io_async_msghdr ),
504
504
#else
505
505
.prep = io_eopnotsupp_prep ,
506
+ #endif
507
+ },
508
+ [IORING_OP_LISTEN ] = {
509
+ #if defined(CONFIG_NET )
510
+ .needs_file = 1 ,
511
+ .prep = io_listen_prep ,
512
+ .issue = io_listen ,
513
+ .async_size = sizeof (struct io_async_msghdr ),
514
+ #else
515
+ .prep = io_eopnotsupp_prep ,
506
516
#endif
507
517
},
508
518
};
@@ -729,6 +739,9 @@ const struct io_cold_def io_cold_defs[] = {
729
739
[IORING_OP_BIND ] = {
730
740
.name = "BIND" ,
731
741
},
742
+ [IORING_OP_LISTEN ] = {
743
+ .name = "LISTEN" ,
744
+ },
732
745
};
733
746
734
747
const char * io_uring_get_opcode (u8 opcode )
You can’t perform that action at this time.
0 commit comments