| ... | @@ -1272,6 +1272,16 @@ pub fn unregister_buffers(self: *IoUring) !void { | ... | @@ -1272,6 +1272,16 @@ pub fn unregister_buffers(self: *IoUring) !void { |
| 1272 | } | 1272 | } |
| 1273 | } | 1273 | } |
| 1274 | | 1274 | |
| | 1275 | /// Returns a io_uring_probe which is used to probe the capabilities of the |
| | 1276 | /// io_uring subsystem of the running kernel. The io_uring_probe contains the |
| | 1277 | /// list of supported operations. |
| | 1278 | pub fn get_probe(self: *IoUring) !linux.io_uring_probe { |
| | 1279 | var probe = mem.zeroInit(linux.io_uring_probe, .{}); |
| | 1280 | const res = linux.io_uring_register(self.fd, .REGISTER_PROBE, &probe, probe.ops.len); |
| | 1281 | try handle_register_buf_ring_result(res); |
| | 1282 | return probe; |
| | 1283 | } |
| | 1284 | |
| 1275 | fn handle_registration_result(res: usize) !void { | 1285 | fn handle_registration_result(res: usize) !void { |
| 1276 | switch (linux.E.init(res)) { | 1286 | switch (linux.E.init(res)) { |
| 1277 | .SUCCESS => {}, | 1287 | .SUCCESS => {}, |
| ... | @@ -4355,9 +4365,7 @@ test "copy_cqes with wrapping sq.cqes buffer" { | ... | @@ -4355,9 +4365,7 @@ test "copy_cqes with wrapping sq.cqes buffer" { |
| 4355 | } | 4365 | } |
| 4356 | } | 4366 | } |
| 4357 | | 4367 | |
| 4358 | test "bind" { | 4368 | test "bind/listen/connect" { |
| 4359 | try skipKernelLessThan(.{ .major = 6, .minor = 11, .patch = 0 }); | | |
| 4360 | | | |
| 4361 | var ring = IoUring.init(4, 0) catch |err| switch (err) { | 4369 | var ring = IoUring.init(4, 0) catch |err| switch (err) { |
| 4362 | error.SystemOutdated => return error.SkipZigTest, | 4370 | error.SystemOutdated => return error.SkipZigTest, |
| 4363 | error.PermissionDenied => return error.SkipZigTest, | 4371 | error.PermissionDenied => return error.SkipZigTest, |
| ... | @@ -4365,6 +4373,10 @@ test "bind" { | ... | @@ -4365,6 +4373,10 @@ test "bind" { |
| 4365 | }; | 4373 | }; |
| 4366 | defer ring.deinit(); | 4374 | defer ring.deinit(); |
| 4367 | | 4375 | |
| | 4376 | const probe = ring.get_probe() catch return error.SkipZigTest; |
| | 4377 | // LISTEN is higher required operation |
| | 4378 | if (!probe.is_supported(.LISTEN)) return error.SkipZigTest; |
| | 4379 | |
| 4368 | var addr = net.Address.initIp4([4]u8{ 127, 0, 0, 1 }, 0); | 4380 | var addr = net.Address.initIp4([4]u8{ 127, 0, 0, 1 }, 0); |
| 4369 | const proto: u32 = if (addr.any.family == linux.AF.UNIX) 0 else linux.IPPROTO.TCP; | 4381 | const proto: u32 = if (addr.any.family == linux.AF.UNIX) 0 else linux.IPPROTO.TCP; |
| 4370 | | 4382 | |